proskomma-core 0.9.18 → 0.9.19

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 (126) hide show
  1. package/dist/bundle.js +1 -0
  2. package/dist/index.cjs +1 -0
  3. package/dist/module.mjs +15888 -0
  4. package/package.json +23 -34
  5. package/dist/index.js +0 -8
  6. package/dist/index.js.LICENSE.txt +0 -23
  7. package/esm/package.json +0 -3
  8. package/esm/wrapper.mjs +0 -7
  9. package/informations/meeting_01_march_2023.md +0 -38
  10. package/src/graph/index.cjs +0 -201
  11. package/src/graph/lib/do_cv.cjs +0 -249
  12. package/src/graph/lib/dump.cjs +0 -40
  13. package/src/graph/lib/remake_blocks.cjs +0 -57
  14. package/src/graph/lib/sequence_chars.cjs +0 -84
  15. package/src/graph/lib/sort.cjs +0 -39
  16. package/src/graph/lib/tribos.cjs +0 -97
  17. package/src/graph/lib/tribos_expression.cjs +0 -556
  18. package/src/graph/lib/tribos_ohm_UNUSED.cjs +0 -37
  19. package/src/graph/lib/tribos_step.cjs +0 -434
  20. package/src/graph/mutations/add.cjs +0 -91
  21. package/src/graph/mutations/delete.cjs +0 -61
  22. package/src/graph/mutations/index.cjs +0 -54
  23. package/src/graph/mutations/rehash.cjs +0 -17
  24. package/src/graph/mutations/tags.cjs +0 -120
  25. package/src/graph/mutations/update.cjs +0 -210
  26. package/src/graph/mutations/versification.cjs +0 -96
  27. package/src/graph/queries/block.cjs +0 -228
  28. package/src/graph/queries/cIndex.cjs +0 -87
  29. package/src/graph/queries/cell.cjs +0 -42
  30. package/src/graph/queries/cv.cjs +0 -19
  31. package/src/graph/queries/cvBook.cjs +0 -16
  32. package/src/graph/queries/cvChapter.cjs +0 -16
  33. package/src/graph/queries/cvIndex.cjs +0 -47
  34. package/src/graph/queries/cvNavigation.cjs +0 -116
  35. package/src/graph/queries/cvVerseElement.cjs +0 -84
  36. package/src/graph/queries/cvVerses.cjs +0 -14
  37. package/src/graph/queries/doc_set.cjs +0 -220
  38. package/src/graph/queries/document.cjs +0 -555
  39. package/src/graph/queries/idParts.cjs +0 -30
  40. package/src/graph/queries/index.cjs +0 -151
  41. package/src/graph/queries/inputBlockSpec.cjs +0 -17
  42. package/src/graph/queries/inputItemObject.cjs +0 -12
  43. package/src/graph/queries/input_att_spec.cjs +0 -14
  44. package/src/graph/queries/input_key_matches.cjs +0 -11
  45. package/src/graph/queries/input_key_value.cjs +0 -11
  46. package/src/graph/queries/input_key_values.cjs +0 -11
  47. package/src/graph/queries/input_selector_spec.cjs +0 -19
  48. package/src/graph/queries/item.cjs +0 -71
  49. package/src/graph/queries/itemGroup.cjs +0 -75
  50. package/src/graph/queries/key_value.cjs +0 -18
  51. package/src/graph/queries/kv_entry.cjs +0 -21
  52. package/src/graph/queries/kv_sequence.cjs +0 -151
  53. package/src/graph/queries/node.cjs +0 -44
  54. package/src/graph/queries/orig.cjs +0 -11
  55. package/src/graph/queries/regex_index.cjs +0 -18
  56. package/src/graph/queries/row_equals_spec.cjs +0 -11
  57. package/src/graph/queries/row_match_spec.cjs +0 -11
  58. package/src/graph/queries/selector_spec.cjs +0 -29
  59. package/src/graph/queries/sequence.cjs +0 -314
  60. package/src/graph/queries/table_sequence.cjs +0 -192
  61. package/src/graph/queries/tree_sequence.cjs +0 -58
  62. package/src/graph/queries/verseNumber.cjs +0 -44
  63. package/src/graph/queries/verseRange.cjs +0 -11
  64. package/src/graph/queries/versification.cjs +0 -25
  65. package/src/index.cjs +0 -583
  66. package/src/model/doc_set.cjs +0 -389
  67. package/src/model/doc_set_helpers/block.cjs +0 -232
  68. package/src/model/doc_set_helpers/enum.cjs +0 -87
  69. package/src/model/doc_set_helpers/item.cjs +0 -198
  70. package/src/model/doc_set_helpers/rehash.cjs +0 -53
  71. package/src/model/doc_set_helpers/selectors.cjs +0 -58
  72. package/src/model/doc_set_helpers/serialize.cjs +0 -22
  73. package/src/model/doc_set_helpers/unsuccinctify.cjs +0 -288
  74. package/src/model/doc_set_helpers/update.cjs +0 -290
  75. package/src/model/document.cjs +0 -369
  76. package/src/model/document_helpers/blocks.cjs +0 -135
  77. package/src/model/document_helpers/chapter_verse.cjs +0 -291
  78. package/src/model/document_helpers/pre_enums.cjs +0 -67
  79. package/src/model/document_helpers/sequences.cjs +0 -205
  80. package/src/model/document_helpers/serialize_succinct.cjs +0 -55
  81. package/src/model/document_helpers/succinct_filter.cjs +0 -102
  82. package/src/model/versifications/eng_vrs.cjs +0 -455
  83. package/src/model/versifications/index.cjs +0 -38
  84. package/src/model/versifications/lxx_vrs.cjs +0 -950
  85. package/src/model/versifications/org_vrs.cjs +0 -155
  86. package/src/model/versifications/rsc_vrs.cjs +0 -342
  87. package/src/model/versifications/rso_vrs.cjs +0 -541
  88. package/src/model/versifications/vul_vrs.cjs +0 -835
  89. package/src/parser/index.cjs +0 -504
  90. package/src/parser/lexers/index.cjs +0 -11
  91. package/src/parser/lexers/lexingRegexes.cjs +0 -45
  92. package/src/parser/lexers/nodes.cjs +0 -123
  93. package/src/parser/lexers/object_for_fragment.cjs +0 -123
  94. package/src/parser/lexers/tsv.cjs +0 -45
  95. package/src/parser/lexers/usfm.cjs +0 -17
  96. package/src/parser/lexers/usx/index.cjs +0 -7
  97. package/src/parser/lexers/usx/usx_lexer.cjs +0 -321
  98. package/src/parser/lib/tokenize.cjs +0 -37
  99. package/src/parser/model/index.cjs +0 -637
  100. package/src/parser/parser_specs.cjs +0 -781
  101. package/src/pipelines/perf2x/index.cjs +0 -7
  102. package/src/pipelines/perf2x/perf2PkJsonPipeline.json +0 -41
  103. package/src/pipelines/perf2x/perf2usfmPipeline.json +0 -65
  104. package/src/transforms/calculateUsfmChapterPositions.cjs +0 -106
  105. package/src/transforms/index.cjs +0 -9
  106. package/src/transforms/perf2PkJson.cjs +0 -534
  107. package/src/transforms/perf2usfm.cjs +0 -294
  108. package/src/util/byteArray.cjs +0 -251
  109. package/src/util/canons.cjs +0 -117
  110. package/src/util/enums.cjs +0 -41
  111. package/src/util/generateId.cjs +0 -6
  112. package/src/util/graftDefs.cjs +0 -15
  113. package/src/util/index.cjs +0 -29
  114. package/src/util/inspectSuccinct.cjs +0 -59
  115. package/src/util/itemDefs.cjs +0 -33
  116. package/src/util/parserConstantDefs.cjs +0 -30
  117. package/src/util/scopeDefs.cjs +0 -173
  118. package/src/util/scriptlike/blocksSpec.cjs +0 -192
  119. package/src/util/scriptlike/dodson_lexicon.xsl +0 -19
  120. package/src/util/scriptlike/dodson_lexicon_to_entries.cjs +0 -85
  121. package/src/util/scriptlike/open_scriptures_hebrew_lexicon.xsl +0 -28
  122. package/src/util/scriptlike/open_scriptures_hebrew_lexicon_to_entries.cjs +0 -85
  123. package/src/util/succinct.cjs +0 -159
  124. package/src/util/tags.cjs +0 -28
  125. package/src/util/tokenDefs.cjs +0 -27
  126. package/src/util/versification.cjs +0 -364
