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.
Files changed (167) hide show
  1. package/esm/wrapper.mjs +1 -1
  2. package/{index.js → index.cjs} +1 -1
  3. package/package.json +2 -2
  4. package/babel.config.js +0 -18
  5. package/test/code/main/bad.cjs +0 -79
  6. package/test/code/main/basics.cjs +0 -534
  7. package/test/code/main/block.cjs +0 -586
  8. package/test/code/main/block_scope_numbers.cjs +0 -31
  9. package/test/code/main/blocks_with_atts.cjs +0 -150
  10. package/test/code/main/blocks_with_cv.cjs +0 -250
  11. package/test/code/main/break.cjs +0 -73
  12. package/test/code/main/checksum.cjs +0 -36
  13. package/test/code/main/cl_global.cjs +0 -35
  14. package/test/code/main/class_for_fragment.cjs +0 -18
  15. package/test/code/main/clean_usfm.cjs +0 -46
  16. package/test/code/main/cp_vp.cjs +0 -158
  17. package/test/code/main/custom.cjs +0 -124
  18. package/test/code/main/cv.cjs +0 -249
  19. package/test/code/main/cvMatching.cjs +0 -155
  20. package/test/code/main/cv_indexes.cjs +0 -189
  21. package/test/code/main/cv_navigation.cjs +0 -124
  22. package/test/code/main/document.cjs +0 -382
  23. package/test/code/main/empty_blocks.cjs +0 -71
  24. package/test/code/main/entries.cjs +0 -402
  25. package/test/code/main/export_lexing_regexes.cjs +0 -19
  26. package/test/code/main/fig.cjs +0 -67
  27. package/test/code/main/filter.cjs +0 -222
  28. package/test/code/main/glossary.cjs +0 -36
  29. package/test/code/main/graft_headings.cjs +0 -36
  30. package/test/code/main/graft_introduction.cjs +0 -96
  31. package/test/code/main/graft_note.cjs +0 -104
  32. package/test/code/main/graft_rems.cjs +0 -34
  33. package/test/code/main/graft_sidebars.cjs +0 -62
  34. package/test/code/main/graft_title.cjs +0 -36
  35. package/test/code/main/hello.cjs +0 -105
  36. package/test/code/main/import_document.cjs +0 -22
  37. package/test/code/main/import_usfm_int.cjs +0 -48
  38. package/test/code/main/item_groups.cjs +0 -133
  39. package/test/code/main/items_with_cv.cjs +0 -311
  40. package/test/code/main/milestone_attributes.cjs +0 -163
  41. package/test/code/main/mixed_sequence_documents.cjs +0 -137
  42. package/test/code/main/mixed_sequences.cjs +0 -217
  43. package/test/code/main/modify_sequence.cjs +0 -29
  44. package/test/code/main/multiple_chapters.cjs +0 -58
  45. package/test/code/main/multiple_content.cjs +0 -105
  46. package/test/code/main/mutate_add.cjs +0 -180
  47. package/test/code/main/mutate_delete.cjs +0 -236
  48. package/test/code/main/mutate_rehash.cjs +0 -68
  49. package/test/code/main/mutate_tags.cjs +0 -90
  50. package/test/code/main/mutate_update.cjs +0 -538
  51. package/test/code/main/selectors.cjs +0 -289
  52. package/test/code/main/sequence.cjs +0 -361
  53. package/test/code/main/serialize.cjs +0 -104
  54. package/test/code/main/spans.cjs +0 -51
  55. package/test/code/main/split_long_tokens.cjs +0 -30
  56. package/test/code/main/standard_vrs.cjs +0 -76
  57. package/test/code/main/subclass.cjs +0 -25
  58. package/test/code/main/table.cjs +0 -119
  59. package/test/code/main/tags.cjs +0 -248
  60. package/test/code/main/token_alignment.cjs +0 -84
  61. package/test/code/main/trees.cjs +0 -211
  62. package/test/code/main/tribos.cjs +0 -865
  63. package/test/code/main/tsv.cjs +0 -385
  64. package/test/code/main/usx_ref.cjs +0 -65
  65. package/test/code/main/verse_mapping.cjs +0 -252
  66. package/test/code/main/verse_range.cjs +0 -31
  67. package/test/code/main/word_likes.cjs +0 -41
  68. package/test/code/utils/byte_array.cjs +0 -271
  69. package/test/code/utils/canons.cjs +0 -20
  70. package/test/code/utils/generate_id.cjs +0 -17
  71. package/test/code/utils/graft_defs.cjs +0 -16
  72. package/test/code/utils/inspect.cjs +0 -130
  73. package/test/code/utils/items.cjs +0 -56
  74. package/test/code/utils/push_succinct.cjs +0 -69
  75. package/test/code/utils/scope_defs.cjs +0 -79
  76. package/test/code/utils/serialize.cjs +0 -28
  77. package/test/code/utils/splice.cjs +0 -67
  78. package/test/code/utils/tags.cjs +0 -69
  79. package/test/code/utils/versification.cjs +0 -249
  80. package/test/lib/load.js +0 -110
  81. package/test/skipped_code/diff.js +0 -53
  82. package/test/test_data/inputBlockSpec/dodson.json +0 -1654
  83. package/test/test_data/inputBlockSpec/kv.json +0 -326
  84. package/test/test_data/inputBlockSpec/mk1.json +0 -1019
  85. package/test/test_data/inputBlockSpec/table.json +0 -170
  86. package/test/test_data/tree/genealogy.json +0 -55
  87. package/test/test_data/tree/jude.json +0 -15965
  88. package/test/test_data/tsv/en_tn_66-JUD.tsv +0 -75
  89. package/test/test_data/tsv/twl_JUD.tsv +0 -144
  90. package/test/test_data/usfm/1pe_webbe.usfm +0 -13
  91. package/test/test_data/usfm/66-JUD-ust.usfm +0 -1089
  92. package/test/test_data/usfm/78-GALspavbl.usfm +0 -10
  93. package/test/test_data/usfm/add_test.usfm +0 -15
  94. package/test/test_data/usfm/backslash.usfm +0 -4
  95. package/test/test_data/usfm/cl.usfm +0 -14
  96. package/test/test_data/usfm/cp_vp.usfm +0 -8
  97. package/test/test_data/usfm/custom.usfm +0 -13
  98. package/test/test_data/usfm/en_ust_oba.usfm +0 -875
  99. package/test/test_data/usfm/en_ust_psa_1.usfm +0 -20
  100. package/test/test_data/usfm/fig.usfm +0 -3
  101. package/test/test_data/usfm/filter.usfm +0 -7
  102. package/test/test_data/usfm/footnote.usfm +0 -11
  103. package/test/test_data/usfm/frt.usfm +0 -4
  104. package/test/test_data/usfm/headings.usfm +0 -7
  105. package/test/test_data/usfm/hello.usfm +0 -8
  106. package/test/test_data/usfm/int.usfm +0 -7
  107. package/test/test_data/usfm/milestone_attributes.usfm +0 -7
  108. package/test/test_data/usfm/milestone_attributes_default.usfm +0 -7
  109. package/test/test_data/usfm/no_break_space.usfm +0 -4
  110. package/test/test_data/usfm/no_mt.usfm +0 -6
  111. package/test/test_data/usfm/rems.usfm +0 -6
  112. package/test/test_data/usfm/section_intros.usfm +0 -26
  113. package/test/test_data/usfm/sidebars.usfm +0 -25
  114. package/test/test_data/usfm/slash_in_att.usfm +0 -6
  115. package/test/test_data/usfm/soft_line_break.usfm +0 -4
  116. package/test/test_data/usfm/spans.usfm +0 -5
  117. package/test/test_data/usfm/split_long_tokens.usfm +0 -6
  118. package/test/test_data/usfm/table.usfm +0 -18
  119. package/test/test_data/usfm/table_at_end.usfm +0 -11
  120. package/test/test_data/usfm/table_in_intro.usfm +0 -22
  121. package/test/test_data/usfm/table_no_end_cells.usfm +0 -18
  122. package/test/test_data/usfm/tit_kitchen_sink.usfm +0 -73
  123. package/test/test_data/usfm/titus_template.usfm +0 -58
  124. package/test/test_data/usfm/ugnt_3jn.usfm +0 -265
  125. package/test/test_data/usfm/ult_3jn.usfm +0 -335
  126. package/test/test_data/usfm/unknown.usfm +0 -5
  127. package/test/test_data/usfm/ust_psa.usfm +0 -29
  128. package/test/test_data/usfm/ust_psa_verse_ranges.usfm +0 -24
  129. package/test/test_data/usfm/ust_psa_with_ts.usfm +0 -29
  130. package/test/test_data/usfm/verse_breaks_in_blocks.usfm +0 -20
  131. package/test/test_data/usfm/verse_range.usfm +0 -7
  132. package/test/test_data/usfm/web_ecc.usfm +0 -391
  133. package/test/test_data/usfm/web_psa51.usfm +0 -71
  134. package/test/test_data/usfm/whitespace.usfm +0 -12
  135. package/test/test_data/usfm/xref.usfm +0 -11
  136. package/test/test_data/usx/bad_element.usx +0 -2
  137. package/test/test_data/usx/cp_vp.usx +0 -12
  138. package/test/test_data/usx/diff1.usx +0 -59
  139. package/test/test_data/usx/diff2.usx +0 -74
  140. package/test/test_data/usx/douay_rheims_ecc.usx +0 -58
  141. package/test/test_data/usx/douay_rheims_psa.usx +0 -5366
  142. package/test/test_data/usx/douay_rheims_psa_40_60.usx +0 -666
  143. package/test/test_data/usx/douay_rheims_rut.usx +0 -26
  144. package/test/test_data/usx/esg3.usx +0 -47
  145. package/test/test_data/usx/fig.usx +0 -6
  146. package/test/test_data/usx/milestone_attributes.usx +0 -11
  147. package/test/test_data/usx/not_nfc18_glo.usx +0 -9
  148. package/test/test_data/usx/not_nfc18_phm.usx +0 -24
  149. package/test/test_data/usx/opt_break.usx +0 -10
  150. package/test/test_data/usx/sidebars.usx +0 -29
  151. package/test/test_data/usx/table.usx +0 -23
  152. package/test/test_data/usx/web_psa.usx +0 -8489
  153. package/test/test_data/usx/web_psa150.usx +0 -33
  154. package/test/test_data/usx/web_psa_40_60.usx +0 -1079
  155. package/test/test_data/usx/web_rut.usx +0 -95
  156. package/test/test_data/usx/web_rut_1.usx +0 -17
  157. package/test/test_data/utils/douay_rheims.vrs +0 -520
  158. package/test/test_data/utils/douay_rheims_PSA.usx +0 -5366
  159. package/test/test_data/utils/serialize_example.json +0 -91
  160. package/test/test_data/utils/truncated_versification.vrs +0 -29
  161. package/test/test_data/utils/web_rut_items.json +0 -2977
  162. package/test/test_data/utils/webbe.vrs +0 -395
  163. package/test/test_data/utils/webbe_PSA.usx +0 -8489
  164. package/test/test_data/vrs/douay_rheims.vrs +0 -520
  165. package/test/test_data/vrs/truncated_versification.vrs +0 -27
  166. package/test/test_data/vrs/webbe.vrs +0 -397
  167. package/webpack.prod.js +0 -50
