@helloao/tools 0.0.5 → 0.0.6

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.
@@ -28,23 +28,23 @@ describe('generateApiForDataset()', () => {
28
28
  language: 'eng',
29
29
  direction: 'ltr',
30
30
  licenseUrl: 'https://berean.bible/terms.htm',
31
- website: 'https://berean.bible'
31
+ website: 'https://berean.bible',
32
32
  };
33
33
  let inputFiles = [
34
34
  {
35
35
  fileType: 'usfm',
36
36
  metadata: {
37
- translation: translation1
37
+ translation: translation1,
38
38
  },
39
- content: firstXLines(_01GENBSB_usfm_1.default, 13)
39
+ content: firstXLines(_01GENBSB_usfm_1.default, 13),
40
40
  },
41
41
  {
42
42
  fileType: 'usfm',
43
43
  metadata: {
44
- translation: translation1
44
+ translation: translation1,
45
45
  },
46
- content: firstXLines(_02EXOBSB_usfm_1.default, 14)
47
- }
46
+ content: firstXLines(_02EXOBSB_usfm_1.default, 14),
47
+ },
48
48
  ];
49
49
  const dataset = (0, dataset_1.generateDataset)(inputFiles, new linkedom_1.DOMParser());
50
50
  const generated = (0, api_1.generateApiForDataset)(dataset);
