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,180 +0,0 @@
|
|
|
1
|
-
const path = require('path');
|
|
2
|
-
const test = require('tape');
|
|
3
|
-
const fse = require('fs-extra');
|
|
4
|
-
const { Proskomma } = require('../../../src/index.cjs');
|
|
5
|
-
const { pkWithDocs } = require('../../lib/load.js');
|
|
6
|
-
const { blocksSpec2Query } = require('../../../src/util/scriptlike/blocksSpec.cjs');
|
|
7
|
-
|
|
8
|
-
const testGroup = 'Mutate Add Operations';
|
|
9
|
-
|
|
10
|
-
const pk = new Proskomma();
|
|
11
|
-
let content = fse.readFileSync(
|
|
12
|
-
path.resolve(__dirname, '../../test_data/usx/web_rut.usx'),
|
|
13
|
-
).toString();
|
|
14
|
-
|
|
15
|
-
test(
|
|
16
|
-
`Document (${testGroup})`,
|
|
17
|
-
async function (t) {
|
|
18
|
-
try {
|
|
19
|
-
t.plan(10);
|
|
20
|
-
let query = '{ docSets { id } }';
|
|
21
|
-
let result = await pk.gqlQuery(query);
|
|
22
|
-
t.equal(result.errors, undefined);
|
|
23
|
-
t.equal(result.data.docSets.length, 0);
|
|
24
|
-
query = `mutation { addDocument(` +
|
|
25
|
-
`selectors: [{key: "lang", value: "eng"}, {key: "abbr", value: "ust"}], ` +
|
|
26
|
-
`contentType: "usx", ` +
|
|
27
|
-
`content: """${content}"""` +
|
|
28
|
-
`tags: ["foo", "baa"]) }`;
|
|
29
|
-
result = await pk.gqlQuery(query);
|
|
30
|
-
t.equal(result.errors, undefined);
|
|
31
|
-
t.equal(result.data.addDocument, true);
|
|
32
|
-
query = '{ docSets { id documents { id tags mainSequence { nBlocks } } } }';
|
|
33
|
-
result = await pk.gqlQuery(query);
|
|
34
|
-
t.equal(result.data.docSets.length, 1);
|
|
35
|
-
t.equal(result.data.docSets[0].documents.length, 1);
|
|
36
|
-
t.ok(result.data.docSets[0].documents[0].mainSequence.nBlocks > 0);
|
|
37
|
-
t.equal(result.data.docSets[0].documents[0].tags.length, 2);
|
|
38
|
-
t.ok(result.data.docSets[0].documents[0].tags.includes('foo'));
|
|
39
|
-
t.ok(result.data.docSets[0].documents[0].tags.includes('baa'));
|
|
40
|
-
} catch (err) {
|
|
41
|
-
console.log(err);
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
|
-
);
|
|
45
|
-
|
|
46
|
-
test(
|
|
47
|
-
`Sequence (${testGroup})`,
|
|
48
|
-
async function (t) {
|
|
49
|
-
try {
|
|
50
|
-
t.plan(9);
|
|
51
|
-
let query = '{ documents { id nSequences sequences { id type } } }';
|
|
52
|
-
let result = await pk.gqlQuery(query);
|
|
53
|
-
t.equal(result.errors, undefined);
|
|
54
|
-
const docId = result.data.documents[0].id;
|
|
55
|
-
const nSequences = result.data.documents[0].nSequences;
|
|
56
|
-
t.equal(result.data.documents[0].sequences.filter(s => s.type === 'banana').length, 0);
|
|
57
|
-
query = `mutation { newSequence(` +
|
|
58
|
-
` documentId: "${docId}"` +
|
|
59
|
-
` type: "banana"` +
|
|
60
|
-
` tags: ["yellow", "tasty"]) }`;
|
|
61
|
-
result = await pk.gqlQuery(query);
|
|
62
|
-
t.equal(result.errors, undefined);
|
|
63
|
-
const newSequenceId = result.data.newSequence;
|
|
64
|
-
query = '{ documents { id nSequences sequences { id type tags } } }';
|
|
65
|
-
result = await pk.gqlQuery(query);
|
|
66
|
-
t.equal(result.errors, undefined);
|
|
67
|
-
t.equal(result.data.documents[0].nSequences, nSequences + 1);
|
|
68
|
-
const bananaSequence = result.data.documents[0].sequences.filter(s => s.type === 'banana');
|
|
69
|
-
t.equal(bananaSequence.length, 1);
|
|
70
|
-
t.equal(result.data.documents[0].sequences.filter(s => s.id === newSequenceId).length, 1);
|
|
71
|
-
t.ok(bananaSequence[0].tags.includes('yellow'));
|
|
72
|
-
t.ok(bananaSequence[0].tags.includes('tasty'));
|
|
73
|
-
} catch (err) {
|
|
74
|
-
console.log(err);
|
|
75
|
-
}
|
|
76
|
-
},
|
|
77
|
-
);
|
|
78
|
-
|
|
79
|
-
test(
|
|
80
|
-
`Sequence with graft (${testGroup})`,
|
|
81
|
-
async function (t) {
|
|
82
|
-
try {
|
|
83
|
-
t.plan(8);
|
|
84
|
-
let query = '{ documents { id nSequences sequences { id type } } }';
|
|
85
|
-
let result = await pk.gqlQuery(query);
|
|
86
|
-
t.equal(result.errors, undefined);
|
|
87
|
-
const docId = result.data.documents[0].id;
|
|
88
|
-
const nSequences = result.data.documents[0].nSequences;
|
|
89
|
-
t.equal(result.data.documents[0].sequences.filter(s => s.type === 'table').length, 0);
|
|
90
|
-
query = `mutation { newSequence(` +
|
|
91
|
-
` documentId: "${docId}"` +
|
|
92
|
-
` type: "table"` +
|
|
93
|
-
` graftToMain: true) }`;
|
|
94
|
-
result = await pk.gqlQuery(query);
|
|
95
|
-
t.equal(result.errors, undefined);
|
|
96
|
-
const newSequenceId = result.data.newSequence;
|
|
97
|
-
query = '{ documents { id mainSequence { id blocks { bg { payload } } } nSequences sequences { id type } } }';
|
|
98
|
-
result = await pk.gqlQuery(query);
|
|
99
|
-
t.equal(result.errors, undefined);
|
|
100
|
-
t.equal(result.data.documents[0].nSequences, nSequences + 1);
|
|
101
|
-
t.equal(result.data.documents[0].sequences.filter(s => s.type === 'table').length, 1);
|
|
102
|
-
t.equal(result.data.documents[0].sequences.filter(s => s.id === newSequenceId).length, 1);
|
|
103
|
-
const mainSequenceFirstBlockGrafts = result.data.documents[0].mainSequence.blocks[0].bg.map(g => g.payload);
|
|
104
|
-
t.ok(mainSequenceFirstBlockGrafts.includes(newSequenceId));
|
|
105
|
-
} catch (err) {
|
|
106
|
-
console.log(err);
|
|
107
|
-
}
|
|
108
|
-
},
|
|
109
|
-
);
|
|
110
|
-
|
|
111
|
-
test(
|
|
112
|
-
`Sequence with block content (${testGroup})`,
|
|
113
|
-
async function (t) {
|
|
114
|
-
try {
|
|
115
|
-
t.plan(8);
|
|
116
|
-
const blocksSpec = fse.readJSONSync(path.resolve(__dirname, '../../test_data/inputBlockSpec/mk1.json'));
|
|
117
|
-
const blockQuery = blocksSpec2Query(blocksSpec);
|
|
118
|
-
let query = '{ documents { id nSequences sequences { id type } } }';
|
|
119
|
-
let result = await pk.gqlQuery(query);
|
|
120
|
-
t.equal(result.errors, undefined);
|
|
121
|
-
const docId = result.data.documents[0].id;
|
|
122
|
-
const nSequences = result.data.documents[0].nSequences;
|
|
123
|
-
t.equal(result.data.documents[0].sequences.filter(s => s.type === 'table').length, 1);
|
|
124
|
-
query = `mutation { newSequence(` +
|
|
125
|
-
` documentId: "${docId}"` +
|
|
126
|
-
` type: "randomText"` +
|
|
127
|
-
` blocksSpec: ${blockQuery}` +
|
|
128
|
-
` graftToMain: true) }`;
|
|
129
|
-
result = await pk.gqlQuery(query);
|
|
130
|
-
t.equal(result.errors, undefined);
|
|
131
|
-
const newSequenceId = result.data.newSequence;
|
|
132
|
-
query = '{ documents { id nSequences sequences { id type blocks { text } } } }';
|
|
133
|
-
result = await pk.gqlQuery(query);
|
|
134
|
-
t.equal(result.errors, undefined);
|
|
135
|
-
t.equal(result.data.documents[0].nSequences, nSequences + 1);
|
|
136
|
-
const newSequence = result.data.documents[0].sequences.filter(s => s.id === newSequenceId)[0];
|
|
137
|
-
t.equal(result.data.documents[0].sequences.filter(s => s.id === newSequenceId).length, 1);
|
|
138
|
-
t.equal(newSequence.type, 'randomText');
|
|
139
|
-
t.ok(newSequence.blocks[0].text.startsWith('Start of the Good News'));
|
|
140
|
-
} catch (err) {
|
|
141
|
-
console.log(err);
|
|
142
|
-
}
|
|
143
|
-
},
|
|
144
|
-
);
|
|
145
|
-
|
|
146
|
-
test(
|
|
147
|
-
`Block (${testGroup})`,
|
|
148
|
-
async function (t) {
|
|
149
|
-
try {
|
|
150
|
-
t.plan(7);
|
|
151
|
-
const pk = pkWithDocs(
|
|
152
|
-
[
|
|
153
|
-
['../test_data/usfm/1pe_webbe.usfm', {
|
|
154
|
-
lang: 'eng',
|
|
155
|
-
abbr: 'web',
|
|
156
|
-
}],
|
|
157
|
-
],
|
|
158
|
-
);
|
|
159
|
-
let query = '{ documents { id mainSequence { id nBlocks } } }';
|
|
160
|
-
let result = await pk.gqlQuery(query);
|
|
161
|
-
t.equal(result.errors, undefined);
|
|
162
|
-
const docId = result.data.documents[0].id;
|
|
163
|
-
const seqId = result.data.documents[0].mainSequence.id;
|
|
164
|
-
const nBlocks = result.data.documents[0].mainSequence.nBlocks;
|
|
165
|
-
t.equal(nBlocks, 3);
|
|
166
|
-
query = `mutation { newBlock(documentId: "${docId}" sequenceId: "${seqId}" blockN: 1, blockScope: "blockTag/q4") }`;
|
|
167
|
-
result = await pk.gqlQuery(query);
|
|
168
|
-
t.equal(result.errors, undefined);
|
|
169
|
-
t.equal(result.data.newBlock, true);
|
|
170
|
-
query = '{ documents { id mainSequence { id nBlocks blocks(positions:[1]) { bs { payload } } } } }';
|
|
171
|
-
result = await pk.gqlQuery(query);
|
|
172
|
-
t.equal(result.errors, undefined);
|
|
173
|
-
t.equal(result.data.documents[0].mainSequence.nBlocks, nBlocks + 1);
|
|
174
|
-
t.equal(result.data.documents[0].mainSequence.blocks[0].bs.payload, 'blockTag/q4');
|
|
175
|
-
} catch (err) {
|
|
176
|
-
console.log(err);
|
|
177
|
-
}
|
|
178
|
-
},
|
|
179
|
-
);
|
|
180
|
-
|
|
@@ -1,236 +0,0 @@
|
|
|
1
|
-
const path = require('path');
|
|
2
|
-
const test = require('tape');
|
|
3
|
-
const fse = require('fs-extra');
|
|
4
|
-
const {
|
|
5
|
-
pkWithDoc,
|
|
6
|
-
pkWithDocs,
|
|
7
|
-
} = require('../../lib/load.js');
|
|
8
|
-
|
|
9
|
-
const testGroup = 'Mutate Delete Operations';
|
|
10
|
-
|
|
11
|
-
test(
|
|
12
|
-
`DocSet (${testGroup})`,
|
|
13
|
-
async function (t) {
|
|
14
|
-
try {
|
|
15
|
-
t.plan(9);
|
|
16
|
-
const pk = pkWithDoc('../test_data/usx/web_rut.usx', {
|
|
17
|
-
lang: 'eng',
|
|
18
|
-
abbr: 'ust',
|
|
19
|
-
}, {}, {}, [], [])[0];
|
|
20
|
-
let query = '{ docSets { id } }';
|
|
21
|
-
let result = await pk.gqlQuery(query);
|
|
22
|
-
t.equal(result.errors, undefined);
|
|
23
|
-
t.equal(result.data.docSets.length, 1);
|
|
24
|
-
query = `mutation { deleteDocSet(docSetId: "foo/baa") }`;
|
|
25
|
-
result = await pk.gqlQuery(query);
|
|
26
|
-
t.equal(result.errors, undefined);
|
|
27
|
-
t.equal(result.data.deleteDocSet, false);
|
|
28
|
-
query = '{ docSets { id } }';
|
|
29
|
-
result = await pk.gqlQuery(query);
|
|
30
|
-
t.equal(result.data.docSets.length, 1);
|
|
31
|
-
query = `mutation { deleteDocSet(docSetId: "${result.data.docSets[0].id}") }`;
|
|
32
|
-
result = await pk.gqlQuery(query);
|
|
33
|
-
t.equal(result.errors, undefined);
|
|
34
|
-
t.equal(result.data.deleteDocSet, true);
|
|
35
|
-
query = '{ nDocSets nDocuments }';
|
|
36
|
-
result = await pk.gqlQuery(query);
|
|
37
|
-
t.equal(result.data.nDocSets, 0);
|
|
38
|
-
t.equal(result.data.nDocuments, 0);
|
|
39
|
-
} catch (err) {
|
|
40
|
-
console.log(err);
|
|
41
|
-
}
|
|
42
|
-
},
|
|
43
|
-
);
|
|
44
|
-
|
|
45
|
-
test(
|
|
46
|
-
`Reload Deleted DocSet (${testGroup})`,
|
|
47
|
-
async function (t) {
|
|
48
|
-
try {
|
|
49
|
-
t.plan(3);
|
|
50
|
-
const selectors = {
|
|
51
|
-
lang: 'eng',
|
|
52
|
-
abbr: 'ust',
|
|
53
|
-
};
|
|
54
|
-
const pk = pkWithDoc('../test_data/usx/web_rut.usx', selectors, {}, {}, [], [])[0];
|
|
55
|
-
let query = '{ docSets { id } }';
|
|
56
|
-
let result = await pk.gqlQuery(query);
|
|
57
|
-
query = `mutation { deleteDocSet(docSetId: "${result.data.docSets[0].id}") }`;
|
|
58
|
-
result = await pk.gqlQuery(query);
|
|
59
|
-
query = '{ docSets { id } nDocuments}';
|
|
60
|
-
result = await pk.gqlQuery(query);
|
|
61
|
-
t.equal(result.data.docSets.length, 0);
|
|
62
|
-
t.equal(result.data.nDocuments, 0);
|
|
63
|
-
const content = fse.readFileSync(path.resolve(__dirname, '../../test_data/usx/web_rut.usx'));
|
|
64
|
-
|
|
65
|
-
t.doesNotThrow(
|
|
66
|
-
() => pk.importDocument(
|
|
67
|
-
selectors,
|
|
68
|
-
'usx',
|
|
69
|
-
content,
|
|
70
|
-
{},
|
|
71
|
-
),
|
|
72
|
-
);
|
|
73
|
-
} catch (err) {
|
|
74
|
-
console.log(err);
|
|
75
|
-
}
|
|
76
|
-
},
|
|
77
|
-
);
|
|
78
|
-
|
|
79
|
-
test(
|
|
80
|
-
`Document (${testGroup})`,
|
|
81
|
-
async function (t) {
|
|
82
|
-
try {
|
|
83
|
-
t.plan(9);
|
|
84
|
-
const pk = pkWithDocs(
|
|
85
|
-
[
|
|
86
|
-
['../test_data/usx/web_rut.usx', {
|
|
87
|
-
lang: 'eng',
|
|
88
|
-
abbr: 'ust',
|
|
89
|
-
}],
|
|
90
|
-
['../test_data/usx/web_psa150.usx', {
|
|
91
|
-
lang: 'eng',
|
|
92
|
-
abbr: 'ust',
|
|
93
|
-
}],
|
|
94
|
-
],
|
|
95
|
-
);
|
|
96
|
-
let query = '{ docSets { id documents { id } } }';
|
|
97
|
-
let result = await pk.gqlQuery(query);
|
|
98
|
-
t.equal(result.errors, undefined);
|
|
99
|
-
t.equal(result.data.docSets.length, 1);
|
|
100
|
-
t.equal(result.data.docSets[0].documents.length, 2);
|
|
101
|
-
const aDocumentId = result.data.docSets[0].documents[0].id;
|
|
102
|
-
query = `mutation { deleteDocument(docSetId: "${result.data.docSets[0].id}", documentId: "foobaa") }`;
|
|
103
|
-
result = await pk.gqlQuery(query);
|
|
104
|
-
t.equal(result.errors, undefined);
|
|
105
|
-
t.equal(result.data.deleteDocument, false);
|
|
106
|
-
query = '{ docSets { id documents { id } } }';
|
|
107
|
-
result = await pk.gqlQuery(query);
|
|
108
|
-
t.equal(result.data.docSets[0].documents.length, 2);
|
|
109
|
-
query = `mutation { deleteDocument(docSetId: "${result.data.docSets[0].id}", documentId: "${aDocumentId}") }`;
|
|
110
|
-
result = await pk.gqlQuery(query);
|
|
111
|
-
t.equal(result.errors, undefined);
|
|
112
|
-
t.equal(result.data.deleteDocument, true);
|
|
113
|
-
query = '{ docSets { id documents { id } } }';
|
|
114
|
-
result = await pk.gqlQuery(query);
|
|
115
|
-
t.equal(result.data.docSets.length, 1);
|
|
116
|
-
} catch (err) {
|
|
117
|
-
console.log(err);
|
|
118
|
-
}
|
|
119
|
-
},
|
|
120
|
-
);
|
|
121
|
-
|
|
122
|
-
test(
|
|
123
|
-
`Inline Sequence (${testGroup})`,
|
|
124
|
-
async function (t) {
|
|
125
|
-
try {
|
|
126
|
-
t.plan(12);
|
|
127
|
-
const pk = pkWithDocs(
|
|
128
|
-
[
|
|
129
|
-
['../test_data/usx/web_rut.usx', {
|
|
130
|
-
lang: 'eng',
|
|
131
|
-
abbr: 'ust',
|
|
132
|
-
}],
|
|
133
|
-
],
|
|
134
|
-
);
|
|
135
|
-
let query = '{ documents { id nSequences mainSequence { id blocks(positions:[0]) { items { type subType payload } } } } }';
|
|
136
|
-
let result = await pk.gqlQuery(query);
|
|
137
|
-
t.equal(result.errors, undefined);
|
|
138
|
-
t.equal(result.data.documents.length, 1);
|
|
139
|
-
const docId = result.data.documents[0].id;
|
|
140
|
-
const nSequences = result.data.documents[0].nSequences;
|
|
141
|
-
const items = result.data.documents[0].mainSequence.blocks[0].items;
|
|
142
|
-
const mainId = result.data.documents[0].mainSequence.id;
|
|
143
|
-
const graft = items.filter(i => i.type === 'graft')[0];
|
|
144
|
-
query = `mutation { deleteSequence(documentId: "foo" sequenceId: "${graft.payload}") }`;
|
|
145
|
-
result = await pk.gqlQuery(query);
|
|
146
|
-
t.equal(result.errors.length, 1);
|
|
147
|
-
t.ok(result.errors[0].message.startsWith('Document \'foo\' not found'));
|
|
148
|
-
query = `mutation { deleteSequence(documentId: "${docId}" sequenceId: "${mainId}") }`;
|
|
149
|
-
result = await pk.gqlQuery(query);
|
|
150
|
-
t.equal(result.errors.length, 1);
|
|
151
|
-
t.ok(result.errors[0].message.startsWith('Cannot delete main sequence'));
|
|
152
|
-
query = `mutation { deleteSequence(documentId: "${docId}" sequenceId: "baa") }`;
|
|
153
|
-
result = await pk.gqlQuery(query);
|
|
154
|
-
t.equal(result.errors, undefined);
|
|
155
|
-
t.equal(result.data.deleteSequence, false);
|
|
156
|
-
query = `mutation { deleteSequence(documentId: "${docId}" sequenceId: "${graft.payload}") }`;
|
|
157
|
-
result = await pk.gqlQuery(query);
|
|
158
|
-
t.equal(result.errors, undefined);
|
|
159
|
-
t.equal(result.data.deleteSequence, true);
|
|
160
|
-
query = '{ documents { id nSequences mainSequence { id blocks(positions:[0]) { items { type subType payload } } } } }';
|
|
161
|
-
result = await pk.gqlQuery(query);
|
|
162
|
-
t.equal(result.errors, undefined);
|
|
163
|
-
t.equal(result.data.documents[0].nSequences, nSequences - 2);
|
|
164
|
-
} catch (err) {
|
|
165
|
-
console.log(err);
|
|
166
|
-
}
|
|
167
|
-
},
|
|
168
|
-
);
|
|
169
|
-
|
|
170
|
-
test(
|
|
171
|
-
`Block-Grafted Sequence (${testGroup})`,
|
|
172
|
-
async function (t) {
|
|
173
|
-
try {
|
|
174
|
-
t.plan(6);
|
|
175
|
-
const pk = pkWithDocs(
|
|
176
|
-
[
|
|
177
|
-
['../test_data/usx/not_nfc18_phm.usx', {
|
|
178
|
-
lang: 'fra',
|
|
179
|
-
abbr: 'nfc18',
|
|
180
|
-
}],
|
|
181
|
-
],
|
|
182
|
-
);
|
|
183
|
-
let query = '{ documents { id nSequences mainSequence { id blocks(positions:[0]) { bg { subType payload } } } } }';
|
|
184
|
-
let result = await pk.gqlQuery(query);
|
|
185
|
-
t.equal(result.errors, undefined);
|
|
186
|
-
t.equal(result.data.documents.length, 1);
|
|
187
|
-
const docId = result.data.documents[0].id;
|
|
188
|
-
const nSequences = result.data.documents[0].nSequences;
|
|
189
|
-
const graftSeqId = result.data.documents[0].mainSequence.blocks[0].bg[0].payload;
|
|
190
|
-
query = `mutation { deleteSequence(documentId: "${docId}" sequenceId: "${graftSeqId}") }`;
|
|
191
|
-
result = await pk.gqlQuery(query);
|
|
192
|
-
t.equal(result.errors, undefined);
|
|
193
|
-
t.equal(result.data.deleteSequence, true);
|
|
194
|
-
query = '{ documents { id nSequences } }';
|
|
195
|
-
result = await pk.gqlQuery(query);
|
|
196
|
-
t.equal(result.errors, undefined);
|
|
197
|
-
t.equal(result.data.documents[0].nSequences, nSequences - 1);
|
|
198
|
-
} catch (err) {
|
|
199
|
-
console.log(err);
|
|
200
|
-
}
|
|
201
|
-
},
|
|
202
|
-
);
|
|
203
|
-
|
|
204
|
-
test(
|
|
205
|
-
`Block (${testGroup})`,
|
|
206
|
-
async function (t) {
|
|
207
|
-
try {
|
|
208
|
-
t.plan(6);
|
|
209
|
-
const pk = pkWithDocs(
|
|
210
|
-
[
|
|
211
|
-
['../test_data/usfm/1pe_webbe.usfm', {
|
|
212
|
-
lang: 'eng',
|
|
213
|
-
abbr: 'web',
|
|
214
|
-
}],
|
|
215
|
-
],
|
|
216
|
-
);
|
|
217
|
-
let query = '{ documents { id mainSequence { id nBlocks } } }';
|
|
218
|
-
let result = await pk.gqlQuery(query);
|
|
219
|
-
t.equal(result.errors, undefined);
|
|
220
|
-
const docId = result.data.documents[0].id;
|
|
221
|
-
const seqId = result.data.documents[0].mainSequence.id;
|
|
222
|
-
const nBlocks = result.data.documents[0].mainSequence.nBlocks;
|
|
223
|
-
t.equal(nBlocks, 3);
|
|
224
|
-
query = `mutation { deleteBlock(documentId: "${docId}" sequenceId: "${seqId}" blockN: 1) }`;
|
|
225
|
-
result = await pk.gqlQuery(query);
|
|
226
|
-
t.equal(result.errors, undefined);
|
|
227
|
-
t.equal(result.data.deleteBlock, true);
|
|
228
|
-
query = '{ documents { id mainSequence { id nBlocks blocks { items { type subType payload } } } } }';
|
|
229
|
-
result = await pk.gqlQuery(query);
|
|
230
|
-
t.equal(result.errors, undefined);
|
|
231
|
-
t.equal(result.data.documents[0].mainSequence.nBlocks, nBlocks - 1);
|
|
232
|
-
} catch (err) {
|
|
233
|
-
console.log(err);
|
|
234
|
-
}
|
|
235
|
-
},
|
|
236
|
-
);
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
const path = require('path');
|
|
2
|
-
const test = require('tape');
|
|
3
|
-
const fse = require('fs-extra');
|
|
4
|
-
const { pkWithDoc } = require('../../lib/load.js');
|
|
5
|
-
|
|
6
|
-
const pk = pkWithDoc('../test_data/usx/web_psa150.usx', {
|
|
7
|
-
lang: 'eng',
|
|
8
|
-
abbr: 'web',
|
|
9
|
-
}, {}, {}, [], [])[0];
|
|
10
|
-
|
|
11
|
-
const testGroup = 'Rehash';
|
|
12
|
-
|
|
13
|
-
test(
|
|
14
|
-
`One Document (${testGroup})`,
|
|
15
|
-
async function (t) {
|
|
16
|
-
try {
|
|
17
|
-
t.plan(8);
|
|
18
|
-
let query = '{ docSets { id documents { id mainSequence { nBlocks blocks { dump } } } } }';
|
|
19
|
-
let result = await pk.gqlQuery(query);
|
|
20
|
-
t.equal(result.errors, undefined);
|
|
21
|
-
t.equal(result.data.docSets.length, 1);
|
|
22
|
-
const nMainSequenceBlocks = result.data.docSets[0].documents[0].mainSequence.nBlocks;
|
|
23
|
-
query = `mutation { rehashDocSet(docSetId: "${result.data.docSets[0].id}") }`;
|
|
24
|
-
result = await pk.gqlQuery(query);
|
|
25
|
-
t.equal(result.errors, undefined);
|
|
26
|
-
t.equal(result.data.rehashDocSet, true);
|
|
27
|
-
query = '{ docSets { id documents { id mainSequence { nBlocks blocks { dump } } } } }';
|
|
28
|
-
result = await pk.gqlQuery(query);
|
|
29
|
-
t.equal(result.errors, undefined);
|
|
30
|
-
t.equal(result.data.docSets.length, 1);
|
|
31
|
-
t.equal(result.data.docSets[0].documents.length, 1);
|
|
32
|
-
t.equal(result.data.docSets[0].documents[0].mainSequence.nBlocks, nMainSequenceBlocks);
|
|
33
|
-
} catch (err) {
|
|
34
|
-
console.log(err);
|
|
35
|
-
}
|
|
36
|
-
},
|
|
37
|
-
);
|
|
38
|
-
|
|
39
|
-
test(
|
|
40
|
-
`After adding document (${testGroup})`,
|
|
41
|
-
async function (t) {
|
|
42
|
-
try {
|
|
43
|
-
t.plan(6);
|
|
44
|
-
let query = '{ docSets { id documents { id mainSequence { nBlocks blocks { dump } } } } }';
|
|
45
|
-
let result = await pk.gqlQuery(query);
|
|
46
|
-
t.equal(result.errors, undefined);
|
|
47
|
-
t.equal(result.data.docSets.length, 1);
|
|
48
|
-
// const firstDocumentId = result.data.docSets[0].documents[0].id;
|
|
49
|
-
// const nMainSequenceBlocks = result.data.docSets[0].documents[0].mainSequence.nBlocks;
|
|
50
|
-
const content = fse.readFileSync(path.resolve(__dirname, '../../test_data/usx/web_rut.usx'));
|
|
51
|
-
|
|
52
|
-
pk.importDocument({
|
|
53
|
-
lang: 'eng',
|
|
54
|
-
abbr: 'web',
|
|
55
|
-
}, 'usx', content);
|
|
56
|
-
query = `mutation { rehashDocSet(docSetId: "${result.data.docSets[0].id}") }`;
|
|
57
|
-
result = await pk.gqlQuery(query);
|
|
58
|
-
t.equal(result.errors, undefined);
|
|
59
|
-
t.equal(result.data.rehashDocSet, true);
|
|
60
|
-
query = '{ docSets { id documents { id mainSequence { nBlocks blocks { dump } } } } }';
|
|
61
|
-
result = await pk.gqlQuery(query);
|
|
62
|
-
t.equal(result.errors, undefined);
|
|
63
|
-
t.equal(result.data.docSets[0].documents.length, 2);
|
|
64
|
-
} catch (err) {
|
|
65
|
-
console.log(err);
|
|
66
|
-
}
|
|
67
|
-
},
|
|
68
|
-
);
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
const test = require('tape');
|
|
2
|
-
const { pkWithDoc } = require('../../lib/load.js');
|
|
3
|
-
|
|
4
|
-
const pk = pkWithDoc('../test_data/usx/web_rut.usx', {
|
|
5
|
-
lang: 'eng',
|
|
6
|
-
abbr: 'ust',
|
|
7
|
-
}, {}, {}, [], [])[0];
|
|
8
|
-
|
|
9
|
-
const testGroup = 'Mutate Tags';
|
|
10
|
-
|
|
11
|
-
test(
|
|
12
|
-
`DocSet (${testGroup})`,
|
|
13
|
-
async function (t) {
|
|
14
|
-
try {
|
|
15
|
-
t.plan(6);
|
|
16
|
-
let query = '{ docSets { id tags } }';
|
|
17
|
-
let result = await pk.gqlQuery(query);
|
|
18
|
-
t.equal(result.errors, undefined);
|
|
19
|
-
const docSet = result.data.docSets[0];
|
|
20
|
-
t.equal(docSet.tags.length, 0);
|
|
21
|
-
query = `mutation { addDocSetTags(docSetId: "${docSet.id}", tags: ["foo", "baa"]) }`;
|
|
22
|
-
result = await pk.gqlQuery(query);
|
|
23
|
-
t.equal(result.data.addDocSetTags.length, 2);
|
|
24
|
-
query = `mutation { addDocSetTags(docSetId: "${docSet.id}", tags: ["foo", "frob"]) }`;
|
|
25
|
-
result = await pk.gqlQuery(query);
|
|
26
|
-
t.equal(result.data.addDocSetTags.length, 3);
|
|
27
|
-
query = `mutation { removeDocSetTags(docSetId: "${docSet.id}", tags: ["baa", "frob"]) }`;
|
|
28
|
-
result = await pk.gqlQuery(query);
|
|
29
|
-
t.equal(result.data.removeDocSetTags.length, 1);
|
|
30
|
-
t.ok(result.data.removeDocSetTags.includes('foo'));
|
|
31
|
-
} catch (err) {
|
|
32
|
-
console.log(err);
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
test(
|
|
38
|
-
`Document (${testGroup})`,
|
|
39
|
-
async function (t) {
|
|
40
|
-
try {
|
|
41
|
-
t.plan(6);
|
|
42
|
-
let query = '{ docSets { id documents { id tags } } }';
|
|
43
|
-
let result = await pk.gqlQuery(query);
|
|
44
|
-
t.equal(result.errors, undefined);
|
|
45
|
-
const docSet = result.data.docSets[0];
|
|
46
|
-
const document = docSet.documents[0];
|
|
47
|
-
t.equal(document.tags.length, 0);
|
|
48
|
-
query = `mutation { addDocumentTags(docSetId: "${docSet.id}", documentId: "${document.id}", tags: ["foo", "baa"]) }`;
|
|
49
|
-
result = await pk.gqlQuery(query);
|
|
50
|
-
t.equal(result.data.addDocumentTags.length, 2);
|
|
51
|
-
query = `mutation { addDocumentTags(docSetId: "${docSet.id}", documentId: "${document.id}", tags: ["foo", "frob"]) }`;
|
|
52
|
-
result = await pk.gqlQuery(query);
|
|
53
|
-
t.equal(result.data.addDocumentTags.length, 3);
|
|
54
|
-
query = `mutation { removeDocumentTags(docSetId: "${docSet.id}", documentId: "${document.id}", tags: ["baa", "frob"]) }`;
|
|
55
|
-
result = await pk.gqlQuery(query);
|
|
56
|
-
t.equal(result.data.removeDocumentTags.length, 1);
|
|
57
|
-
t.ok(result.data.removeDocumentTags.includes('foo'));
|
|
58
|
-
} catch (err) {
|
|
59
|
-
console.log(err);
|
|
60
|
-
}
|
|
61
|
-
},
|
|
62
|
-
);
|
|
63
|
-
|
|
64
|
-
test(
|
|
65
|
-
`Sequence (${testGroup})`,
|
|
66
|
-
async function (t) {
|
|
67
|
-
try {
|
|
68
|
-
t.plan(6);
|
|
69
|
-
let query = '{ docSets { id documents { id mainSequence { id tags } } } }';
|
|
70
|
-
let result = await pk.gqlQuery(query);
|
|
71
|
-
t.equal(result.errors, undefined);
|
|
72
|
-
const docSet = result.data.docSets[0];
|
|
73
|
-
const document = docSet.documents[0];
|
|
74
|
-
const sequence = document.mainSequence;
|
|
75
|
-
t.equal(sequence.tags.length, 0);
|
|
76
|
-
query = `mutation { addSequenceTags(docSetId: "${docSet.id}", documentId: "${document.id}", sequenceId: "${sequence.id}", tags: ["foo", "baa"]) }`;
|
|
77
|
-
result = await pk.gqlQuery(query);
|
|
78
|
-
t.equal(result.data.addSequenceTags.length, 2);
|
|
79
|
-
query = `mutation { addSequenceTags(docSetId: "${docSet.id}", documentId: "${document.id}", sequenceId: "${sequence.id}", tags: ["foo", "frob"]) }`;
|
|
80
|
-
result = await pk.gqlQuery(query);
|
|
81
|
-
t.equal(result.data.addSequenceTags.length, 3);
|
|
82
|
-
query = `mutation { removeSequenceTags(docSetId: "${docSet.id}", documentId: "${document.id}", sequenceId: "${sequence.id}", tags: ["baa", "frob"]) }`;
|
|
83
|
-
result = await pk.gqlQuery(query);
|
|
84
|
-
t.equal(result.data.removeSequenceTags.length, 1);
|
|
85
|
-
t.ok(result.data.removeSequenceTags.includes('foo'));
|
|
86
|
-
} catch (err) {
|
|
87
|
-
console.log(err);
|
|
88
|
-
}
|
|
89
|
-
},
|
|
90
|
-
);
|