@@ -1,84 +0,0 @@
1
- const test = require('tape');
2
-
3
- const { pkWithDoc } = require('../../lib/load.js');
4
-
5
- const testGroup = 'Tokens withChars';
6
-
7
- const pk = pkWithDoc('../test_data/usfm/ugnt_3jn.usfm', {
8
- lang: 'grc',
9
- abbr: 'hello',
10
- })[0];
11
- const pk2 = pkWithDoc('../test_data/usfm/ult_3jn.usfm', {
12
- lang: 'eng',
13
- abbr: 'hello',
14
- })[0];
15
-
16
- test(
17
- `Find lemmas by word (${testGroup})`,
18
- async function (t) {
19
- try {
20
- t.plan(4);
21
- const query =
22
- '{' +
23
- ' documents(withBook:"3JN") {' +
24
- ' mainSequence {' +
25
- ' blocks (withScriptureCV: "1:3") {' +
26
- ' tokens(' +
27
- ' includeContext:true' +
28
- ' withScriptureCV: "1:3"' +
29
- ' withChars: ["ἐρχομένων", "ἀδελφῶν"]' +
30
- ' ) {' +
31
- ' payload position' +
32
- ' scopes(startsWith:["attribute/spanWithAtts/w/lemma", "attribute/spanWithAtts/w/strong"])' +
33
- ' }' +
34
- ' }' +
35
- ' }' +
36
- ' }' +
37
- '}';
38
- const result = await pk.gqlQuery(query);
39
- t.equal(result.errors, undefined);
40
- const foundLemma = result.data.documents[0].mainSequence.blocks[0].tokens
41
- .map(t => t.scopes.filter(s => s.startsWith('attribute/spanWithAtts/w/lemma/0'))[0].split('/')[5]);
42
- t.equal(foundLemma.length, 2);
43
-
44
- for (const lemma of ['ἔρχομαι', 'ἀδελφός']) {
45
- t.ok(foundLemma.includes(lemma));
46
- }
47
- } catch (err) {
48
- console.log(err);
49
- }
50
- },
51
- );
52
-
53
- test(
54
- `Find words by lemma (${testGroup})`,
55
- async function (t) {
56
- try {
57
- t.plan(1);
58
- const query =
59
- '{' +
60
- ' documents(withBook:"3JN") {' +
61
- ' mainSequence {' +
62
- ' blocks (withScriptureCV: "1:3") {' +
63
- ' tokens(' +
64
- ' includeContext:true' +
65
- ' withScopes:[' +
66
- ' "attribute/milestone/zaln/x-lemma/0/ἔρχομαι"' +
67
- ' "attribute/milestone/zaln/x-lemma/0/ἀδελφός"' +
68
- ' ]' +
69
- ' anyScope:true' +
70
- ' ) {' +
71
- ' subType payload position scopes' +
72
- ' }' +
73
- ' }' +
74
- ' }' +
75
- ' }' +
76
- '}';
77
- const result = await pk2.gqlQuery(query);
78
- t.equal(result.errors, undefined);
79
- // console.log(JSON.stringify(simplifyBlocks(result.data.documents[0].mainSequence.blocks), null, 2));
80
- } catch (err) {
81
- console.log(err);
82
- }
83
- },
84
- );
@@ -1,211 +0,0 @@
1
- const path = require('path');
2
- const fse = require('fs-extra');
3
- const test = require('tape');
4
-
5
- const { Validator } = require('proskomma-json-tools');
6
- const { pkWithDoc } = require('../../lib/load.js');
7
- const { Proskomma } = require('../../../src/index.cjs');
8
- const {
9
- blocksSpec2Query,
10
- treeToInputBlock,
11
- } = require('../../../src/util/scriptlike/blocksSpec.cjs');
12
-
13
- const [pk, pkDoc] = pkWithDoc('../test_data/usfm/66-JUD-ust.usfm', {
14
- lang: 'eng',
15
- abbr: 'ust',
16
- });
17
-
18
- const importNodes = pk => {
19
- pk.importDocument({
20
- lang: 'deu',
21
- abbr: 'xyz',
22
- }, 'nodes',
23
- fse.readFileSync(path.resolve(__dirname, '../../test_data/tree/genealogy.json')),
24
- {},
25
- );
26
- };
27
-
28
- const testGroup = 'Trees';
29
-
30
- test(
31
- `Return error for treeSequence on non-tree sequence (${testGroup})`,
32
- async function (t) {
33
- try {
34
- t.plan(3);
35
- let query = '{documents { id mainSequence { id } } }';
36
- let result = await pk.gqlQuery(query);
37
- t.equal(result.errors, undefined);
38
- const docId = result.data.documents[0].id;
39
- const seqId = result.data.documents[0].mainSequence.id;
40
- query = `{document(id:"${docId}") { treeSequence(id:"${seqId}") { id } } }`;
41
- result = await pk.gqlQuery(query);
42
- t.equal(result.errors.length, 1);
43
- t.ok(result.errors[0].message.includes('type \'tree\', not \'main\''));
44
- } catch (err) {
45
- console.log(err);
46
- }
47
- },
48
- );
49
-
50
- test(
51
- `Import (${testGroup})`,
52
- async function (t) {
53
- try {
54
- t.plan(8);
55
- const pk = new Proskomma();
56
- importNodes(pk);
57
- let query = '{documents { mainSequence { id } sequences { id type tags blocks { bs { payload} bg { payload } is { payload } items { type subType payload } } } } }';
58
- let result = await pk.gqlQuery(query);
59
- t.equal(result.errors, undefined);
60
- const doc = result.data.documents[0];
61
- const mainSequence = doc.sequences.filter(s => s.id === doc.mainSequence.id)[0];
62
- const treeGraft = mainSequence.blocks[0].bg[0].payload;
63
- const treeSequence = doc.sequences.filter(s => s.id === treeGraft)[0];
64
- t.equal(treeSequence.type, 'tree');
65
- t.equal(treeSequence.blocks.length, 7);
66
- t.equal(treeSequence.blocks[0].bs.payload, 'tTreeNode/0');
67
- const nodeChildren = treeSequence.blocks[0].is.filter(s => s.payload.startsWith('tTreeChild')).map(s => s.payload);
68
- t.equal(nodeChildren.length, 2);
69
- const nodeParent = treeSequence.blocks[0].is.filter(s => s.payload.startsWith('tTreeParent')).map(s => s.payload);
70
- t.equal(nodeParent.length, 1);
71
- t.equal(nodeParent[0], 'tTreeParent/none');
72
- const nodeName = treeSequence.blocks[0].is.filter(s => s.payload.startsWith('tTreeContent/name')).map(s => s.payload);
73
- t.equal(nodeName.length, 1);
74
- } catch (err) {
75
- console.log(err);
76
- }
77
- },
78
- );
79
-
80
- test(
81
- `treeSequence (${testGroup})`,
82
- async function (t) {
83
- try {
84
- t.plan(12);
85
- const pk = new Proskomma();
86
- importNodes(pk);
87
- let query = '{docSets { document(bookCode:"N00") { sequences(types:"tree") { id } } } }';
88
- let result = await pk.gqlQuery(query);
89
- t.equal(result.errors, undefined);
90
- const treeSequenceId = result.data.docSets[0].document.sequences[0].id;
91
-
92
- query = `{
93
- docSets {
94
- document(bookCode:"N00") {
95
- treeSequence(id:"${treeSequenceId}") {
96
- id
97
- nNodes
98
- nodes {
99
- id
100
- parentId
101
- childIds
102
- keys
103
- itemGroups {
104
- scopeLabels(startsWith:"tTreeContent")
105
- text
106
- }
107
- }
108
- }
109
- }
110
- }
111
- }`;
112
- result = await pk.gqlQuery(query);
113
- t.equal(result.errors, undefined);
114
- const treeSequence = result.data.docSets[0].document.treeSequence;
115
- t.equal(treeSequence.nNodes, 7);
116
- t.equal(treeSequence.nodes[0].parentId, null);
117
- t.equal(treeSequence.nodes[1].parentId, treeSequence.nodes[0].id);
118
- t.equal(treeSequence.nodes[0].childIds.length, 2);
119
- t.equal(treeSequence.nodes[0].childIds[0], '1');
120
- t.equal(treeSequence.nodes[0].childIds[1], '4');
121
- t.equal(treeSequence.nodes[0].keys.length, 3);
122
- t.equal(treeSequence.nodes[0].itemGroups.length, 3);
123
- t.equal(treeSequence.nodes[0].itemGroups[0].text, 'me');
124
- t.equal(treeSequence.nodes[0].itemGroups[0].scopeLabels[0].split('/')[1], 'label');
125
- } catch (err) {
126
- console.log(err);
127
- }
128
- },
129
- );
130
-
131
- test(
132
- `Import and query tree JSON as sequence (${testGroup})`,
133
- async function (t) {
134
- try {
135
- t.plan(7);
136
-
137
- const blockQuery = blocksSpec2Query(
138
- treeToInputBlock(
139
- fse.readJSONSync(path.resolve(__dirname, '../../test_data/tree/jude.json')),
140
- ),
141
- );
142
-
143
- // console.log(blockQuery);
144
-
145
- let query = `mutation { newSequence(` +
146
- ` documentId: "${pkDoc.id}"` +
147
- ` type: "tree"` +
148
- ` blocksSpec: ${blockQuery}` +
149
- ` graftToMain: true) }`;
150
-
151
- let result = await pk.gqlQuery(query);
152
- t.equal(result.errors, undefined);
153
-
154
- query = `{
155
- docSets {
156
- documents {
157
- treeSequences {
158
- id
159
- nNodes
160
- nodes {
161
- id
162
- parentId
163
- childIds
164
- keys
165
- itemGroups {
166
- scopeLabels(startsWith:"tTreeContent")
167
- text
168
- }
169
- }
170
-
171
- }
172
- }
173
- }}`;
174
- result = await pk.gqlQuery(query);
175
- t.equal(result.errors, undefined);
176
- const node = result.data.docSets[0].documents[0].treeSequences[0].nodes[13];
177
- t.equal(node.id, '13');
178
- t.equal(node.parentId, '12');
179
- t.equal(node.childIds.length, 1);
180
- t.equal(node.childIds[0], '14');
181
- t.equal(node.itemGroups.filter(ig => ig.scopeLabels[0] === 'tTreeContent/English')[0].text, 'of Jesus');
182
- } catch (err) {
183
- console.log(err);
184
- }
185
- },
186
- );
187
-
188
- test(
189
- `Serialize (${testGroup})`,
190
- async function (t) {
191
- try {
192
- t.plan(3);
193
- const pk = new Proskomma();
194
- importNodes(pk);
195
- const query = '{ docSets { id } }';
196
- const result = await pk.gqlQuery(query);
197
- const docSetId = result.data.docSets[0].id;
198
- const serialized = pk.serializeSuccinct(docSetId);
199
- t.ok(serialized);
200
- const validationReport = new Validator().validate('proskomma',
201
- 'succinct',
202
- '0.2.0',
203
- serialized
204
- );
205
- t.ok(validationReport.isValid);
206
- t.equal(validationReport.errors, null);
207
- } catch (err) {
208
- console.log(err);
209
- }
210
- },
211
- );