@@ -59,9 +59,7 @@ describe('generateApiForDataset()', () => {
59
59
  textDirection: 'ltr',
60
60
  licenseUrl: 'https://berean.bible/terms.htm',
61
61
  website: 'https://berean.bible',
62
- availableFormats: [
63
- 'json'
64
- ],
62
+ availableFormats: ['json'],
65
63
  listOfBooksApiLink: '/api/bsb/books.json',
66
64
  numberOfBooks: 2,
67
65
  totalNumberOfChapters: 2,
@@ -71,9 +69,7 @@ describe('generateApiForDataset()', () => {
71
69
  };
72
70
  expect(tree).toEqual({
73
71
  '/api/available_translations.json': {
74
- translations: [
75
- expectedTranslation
76
- ]
72
+ translations: [expectedTranslation],
77
73
  },
78
74
  '/api/bsb/books.json': {
79
75
  translation: expectedTranslation,
@@ -99,8 +95,8 @@ describe('generateApiForDataset()', () => {
99
95
  totalNumberOfVerses: 2,
100
96
  firstChapterApiLink: '/api/bsb/EXO/1.json',
101
97
  lastChapterApiLink: '/api/bsb/EXO/1.json',
102
- }
103
- ]
98
+ },
99
+ ],
104
100
  },
105
101
  '/api/bsb/GEN/1.json': {
106
102
  translation: expectedTranslation,
@@ -113,7 +109,7 @@ describe('generateApiForDataset()', () => {
113
109
  numberOfChapters: 1,
114
110
  totalNumberOfVerses: 2,
115
111
  firstChapterApiLink: '/api/bsb/GEN/1.json',
116
- lastChapterApiLink: '/api/bsb/GEN/1.json'
112
+ lastChapterApiLink: '/api/bsb/GEN/1.json',
117
113
  },
118
114
  thisChapterLink: '/api/bsb/GEN/1.json',
119
115
  thisChapterAudioLinks: {},
@@ -127,33 +123,31 @@ describe('generateApiForDataset()', () => {
127
123
  content: [
128
124
  {
129
125
  type: 'heading',
130
- content: [
131
- 'The Creation'
132
- ]
126
+ content: ['The Creation'],
133
127
  },
134
128
  {
135
- type: 'line_break'
129
+ type: 'line_break',
136
130
  },
137
131
  {
138
132
  type: 'verse',
139
133
  number: 1,
140
134
  content: [
141
- 'In the beginning God created the heavens and the earth.'
135
+ 'In the beginning God created the heavens and the earth.',
142
136
  ],
143
137
  },
144
138
  {
145
- type: 'line_break'
139
+ type: 'line_break',
146
140
  },
147
141
  {
148
142
  type: 'verse',
149
143
  number: 2,
150
144
  content: [
151
- 'Now the earth was formless and void, and darkness was over the surface of the deep. And the Spirit of God was hovering over the surface of the waters.'
145
+ 'Now the earth was formless and void, and darkness was over the surface of the deep. And the Spirit of God was hovering over the surface of the waters.',
152
146
  ],
153
147
  },
154
148
  ],
155
- footnotes: []
156
- }
149
+ footnotes: [],
150
+ },
157
151
  },
158
152
  '/api/bsb/EXO/1.json': {
159
153
  translation: expectedTranslation,
@@ -166,7 +160,7 @@ describe('generateApiForDataset()', () => {
166
160
  numberOfChapters: 1,
167
161
  totalNumberOfVerses: 2,
168
162
  firstChapterApiLink: '/api/bsb/EXO/1.json',
169
- lastChapterApiLink: '/api/bsb/EXO/1.json'
163
+ lastChapterApiLink: '/api/bsb/EXO/1.json',
170
164
  },
171
165
  thisChapterLink: '/api/bsb/EXO/1.json',
172
166
  thisChapterAudioLinks: {},
@@ -180,34 +174,30 @@ describe('generateApiForDataset()', () => {
180
174
  content: [
181
175
  {
182
176
  type: 'heading',
183
- content: [
184
- 'The Israelites Multiply in Egypt'
185
- ]
177
+ content: ['The Israelites Multiply in Egypt'],
186
178
  },
187
179
  {
188
- type: 'line_break'
180
+ type: 'line_break',
189
181
  },
190
182
  {
191
183
  type: 'verse',
192
184
  number: 1,
193
185
  content: [
194
- 'These are the names of the sons of Israel who went to Egypt with Jacob, each with his family:'
186
+ 'These are the names of the sons of Israel who went to Egypt with Jacob, each with his family:',
195
187
  ],
196
188
  },
197
189
  {
198
- type: 'line_break'
190
+ type: 'line_break',
199
191
  },
200
192
  {
201
193
  type: 'verse',
202
194
  number: 2,
203
- content: [
204
- 'Reuben, Simeon, Levi, and Judah;'
205
- ],
195
+ content: ['Reuben, Simeon, Levi, and Judah;'],
206
196
  },
207
197
  ],
208
- footnotes: []
209
- }
210
- }
198
+ footnotes: [],
199
+ },
200
+ },
211
201
  });
212
202
  // expect(availableTranslations).toEqual({
213
203
  // translations: [
@@ -224,27 +214,27 @@ describe('generateApiForDataset()', () => {
224
214
  language: 'eng',
225
215
  direction: 'ltr',
226
216
  licenseUrl: 'https://berean.bible/terms.htm',
227
- website: 'https://berean.bible'
217
+ website: 'https://berean.bible',
228
218
  };
229
219
  let inputFiles = [
230
220
  {
231
221
  fileType: 'usfm',
232
222
  metadata: {
233
- translation: translation1
223
+ translation: translation1,
234
224
  },
235
- content: firstXLines(_01GENBSB_usfm_1.default, 13)
225
+ content: firstXLines(_01GENBSB_usfm_1.default, 13),
236
226
  },
237
227
  {
238
228
  fileType: 'usfm',
239
229
  metadata: {
240
- translation: translation1
230
+ translation: translation1,
241
231
  },
242
- content: firstXLines(_02EXOBSB_usfm_1.default, 14)
243
- }
232
+ content: firstXLines(_02EXOBSB_usfm_1.default, 14),
233
+ },
244
234
  ];
245
235
  const dataset = (0, dataset_1.generateDataset)(inputFiles, new linkedom_1.DOMParser());
246
236
  const generated = (0, api_1.generateApiForDataset)(dataset, {
247
- pathPrefix: '/hello'
237
+ pathPrefix: '/hello',
248
238
  });
249
239
  const files = (0, api_1.generateFilesForApi)(generated);
250
240
  const tree = fileTree(files);
@@ -257,9 +247,7 @@ describe('generateApiForDataset()', () => {
257
247
  textDirection: 'ltr',
258
248
  licenseUrl: 'https://berean.bible/terms.htm',
259
249
  website: 'https://berean.bible',
260
- availableFormats: [
261
- 'json'
262
- ],
250
+ availableFormats: ['json'],
263
251
  listOfBooksApiLink: '/hello/api/bsb/books.json',
264
252
  numberOfBooks: 2,
265
253
  totalNumberOfChapters: 2,
@@ -269,9 +257,7 @@ describe('generateApiForDataset()', () => {
269
257
  };
270
258
  expect(tree).toEqual({
271
259
  '/hello/api/available_translations.json': {
272
- translations: [
273
- expectedTranslation
274
- ]
260
+ translations: [expectedTranslation],
275
261
  },
276
262
  '/hello/api/bsb/books.json': {
277
263
  translation: expectedTranslation,
@@ -297,8 +283,8 @@ describe('generateApiForDataset()', () => {
297
283
  totalNumberOfVerses: 2,
298
284
  firstChapterApiLink: '/hello/api/bsb/EXO/1.json',
299
285
  lastChapterApiLink: '/hello/api/bsb/EXO/1.json',
300
- }
301
- ]
286
+ },
287
+ ],
302
288
  },
303
289
  '/hello/api/bsb/GEN/1.json': {
304
290
  translation: expectedTranslation,
@@ -311,7 +297,7 @@ describe('generateApiForDataset()', () => {
311
297
  numberOfChapters: 1,
312
298
  totalNumberOfVerses: 2,
313
299
  firstChapterApiLink: '/hello/api/bsb/GEN/1.json',
314
- lastChapterApiLink: '/hello/api/bsb/GEN/1.json'
300
+ lastChapterApiLink: '/hello/api/bsb/GEN/1.json',
315
301
  },
316
302
  thisChapterLink: '/hello/api/bsb/GEN/1.json',
317
303
  thisChapterAudioLinks: {},
@@ -325,33 +311,31 @@ describe('generateApiForDataset()', () => {
325
311
  content: [
326
312
  {
327
313
  type: 'heading',
328
- content: [
329
- 'The Creation'
330
- ]
314
+ content: ['The Creation'],
331
315
  },
332
316
  {
333
- type: 'line_break'
317
+ type: 'line_break',
334
318
  },
335
319
  {
336
320
  type: 'verse',
337
321
  number: 1,
338
322
  content: [
339
- 'In the beginning God created the heavens and the earth.'
323
+ 'In the beginning God created the heavens and the earth.',
340
324
  ],
341
325
  },
342
326
  {
343
- type: 'line_break'
327
+ type: 'line_break',
344
328
  },
345
329
  {
346
330
  type: 'verse',
347
331
  number: 2,
348
332
  content: [
349
- 'Now the earth was formless and void, and darkness was over the surface of the deep. And the Spirit of God was hovering over the surface of the waters.'
333
+ 'Now the earth was formless and void, and darkness was over the surface of the deep. And the Spirit of God was hovering over the surface of the waters.',
350
334
  ],
351
335
  },
352
336
  ],
353
- footnotes: []
354
- }
337
+ footnotes: [],
338
+ },
355
339
  },
356
340
  '/hello/api/bsb/EXO/1.json': {
357
341
  translation: expectedTranslation,
@@ -364,7 +348,7 @@ describe('generateApiForDataset()', () => {
364
348
  numberOfChapters: 1,
365
349
  totalNumberOfVerses: 2,
366
350
  firstChapterApiLink: '/hello/api/bsb/EXO/1.json',
367
- lastChapterApiLink: '/hello/api/bsb/EXO/1.json'
351
+ lastChapterApiLink: '/hello/api/bsb/EXO/1.json',
368
352
  },
369
353
  thisChapterLink: '/hello/api/bsb/EXO/1.json',
370
354
  thisChapterAudioLinks: {},
@@ -378,34 +362,30 @@ describe('generateApiForDataset()', () => {
378
362
  content: [
379
363
  {
380
364
  type: 'heading',
381
- content: [
382
- 'The Israelites Multiply in Egypt'
383
- ]
365
+ content: ['The Israelites Multiply in Egypt'],
384
366
  },
385
367
  {
386
- type: 'line_break'
368
+ type: 'line_break',
387
369
  },
388
370
  {
389
371
  type: 'verse',
390
372
  number: 1,
391
373
  content: [
392
- 'These are the names of the sons of Israel who went to Egypt with Jacob, each with his family:'
374
+ 'These are the names of the sons of Israel who went to Egypt with Jacob, each with his family:',
393
375
  ],
394
376
  },
395
377
  {
396
- type: 'line_break'
378
+ type: 'line_break',
397
379
  },
398
380
  {
399
381
  type: 'verse',
400
382
  number: 2,
401
- content: [
402
- 'Reuben, Simeon, Levi, and Judah;'
403
- ],
383
+ content: ['Reuben, Simeon, Levi, and Judah;'],
404
384
  },
405
385
  ],
406
- footnotes: []
407
- }
408
- }
386
+ footnotes: [],
387
+ },
388
+ },
409
389
  });
410
390
  });
411
391
  it('should use underscores for spaces in the book name', () => {
@@ -417,15 +397,15 @@ describe('generateApiForDataset()', () => {
417
397
  language: 'eng',
418
398
  direction: 'ltr',
419
399
  licenseUrl: 'https://berean.bible/terms.htm',
420
- website: 'https://berean.bible'
400
+ website: 'https://berean.bible',
421
401
  };
422
402
  let inputFiles = [
423
403
  {
424
404
  fileType: 'usfm',
425
405
  metadata: {
426
- translation: translation1
406
+ translation: translation1,
427
407
  },
428
- content: firstXLines(_131CHBSB_usfm_1.default, 11)
408
+ content: firstXLines(_131CHBSB_usfm_1.default, 11),
429
409
  },
430
410
  ];
431
411
  const dataset = (0, dataset_1.generateDataset)(inputFiles, new linkedom_1.DOMParser());
@@ -443,9 +423,7 @@ describe('generateApiForDataset()', () => {
443
423
  textDirection: 'ltr',
444
424
  licenseUrl: 'https://berean.bible/terms.htm',
445
425
  website: 'https://berean.bible',
446
- availableFormats: [
447
- 'json'
448
- ],
426
+ availableFormats: ['json'],
449
427
  listOfBooksApiLink: '/api/bsb/books.json',
450
428
  numberOfBooks: 1,
451
429
  totalNumberOfChapters: 1,
@@ -455,9 +433,7 @@ describe('generateApiForDataset()', () => {
455
433
  };
456
434
  expect(tree).toEqual({
457
435
  '/api/available_translations.json': {
458
- translations: [
459
- expectedTranslation
460
- ]
436
+ translations: [expectedTranslation],
461
437
  },
462
438
  '/api/bsb/books.json': {
463
439
  translation: expectedTranslation,
@@ -473,7 +449,7 @@ describe('generateApiForDataset()', () => {
473
449
  firstChapterApiLink: '/api/bsb/1_Chronicles/1.json',
474
450
  lastChapterApiLink: '/api/bsb/1_Chronicles/1.json',
475
451
  },
476
- ]
452
+ ],
477
453
  },
478
454
  '/api/bsb/1_Chronicles/1.json': {
479
455
  translation: expectedTranslation,
@@ -486,9 +462,9 @@ describe('generateApiForDataset()', () => {
486
462
  totalNumberOfVerses: 1,
487
463
  order: 13,
488
464
  firstChapterApiLink: '/api/bsb/1_Chronicles/1.json',
489
- lastChapterApiLink: '/api/bsb/1_Chronicles/1.json'
465
+ lastChapterApiLink: '/api/bsb/1_Chronicles/1.json',
490
466
  },
491
- thisChapterLink: "/api/bsb/1_Chronicles/1.json",
467
+ thisChapterLink: '/api/bsb/1_Chronicles/1.json',
492
468
  thisChapterAudioLinks: {},
493
469
  nextChapterApiLink: null,
494
470
  nextChapterAudioLinks: null,
@@ -500,23 +476,19 @@ describe('generateApiForDataset()', () => {
500
476
  content: [
501
477
  {
502
478
  type: 'heading',
503
- content: [
504
- 'From Adam to Abraham'
505
- ]
479
+ content: ['From Adam to Abraham'],
506
480
  },
507
481
  {
508
- type: 'line_break'
482
+ type: 'line_break',
509
483
  },
510
484
  {
511
485
  type: 'verse',
512
486
  number: 1,
513
- content: [
514
- 'Adam, Seth, Enosh,'
515
- ],
487
+ content: ['Adam, Seth, Enosh,'],
516
488
  },
517
489
  ],
518
- footnotes: []
519
- }
490
+ footnotes: [],
491
+ },
520
492
  },
521
493
  });
522
494
  // expect(availableTranslations).toEqual({
@@ -534,15 +506,15 @@ describe('generateApiForDataset()', () => {
534
506
  language: 'spa',
535
507
  direction: 'ltr',
536
508
  licenseUrl: 'https://berean.bible/terms.htm',
537
- website: 'https://berean.bible'
509
+ website: 'https://berean.bible',
538
510
  };
539
511
  let inputFiles = [
540
512
  {
541
513
  fileType: 'usfm',
542
514
  metadata: {
543
- translation: translation1
515
+ translation: translation1,
544
516
  },
545
- content: firstXLines(_131CHBSB_usfm_1.default, 11)
517
+ content: firstXLines(_131CHBSB_usfm_1.default, 11),
546
518
  },
547
519
  ];
548
520
  const dataset = (0, dataset_1.generateDataset)(inputFiles, new linkedom_1.DOMParser());
@@ -560,9 +532,7 @@ describe('generateApiForDataset()', () => {
560
532
  textDirection: 'ltr',
561
533
  licenseUrl: 'https://berean.bible/terms.htm',
562
534
  website: 'https://berean.bible',
563
- availableFormats: [
564
- 'json'
565
- ],
535
+ availableFormats: ['json'],
566
536
  listOfBooksApiLink: '/api/bsb/books.json',
567
537
  numberOfBooks: 1,
568
538
  totalNumberOfChapters: 1,
@@ -572,9 +542,7 @@ describe('generateApiForDataset()', () => {
572
542
  };
573
543
  expect(tree).toEqual({
574
544
  '/api/available_translations.json': {
575
- translations: [
576
- expectedTranslation
577
- ]
545
+ translations: [expectedTranslation],
578
546
  },
579
547
  '/api/bsb/books.json': {
580
548
  translation: expectedTranslation,
@@ -590,7 +558,7 @@ describe('generateApiForDataset()', () => {
590
558
  firstChapterApiLink: '/api/bsb/1_Chronicles/1.json',
591
559
  lastChapterApiLink: '/api/bsb/1_Chronicles/1.json',
592
560
  },
593
- ]
561
+ ],
594
562
  },
595
563
  '/api/bsb/1_Chronicles/1.json': {
596
564
  translation: expectedTranslation,
@@ -603,9 +571,9 @@ describe('generateApiForDataset()', () => {
603
571
  totalNumberOfVerses: 1,
604
572
  order: 13,
605
573
  firstChapterApiLink: '/api/bsb/1_Chronicles/1.json',
606
- lastChapterApiLink: '/api/bsb/1_Chronicles/1.json'
574
+ lastChapterApiLink: '/api/bsb/1_Chronicles/1.json',
607
575
  },
608
- thisChapterLink: "/api/bsb/1_Chronicles/1.json",
576
+ thisChapterLink: '/api/bsb/1_Chronicles/1.json',
609
577
  thisChapterAudioLinks: {},
610
578
  nextChapterApiLink: null,
611
579
  nextChapterAudioLinks: null,
@@ -617,23 +585,19 @@ describe('generateApiForDataset()', () => {
617
585
  content: [
618
586
  {
619
587
  type: 'heading',
620
- content: [
621
- 'From Adam to Abraham'
622
- ]
588
+ content: ['From Adam to Abraham'],
623
589
  },
624
590
  {
625
- type: 'line_break'
591
+ type: 'line_break',
626
592
  },
627
593
  {
628
594
  type: 'verse',
629
595
  number: 1,
630
- content: [
631
- 'Adam, Seth, Enosh,'
632
- ],
596
+ content: ['Adam, Seth, Enosh,'],
633
597
  },
634
598
  ],
635
- footnotes: []
636
- }
599
+ footnotes: [],
600
+ },
637
601
  },
638
602
  });
639
603
  // expect(availableTranslations).toEqual({
@@ -1,4 +1,4 @@
1
- import { InputFile, Translation, TranslationBook, TranslationBookChapter } from "./common-types";
1
+ import { InputFile, Translation, TranslationBook, TranslationBookChapter } from './common-types';
2
2
  /**
3
3
  * Defines an interface that contains generated dataset info.
4
4
  */
@@ -63,7 +63,7 @@ function generateDataset(files, parser = new globalThis.DOMParser()) {
63
63
  translation = {
64
64
  ...(0, lodash_1.omit)(file.metadata.translation, 'direction'),
65
65
  textDirection: file.metadata.translation.direction,
66
- books: []
66
+ books: [],
67
67
  };
68
68
  output.translations.push(translation);
69
69
  parsedTranslations.set(file.metadata.translation.id, translation);
@@ -88,14 +88,14 @@ function generateDataset(files, parser = new globalThis.DOMParser()) {
88
88
  chapter: {
89
89
  number: content.number,
90
90
  content: content.content,
91
- footnotes: content.footnotes
91
+ footnotes: content.footnotes,
92
92
  },
93
- thisChapterAudioLinks: (0, audio_1.getAudioUrlsForChapter)(translation.id, id, content.number)
93
+ thisChapterAudioLinks: (0, audio_1.getAudioUrlsForChapter)(translation.id, id, content.number),
94
94
  });
95
95
  }
96
96
  }
97
- book.chapters = (0, lodash_1.sortBy)(book.chapters, c => c.chapter.number);
98
- const index = (0, lodash_1.sortedIndexBy)(translation.books, book, b => b.order);
97
+ book.chapters = (0, lodash_1.sortBy)(book.chapters, (c) => c.chapter.number);
98
+ const index = (0, lodash_1.sortedIndexBy)(translation.books, book, (b) => b.order);
99
99
  translation.books.splice(index, 0, book);
100
100
  }
101
101
  catch (err) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@helloao/tools",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
4
4
  "description": "A set of tools for managing HelloAO's Free Bible API",
5
5
  "module": "index.js",
6
6
  "types": "index.d.ts",
@@ -8,7 +8,6 @@
8
8
  "license": "MIT",
9
9
  "dependencies": {
10
10
  "lodash": "4.17.21",
11
- "all-iso-language-codes": "1.0.17",
12
11
  "zod": "^3.23.8"
13
12
  },
14
13
  "devDependencies": {