@@ -1,120 +0,0 @@
1
- const utils = require('../../util/index.cjs');
2
-
3
- const tagMutationsSchemaString = `
4
- """Add one or more tags to a docSet, if they are not already present"""
5
- addDocSetTags(
6
- """The id of the docSet to which the tags will be added"""
7
- docSetId: String!
8
- """A list of tags to be added"""
9
- tags: [String]!
10
- ): [String!]!
11
- """Add one or more tags to a document, if they are not already present"""
12
- addDocumentTags(
13
- """The id of the docSet containing the document to which the tags will be added"""
14
- docSetId: String!
15
- """The id of the document to which the tags will be added"""
16
- documentId: String!
17
- """A list of tags to be added"""
18
- tags: [String]!
19
- ): [String!]
20
- """Add one or more tags to a sequence, if they are not already present"""
21
- addSequenceTags(
22
- """The id of the docSet containing the document containing the sequence to which the tags will be added"""
23
- docSetId: String!
24
- """The id of the document containing the sequence to which the tags will be added"""
25
- documentId: String!
26
- """The id of the sequence to which the tags will be added"""
27
- sequenceId: String!
28
- """A list of tags to be added"""
29
- tags: [String]!
30
- ) : [String!]
31
- """Remove one or more tags from a docSet, if they are present"""
32
- removeDocSetTags(
33
- """The id of the docSet from which the tags will be removed"""
34
- docSetId: String!
35
- """A list of tags to be removed"""
36
- tags: [String]!
37
- ): [String!]
38
- """Remove one or more tags from a document, if they are present"""
39
- removeDocumentTags(
40
- """The id of the docSet containing the document from which the tags will be removed"""
41
- docSetId: String!
42
- """The id of the document from which the tags will be removed"""
43
- documentId: String!
44
- """A list of tags to be removed"""
45
- tags: [String]!
46
- ): [String!]
47
- """Remove one or more tags from a sequence, if they are present"""
48
- removeSequenceTags(
49
- """The id of the docSet containing the document containing the sequence from which the tags will be removed"""
50
- docSetId: String!
51
- """The id of the document containing the sequence from which the tags will be removed"""
52
- documentId: String!
53
- """The id of the sequence from which the tags will be removed"""
54
- sequenceId: String!
55
- """A list of tags to be removed"""
56
- tags: [String]!
57
- ) : [String!]
58
- `;
59
-
60
- const tagMutationsResolvers = {
61
- addDocSetTags: (root, args) => {
62
- const docSet = root.docSets[args.docSetId];
63
-
64
- for (const tag of args.tags) {
65
- docSet.addTag(tag);
66
- }
67
- return Array.from(docSet.tags);
68
- },
69
- addDocumentTags: (root, args) => {
70
- const docSet = root.docSets[args.docSetId];
71
- const document = docSet.processor.documents[args.documentId];
72
-
73
- for (const tag of args.tags) {
74
- document.addTag(tag);
75
- }
76
- return Array.from(document.tags);
77
- },
78
- addSequenceTags: (root, args) => {
79
- const docSet = root.docSets[args.docSetId];
80
- const document = docSet.processor.documents[args.documentId];
81
- const sequence = document.sequences[args.sequenceId];
82
-
83
- for (const tag of args.tags) {
84
- utils.tags.addTag(sequence.tags, tag);
85
- }
86
- return Array.from(sequence.tags);
87
- },
88
- removeDocSetTags: (root, args) => {
89
- const docSet = root.docSets[args.docSetId];
90
-
91
- for (const tag of args.tags) {
92
- docSet.removeTag(tag);
93
- }
94
- return Array.from(docSet.tags);
95
- },
96
- removeDocumentTags: (root, args) => {
97
- const docSet = root.docSets[args.docSetId];
98
- const document = docSet.processor.documents[args.documentId];
99
-
100
- for (const tag of args.tags) {
101
- document.removeTag(tag);
102
- }
103
- return Array.from(document.tags);
104
- },
105
- removeSequenceTags: (root, args) => {
106
- const docSet = root.docSets[args.docSetId];
107
- const document = docSet.processor.documents[args.documentId];
108
- const sequence = document.sequences[args.sequenceId];
109
-
110
- for (const tag of args.tags) {
111
- utils.tags.removeTag(sequence.tags, tag);
112
- }
113
- return Array.from(sequence.tags);
114
- },
115
- };
116
-
117
- module.exports = {
118
- tagMutationsSchemaString,
119
- tagMutationsResolvers,
120
- };
@@ -1,210 +0,0 @@
1
- const { PipelineHandler } = require('proskomma-json-tools');
2
- const { remakeBlocks } = require('../lib/remake_blocks.cjs');
3
- const pipelines = require('../../pipelines/perf2x/index.cjs');
4
- const customTransforms = require('../../transforms/index.cjs');
5
-
6
- const updateMutationsSchemaString = `
7
- """Replaces the items of a block with a new set of items"""
8
- updateItems(
9
- """The id of the docSet containing the document containing the sequence containing the block for which the items will be updated"""
10
- docSetId: String!
11
- """The id of the document containing the sequence containing the block for which the items will be updated"""
12
- documentId: String!
13
- """The id of the sequence containing the block for which the items will be updated (defaults to the main sequence)"""
14
- sequenceId: String
15
- """The zero-indexed number of the block for which the items will be updated"""
16
- blockPosition: Int!
17
- """The new content for the block as item objects"""
18
- items: [InputItemObject!]
19
- """BlockGrafts for the block as item objects"""
20
- blockGrafts: [InputItemObject!]
21
- """Optional blockScope for the block as an item object"""
22
- blockScope: InputItemObject
23
- ): Boolean!
24
- """Replaces all the blocks of a sequence with a new set of blocks"""
25
- updateAllBlocks(
26
- """The id of the docSet containing the document containing the sequence for which the blocks will be updated"""
27
- docSetId: String!
28
- """The id of the document containing the sequence for which the blocks will be updated"""
29
- documentId: String!
30
- """The id of the sequence for which the blocks will be updated (defaults to the main sequence)"""
31
- sequenceId: String
32
- """The JSON describing blocks"""
33
- blocksSpec: [inputBlockSpec!]!
34
- ): Boolean!
35
- """Replaces all the blocks of a sequence with a new set of blocks derived from PERF"""
36
- updateSequenceFromPerf(
37
- """The id of the docSet containing the document containing the sequence for which the blocks will be updated"""
38
- docSetId: String!
39
- """The id of the document containing the sequence for which the blocks will be updated"""
40
- documentId: String!
41
- """The id of the sequence for which the blocks will be updated (defaults to the main sequence)"""
42
- sequenceId: String
43
- """The JSON describing blocks"""
44
- perf: String!
45
- ): Boolean!
46
- """Garbage collects unused sequences within a document. (You probably don\\'t need to do this.)"""
47
- gcSequences(
48
- """The id of the docSet containing the document to be garbage collected"""
49
- docSetId: String!
50
- """The id of the document to be garbage collected"""
51
- documentId: String!
52
- ) : Boolean!
53
-
54
- `;
55
- const updateMutationsResolvers = {
56
- updateItems: (root, args) => {
57
- const docSet = root.docSets[args.docSetId];
58
-
59
- if (!docSet) {
60
- throw new Error(`DocSet '${args.docSetId}' not found`);
61
- }
62
-
63
- if (!args.items) {
64
- throw new Error('Must provide items');
65
- }
66
-
67
- const itemsResult = docSet.updateItems(
68
- args.documentId,
69
- args.sequenceId,
70
- args.blockPosition,
71
- args.items,
72
- );
73
-
74
- if (!itemsResult) {
75
- return false;
76
- }
77
-
78
- if (args.blockGrafts) {
79
- const bgResult = docSet.updateBlockGrafts(
80
- args.documentId,
81
- args.sequenceId,
82
- args.blockPosition,
83
- args.blockGrafts,
84
- );
85
-
86
- if (!bgResult) {
87
- return false;
88
- }
89
- }
90
-
91
- if (args.blockScope) {
92
- const bsResult = docSet.updateBlockScope(
93
- args.documentId,
94
- args.sequenceId,
95
- args.blockPosition,
96
- args.blockScope,
97
- );
98
-
99
- if (!bsResult) {
100
- return false;
101
- }
102
- }
103
- return true;
104
- },
105
- updateAllBlocks: (root, args) => {
106
- const docSet = root.docSets[args.docSetId];
107
-
108
- if (!docSet) {
109
- throw new Error(`DocSet '${args.docSetId}' not found`);
110
- }
111
-
112
- const document = root.documents[args.documentId];
113
-
114
- if (!document) {
115
- throw new Error(`Document '${args.documentId}' not found`);
116
- }
117
-
118
- const sequence = document.sequences[args.sequenceId || document.mainId];
119
-
120
- if (!sequence) {
121
- throw new Error(`Sequence '${args.sequenceId || document.mainId}' not found`);
122
- }
123
- remakeBlocks(docSet, document, sequence, args.blocksSpec);
124
- document.buildChapterVerseIndex();
125
- return true;
126
- },
127
- updateSequenceFromPerf: async (root, args) => {
128
- const docSet = root.docSets[args.docSetId];
129
-
130
- if (!docSet) {
131
- throw new Error(`DocSet '${args.docSetId}' not found`);
132
- }
133
-
134
- const document = root.documents[args.documentId];
135
-
136
- if (!document) {
137
- throw new Error(`Document '${args.documentId}' not found`);
138
- }
139
-
140
- const sequence = document.sequences[args.sequenceId || document.mainId];
141
-
142
- if (!sequence) {
143
- throw new Error(`Sequence '${args.sequenceId || document.mainId}' not found`);
144
- }
145
-
146
- const sequencePerf = JSON.parse(args.perf);
147
- const perf = {
148
- 'schema': {
149
- 'structure': 'flat',
150
- 'structure_version': '0.3.0',
151
- 'constraints': [
152
- {
153
- 'name': 'perf',
154
- 'version': '0.3.0',
155
- },
156
- ],
157
- },
158
- 'metadata': {
159
- 'translation': {},
160
- 'document': {},
161
- },
162
- 'sequences': {},
163
- 'main_sequence_id': args.sequenceId,
164
- };
165
- perf.sequences[args.sequenceId] = sequencePerf;
166
-
167
- let blocksSpec = {};
168
-
169
- try {
170
- const pipelineHandler = new PipelineHandler({
171
- pipelines:pipelines,
172
- transforms:customTransforms,
173
- proskomma:root,
174
- });
175
- const output = await pipelineHandler.runPipeline('perf2PkJsonPipeline', { perf });
176
- blocksSpec = Object.values(output.pkJson)[0];
177
- } catch (err) {
178
- console.error('pipelineHandler Error :\n', err);
179
- return false;
180
- }
181
- remakeBlocks(docSet, document, sequence, blocksSpec);
182
- document.buildChapterVerseIndex();
183
- return true;
184
- },
185
- gcSequences: (root, args) => {
186
- const docSet = root.docSets[args.docSetId];
187
-
188
- if (!docSet) {
189
- throw new Error(`DocSet '${args.docSetId}' not found`);
190
- }
191
-
192
- const document = root.documents[args.documentId];
193
-
194
- if (!document) {
195
- throw new Error(`Document '${args.documentId}' not found`);
196
- }
197
-
198
- if (document.gcSequences()) {
199
- docSet.rehash();
200
- return true;
201
- } else {
202
- return false;
203
- }
204
- },
205
- };
206
-
207
- module.exports = {
208
- updateMutationsSchemaString,
209
- updateMutationsResolvers,
210
- };
@@ -1,96 +0,0 @@
1
- const utils = require('../../util/index.cjs');
2
-
3
- const versificationMutationsSchemaString = `
4
- """Adds verse mapping tables to the documents in a docSet, where the verse mapping may be provided in legacy .vrs or JSON format"""
5
- setVerseMapping(
6
- """the id of the docSet to which the verse mapping will be added"""
7
- docSetId: String!
8
- """The verse mapping, in legacy .vrs format (as a string)"""
9
- vrsSource: String
10
- """The verse mapping, in JSON format (as a string)"""
11
- jsonSource: String
12
- ): Boolean!
13
- """Removes verse mapping tables from the documents in a docSet"""
14
- unsetVerseMapping(
15
- """The id of the docSet from which verse mapping will be removed"""
16
- docSetId: String!
17
- ): Boolean!
18
- `;
19
- const versificationMutationsResolvers = {
20
- setVerseMapping: (root, args) => {
21
- if (args.vrsSource && args.jsonSource) {
22
- throw new Error('Cannot specify both vrsSource and jsonSource');
23
- } else if (!args.vrsSource && !args.jsonSource) {
24
- throw new Error('Must specify either vrsSource or jsonSource');
25
- }
26
-
27
- const docSet = root.docSets[args.docSetId];
28
-
29
- if (!docSet) {
30
- return false;
31
- }
32
-
33
- let jsonSource;
34
-
35
- if (args.vrsSource) {
36
- jsonSource = utils.versification.vrs2json(args.vrsSource);
37
- } else {
38
- jsonSource = args.jsonSource;
39
- }
40
-
41
- const forwardSuccinctTree = utils.versification.succinctifyVerseMappings(
42
- jsonSource.mappedVerses,
43
- );
44
-
45
- const reversedJsonSource = utils.versification.reverseVersification(jsonSource);
46
- const reversedSuccinctTree = utils.versification.succinctifyVerseMappings(
47
- reversedJsonSource.reverseMappedVerses,
48
- );
49
-
50
- for (const document of docSet.documents().filter(doc => 'bookCode' in doc.headers)) {
51
- const bookCode = document.headers['bookCode'];
52
- const bookDocument = docSet.documentWithBook(bookCode);
53
-
54
- if (!bookDocument) {
55
- continue;
56
- }
57
-
58
- const bookMainSequence = bookDocument.sequences[bookDocument.mainId];
59
- bookMainSequence.verseMapping = {};
60
-
61
- if (bookCode in forwardSuccinctTree) {
62
- bookMainSequence.verseMapping.forward = forwardSuccinctTree[bookCode];
63
- }
64
-
65
- if (bookCode in reversedSuccinctTree) {
66
- bookMainSequence.verseMapping.reversed = reversedSuccinctTree[bookCode];
67
- }
68
- }
69
- docSet.tags.add('hasMapping');
70
- return true;
71
- },
72
- unsetVerseMapping: (root, args) => {
73
- const docSet = root.docSets[args.docSetId];
74
-
75
- if (!docSet) {
76
- return false;
77
- }
78
-
79
- for (const document of docSet.documents().filter(doc => 'bookCode' in doc.headers)) {
80
- const bookCode = document.headers['bookCode'];
81
- const bookDocument = docSet.documentWithBook(bookCode);
82
-
83
- if (bookDocument) {
84
- const bookMainSequence = bookDocument.sequences[bookDocument.mainId];
85
- bookMainSequence.verseMapping = {};
86
- }
87
- }
88
- docSet.tags.delete('hasMapping');
89
- return true;
90
- },
91
- };
92
-
93
- module.exports = {
94
- versificationMutationsSchemaString,
95
- versificationMutationsResolvers,
96
- };
@@ -1,228 +0,0 @@
1
- const xre = require('xregexp');
2
- const utils = require('../../util/index.cjs');
3
- const { dumpBlock } = require('../lib/dump.cjs');
4
-
5
- const scopeMatchesStartsWith = (sw, s) => {
6
- if (sw.length === 0) {
7
- return true;
8
- }
9
-
10
- for (const swv of sw) {
11
- if (s.startsWith(swv)) {
12
- return true;
13
- }
14
- }
15
- return false;
16
- };
17
-
18
- const blockSchemaString = `
19
- """Part of a sequence, roughly equivalent to a USFM paragraph"""
20
- type Block {
21
- """The length in bytes of the succinct representation of c (block items)"""
22
- cBL: Int!
23
- """The length in bytes of the succinct representation of bg (block grafts)"""
24
- bgBL: Int!
25
- """The length in bytes of the succinct representation of os (open scopes)"""
26
- osBL: Int!
27
- """The length in bytes of the succinct representation of is (included scopes)"""
28
- isBL: Int!
29
- """The length in bytes of the succinct representation of nt (nextToken at the start of the block)"""
30
- ntBL: Int!
31
- """The number of items in the succinct representation of c (block items)"""
32
- cL: Int!
33
- """The number of items in the succinct representation of bg (block grafts)"""
34
- bgL: Int!
35
- """The number of items in the succinct representation of os (open scopes)"""
36
- osL: Int!
37
- """The number of items in the succinct representation of is (included scopes)"""
38
- isL: Int!
39
- """A list of included scopes for this block"""
40
- is: [Item!]!
41
- """A list of open scopes for this block"""
42
- os: [Item!]!
43
- """The block scope for this block"""
44
- bs: Item!
45
- """A list of block grafts for this block"""
46
- bg: [Item!]!
47
- """The value of nextToken at the start of this block"""
48
- nt: Int!
49
- """A list of items from the c (content) field of the block"""
50
- items(
51
- """Only return items that are within specific scopes"""
52
- withScopes: [String!]
53
- """If true, withScopes filtering matches items within at least one of the specified scopes"""
54
- anyScope: Boolean
55
- """Only return items that are within a chapterVerse range (ch or ch:v or ch:v-v or ch:v-ch:v)"""
56
- withScriptureCV: String
57
- """If true, adds scope and nextToken information to each token"""
58
- includeContext: Boolean
59
- ) : [Item!]!
60
- """A list of tokens from the c (content) field of the block"""
61
- tokens(
62
- """Only return tokens that are within specific scopes"""
63
- withScopes: [String!]
64
- """If true, withScopes filtering matches tokens within at least one of the specified scopes"""
65
- anyScope: Boolean
66
- """Only return tokens that are within a chapterVerse range (ch or ch:v or ch:v-v or ch:v-ch:v)"""
67
- withScriptureCV: String
68
- """If true, adds scope and nextToken information to each token"""
69
- includeContext: Boolean
70
- """Return tokens whose payload is an exact match to one of the specified strings"""
71
- withChars: [String!]
72
- """Return tokens whose payload matches one of the specified regexes"""
73
- withMatchingChars: [String!]
74
- """Return tokens with one of the specified subTypes"""
75
- withSubTypes: [String!]
76
- ) : [Item!]!
77
- """The text of the block as a single string"""
78
- text(
79
- """Only return text that is within a chapterVerse range (ch or ch:v or ch:v-v or ch:v-ch:v)"""
80
- withScriptureCV: String
81
- """If true, converts each whitespace character to a single space"""
82
- normalizeSpace: Boolean
83
- ): String!
84
- """'Block items grouped by scopes or milestones"""
85
- itemGroups(
86
- """Produce one itemGroup for every match of the list of scopes"""
87
- byScopes: [String!]
88
- """Start a new itemGroup whenever a milestone in the list is encountered"""
89
- byMilestones: [String!]
90
- ): [ItemGroup]!
91
- """The block content as a string in a compact eyeballable format"""
92
- dump: String!
93
- """A list of the labels for the block\\'s bs, os and is scopes"""
94
- scopeLabels(
95
- """Only include scopes that begin with this value"""
96
- startsWith: [String!]
97
- ): [String!]!
98
- }
99
- `;
100
-
101
- const blockResolvers = {
102
- cBL: root => root.c.length,
103
- bgBL: root => root.bg.length,
104
- osBL: root => root.os.length,
105
- isBL: root => root.is.length,
106
- ntBL: root => root.nt.length,
107
- cL: (root, args, context) => context.docSet.countItems(root.c),
108
- bgL: (root, args, context) => context.docSet.countItems(root.bg),
109
- osL: (root, args, context) => context.docSet.countItems(root.os),
110
- isL: (root, args, context) => context.docSet.countItems(root.is),
111
- is: (root, args, context) => context.docSet.unsuccinctifyScopes(root.is),
112
- os: (root, args, context) => context.docSet.unsuccinctifyScopes(root.os),
113
- bs: (root, args, context) => {
114
- // eslint-disable-next-line no-unused-vars
115
- const [itemLength, itemType, itemSubtype] = utils.succinct.headerBytes(root.bs, 0);
116
- return context.docSet.unsuccinctifyScope(root.bs, itemType, itemSubtype, 0);
117
- },
118
- bg: (root, args, context) => context.docSet.unsuccinctifyGrafts(root.bg),
119
- nt: root => root.nt.nByte(0),
120
- items:
121
- (root, args, context) => {
122
- if (args.withScopes && args.withScriptureCV) {
123
- throw new Error('Cannot specify both withScopes and withScriptureCV');
124
- }
125
-
126
- if (args.withScriptureCV) {
127
- return context.docSet.unsuccinctifyItemsWithScriptureCV(root, args.withScriptureCV, {}, args.includeContext || false);
128
- } else {
129
- return context.docSet.unsuccinctifyPrunedItems(
130
- root,
131
- {
132
- tokens: true,
133
- scopes: true,
134
- grafts: true,
135
- requiredScopes: args.withScopes || [],
136
- anyScope: args.anyScope || false,
137
- },
138
- );
139
- }
140
- },
141
- tokens:
142
- (root, args, context) => {
143
- if (Object.keys(args).filter(a => a.includes('Chars')).length > 1) {
144
- throw new Error('Only one of "withChars", "withAnyCaseChars" and "withCharsMatchingRegex" may be specified');
145
- }
146
-
147
- let ret;
148
-
149
- if (args.withScriptureCV) {
150
- ret = context.docSet.unsuccinctifyItemsWithScriptureCV(
151
- root,
152
- args.withScriptureCV,
153
- { tokens: true },
154
- args.includeContext || false,
155
- );
156
- } else {
157
- ret = context.docSet.unsuccinctifyPrunedItems(
158
- root,
159
- {
160
- tokens: true,
161
- scopes: true,
162
- requiredScopes: args.withScopes || [],
163
- anyScope: args.anyScope || false,
164
- },
165
- );
166
- }
167
-
168
- if (args.withSubTypes) {
169
- ret = ret.filter(i => args.withSubTypes.includes(i[1]));
170
- }
171
-
172
- if (args.withChars) {
173
- ret = ret.filter(i => args.withChars.includes(i[2]));
174
- } else if (args.withMatchingChars) {
175
- ret = ret.filter(i => {
176
- for (const re of args.withMatchingChars) {
177
- if (xre.test(i, xre(re))) {
178
- return true;
179
- }
180
- }
181
- return false;
182
- });
183
- }
184
-
185
- return ret.filter(i => i[0] === 'token');
186
- },
187
- text:
188
- (root, args, context) => {
189
- const tokens = args.withScriptureCV ?
190
- context.docSet.unsuccinctifyItemsWithScriptureCV(
191
- root,
192
- args.withScriptureCV,
193
- { tokens: true },
194
- false,
195
- ) :
196
- context.docSet.unsuccinctifyItems(root.c, { tokens: true }, null);
197
- let ret = tokens.map(t => t[2]).join('').trim();
198
-
199
- if (args.normalizeSpace) {
200
- ret = ret.replace(/[ \t\n\r]+/g, ' ');
201
- }
202
- return ret;
203
- },
204
- itemGroups: (root, args, context) => {
205
- if (args.byScopes && args.byMilestones) {
206
- throw new Error('Cannot specify both byScopes and byMilestones');
207
- }
208
-
209
- if (!args.byScopes && !args.byMilestones) {
210
- throw new Error('Must specify either byScopes or byMilestones');
211
- }
212
-
213
- if (args.byScopes) {
214
- return context.docSet.sequenceItemsByScopes([root], args.byScopes);
215
- } else {
216
- return context.docSet.sequenceItemsByMilestones([root], args.byMilestones);
217
- }
218
- },
219
- dump: (root, args, context) => dumpBlock(context.docSet.unsuccinctifyBlock(root, {}, null)),
220
- scopeLabels: (root, args, context) =>
221
- [...context.docSet.unsuccinctifyBlockScopeLabelsSet(root)]
222
- .filter(s => !args.startsWith || scopeMatchesStartsWith(args.startsWith, s)),
223
- };
224
-
225
- module.exports = {
226
- blockSchemaString,
227
- blockResolvers,
228
- };