@helloao/cli 0.1.0 → 0.3.0

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 (67) hide show
  1. package/README.md +138 -136
  2. package/dist/cjs/cli.cjs +8049 -12681
  3. package/dist/cjs/index.cjs +7628 -12571
  4. package/dist/esm/cli.js +5699 -0
  5. package/dist/esm/cli.js.map +7 -0
  6. package/dist/esm/index.js +1972 -6262
  7. package/dist/esm/index.js.map +4 -4
  8. package/dist/types/actions.d.ts +71 -0
  9. package/dist/types/db.d.ts +12 -8
  10. package/dist/types/ebible.d.ts +1 -1
  11. package/dist/types/files.d.ts +12 -1
  12. package/dist/types/openapi.d.ts +2 -0
  13. package/dist/types/prisma-gen/browser.d.ts +110 -0
  14. package/dist/types/prisma-gen/client.d.ts +129 -0
  15. package/dist/types/prisma-gen/commonInputTypes.d.ts +378 -0
  16. package/dist/types/prisma-gen/enums.d.ts +2 -0
  17. package/dist/types/prisma-gen/internal/class.d.ts +353 -0
  18. package/dist/types/prisma-gen/internal/prismaNamespace.d.ts +2273 -0
  19. package/dist/types/prisma-gen/internal/prismaNamespaceBrowser.d.ts +294 -0
  20. package/dist/types/prisma-gen/models/Book.d.ts +2197 -0
  21. package/dist/types/prisma-gen/models/Chapter.d.ts +1934 -0
  22. package/dist/types/prisma-gen/models/ChapterAudioTiming.d.ts +1414 -0
  23. package/dist/types/prisma-gen/models/ChapterAudioUrl.d.ts +1414 -0
  24. package/dist/types/prisma-gen/models/ChapterFootnote.d.ts +1642 -0
  25. package/dist/types/prisma-gen/models/ChapterVerse.d.ts +1653 -0
  26. package/dist/types/prisma-gen/models/ChapterWords.d.ts +1366 -0
  27. package/dist/types/prisma-gen/models/Commentary.d.ts +1711 -0
  28. package/dist/types/prisma-gen/models/CommentaryBook.d.ts +1622 -0
  29. package/dist/types/prisma-gen/models/CommentaryChapter.d.ts +1487 -0
  30. package/dist/types/prisma-gen/models/CommentaryChapterVerse.d.ts +1514 -0
  31. package/dist/types/prisma-gen/models/CommentaryProfile.d.ts +1451 -0
  32. package/dist/types/prisma-gen/models/Dataset.d.ts +1667 -0
  33. package/dist/types/prisma-gen/models/DatasetBook.d.ts +1565 -0
  34. package/dist/types/prisma-gen/models/DatasetChapter.d.ts +1553 -0
  35. package/dist/types/prisma-gen/models/DatasetChapterVerse.d.ts +1600 -0
  36. package/dist/types/prisma-gen/models/DatasetReference.d.ts +1789 -0
  37. package/dist/types/prisma-gen/models/EBibleSource.d.ts +1686 -0
  38. package/dist/types/prisma-gen/models/InputFile.d.ts +1039 -0
  39. package/dist/types/prisma-gen/models/InputFileWarning.d.ts +946 -0
  40. package/dist/types/prisma-gen/models/Translation.d.ts +2238 -0
  41. package/dist/types/prisma-gen/models.d.ts +23 -0
  42. package/dist/types/s3.d.ts +2 -0
  43. package/dist/types/uploads.d.ts +7 -1
  44. package/migrations/20260217200934_add_license_notice/migration.sql +5 -0
  45. package/migrations/20260703000000_add_chapter_audio_timing/migration.sql +13 -0
  46. package/migrations/20260809000000_add_chapter_words/migration.sql +12 -0
  47. package/package.json +23 -17
  48. package/schema.prisma +43 -2
  49. package/prisma-gen/client.d.ts +0 -1
  50. package/prisma-gen/client.js +0 -4
  51. package/prisma-gen/default.d.ts +0 -1
  52. package/prisma-gen/default.js +0 -1
  53. package/prisma-gen/edge.d.ts +0 -1
  54. package/prisma-gen/edge.js +0 -401
  55. package/prisma-gen/index-browser.js +0 -395
  56. package/prisma-gen/index.d.ts +0 -33919
  57. package/prisma-gen/index.js +0 -424
  58. package/prisma-gen/runtime/edge-esm.js +0 -31
  59. package/prisma-gen/runtime/edge.js +0 -31
  60. package/prisma-gen/runtime/index-browser.d.ts +0 -365
  61. package/prisma-gen/runtime/index-browser.js +0 -13
  62. package/prisma-gen/runtime/library.d.ts +0 -3403
  63. package/prisma-gen/runtime/library.js +0 -143
  64. package/prisma-gen/runtime/react-native.js +0 -80
  65. package/prisma-gen/runtime/wasm.js +0 -32
  66. package/prisma-gen/wasm.d.ts +0 -1
  67. package/prisma-gen/wasm.js +0 -395
package/README.md CHANGED
@@ -1,136 +1,138 @@
1
- ## Hello AO CLI
2
-
3
- A Command Line Interface (CLI) that makes it easy to generate and manage your own [Free Use Bible API](https://bible.helloao.org/).
4
-
5
- Additionally, it includes many functions and utilities that can make working with commonly formatted Bible data much easier.
6
-
7
- ### Features
8
-
9
- - Supports [USFM](https://ubsicap.github.io/usfm/), [USX](https://ubsicap.github.io/usx/), and Codex (A JSON format).
10
- - Download over 1000 Bible translations from [fetch.bible](https://fetch.bible/).
11
- - Import Bible translations into a SQLite database.
12
- - Upload to S3, a zip file, or a local directory.
13
-
14
- ### Usage
15
-
16
- ```
17
- Usage: helloao [options] [command]
18
-
19
- A CLI for managing a Free Use Bible API.
20
-
21
- Options:
22
- -V, --version output the version number
23
- -h, --help display help for command
24
-
25
- Commands:
26
- init [options] [path] Initialize a new Bible API DB.
27
- generate-translation-metadata Generates a metadata file for a translation.
28
- import-translation [options] <dir> [dirs...] Imports a translation from the given directory into the database.
29
- import-translations [options] <dir> Imports all translations from the given directory into the database.
30
- import-commentary [options] <dir> [dirs...] Imports a commentary from the given directory into the database.
31
- import-commentaries [options] <dir> Imports all commentaries from the given directory into the database.
32
- upload-test-translation [options] <input> Uploads a translation to the HelloAO Free Bible API test S3 bucket.
33
- Requires access to the HelloAO Free Bible API test S3 bucket.
34
- For inquiries, please contact hello@helloao.org.
35
- upload-test-translations [options] <input> Uploads all the translations in the given input directory to the HelloAO Free Bible API test S3 bucket.
36
- Requires access to the HelloAO Free Bible API test S3 bucket.
37
- For inquiries, please contact hello@helloao.org.
38
- generate-translation-files [options] <input> <dir> Generates API files from the given input translation.
39
- generate-translations-files [options] <input> <dir> Generates API files from the given input translations.
40
- upload-api-files [options] <dest> Uploads API files to the specified destination. For S3, use the format s3://bucket-name/path/to/folder.
41
- source-translations [options] <dir> [translations...] Finds translation sources from ebible.org and downloads it.
42
- list-ebible-translations [search] List available eBible translations. Optionally filter by search term.
43
- fetch-audio [options] <dir> [translations...] Fetches the specified audio translations and places them in the given directory.
44
- Translations should be in the format "translationId/audioId". e.g. "BSB/gilbert"
45
- fetch-bible-metadata <dir> Fetches the Theographic bible metadata and places it in the given directory.
46
- fetch-tyndale-open-resources <dir> Fetches the Tyndale Open Bible Resources and places it in the given directory.
47
- help [command] display help for command
48
- ```
49
-
50
- The `@helloao/cli` package can also be used as a library.
51
-
52
- The library exports a variety of actions, utilities, and supporting classes designed to assist with generating and managing a Free Use Bible API.
53
-
54
- There are 6 main exports:
55
-
56
- - `actions` - This export contains function versions of the CLI commands. They make it easy to call a CLI command from a script.
57
- - `db` - This export contains functions that make working with a database easier. It supports operations like importing translations into a database, inserting chapters, verses, etc. and getting an updated database instance from a path.
58
- - `downloads` - This export contains functions that make downloading files easier.
59
- - `files` - This export contains functions that make working with files easier. It has functions to load files from a translation, discover translation metadata from the filesystem, and classes that support uploading API files to the local file system or to a zip archive.
60
- - `uploads` - This export contains functions that make it easy to upload an API to a destination like S3, the local filesystem, or a zip archive.
61
- - `s3` - This export contains a class that can upload files to S3.
62
-
63
- Here are some common operations that you might want to perform:
64
-
65
- #### Get a SQL Database
66
-
67
- ```typescript
68
- import { db } from '@helloao/cli';
69
-
70
- const pathToDb = './bible-database.db';
71
- const database = await db.getDb(pathToDb);
72
-
73
- // do work on the database
74
-
75
- // Close it when you are done.
76
- database.close();
77
- ```
78
-
79
- #### Import a translation into a database from a directory
80
-
81
- ```typescript
82
- import { db } from '@helloao/cli';
83
-
84
- const pathToDb = './bible-database.db';
85
- const database = await db.getDb(pathToDb);
86
-
87
- // Get a DOMParser for parsing USX.
88
- // On Node.js, you may have to import jsdom or linkedom.
89
- const parser = new DOMParser();
90
-
91
- const pathToTranslation = './path/to/translation';
92
-
93
- // Whether to overwrite files that already exist in the database.
94
- // The system will automatically determine the hashes of the input files and overwrite changed files if needed, so this is only needed
95
- // when you know that they need to be overwritten.
96
- const overwrite = false;
97
- await db.importTranslations(database, pathToTranslation, parser, overwrite);
98
- ```
99
-
100
- #### Generate an API from a translation
101
-
102
- ```typescript
103
- import { files, uploads } from '@helloao/cli';
104
- import { generation } from '@helloao/tools';
105
- import { toAsyncIterable } from '@helloao/tools/parser/iterators';
106
-
107
- const translationPath = './path/to/translation';
108
- const translationFiles = await files.loadTranslationFiles(translationPath);
109
-
110
- // Used to parse XML
111
- const domParser = new DOMParser();
112
-
113
- // Generate a dataset from the files
114
- // Datasets organize all the files and their content
115
- // by translation, book, chapter, and verse
116
- const dataset = generation.dataset.generateDataset(files, parser);
117
-
118
- // You can optionally specifiy a prefix that should be added to all API
119
- // links
120
- const pathPrefix = '';
121
-
122
- // Generate an API representation from the files
123
- // This adds links between chapters and additional metadata.
124
- const api = generation.api.generateApiForDataset(dataset, {
125
- pathPrefix,
126
- });
127
-
128
- // Generate output files from the API representation.
129
- // This will give us a list of files and file paths that represent
130
- // the entire API.
131
- const outputFiles = generation.api.generateFilesForApi(api);
132
-
133
- // Optionally upload files by using:
134
- // const dest = 's3://my-bucket';
135
- // await uploads.serializeAndUploadDatasets(dest, toAsyncIterable(outputFiles));
136
- ```
1
+ ## Hello AO CLI
2
+
3
+ A Command Line Interface (CLI) that makes it easy to generate and manage your own [Free Use Bible API](https://bible.helloao.org/).
4
+
5
+ Additionally, it includes many functions and utilities that can make working with commonly formatted Bible data much easier.
6
+
7
+ ### Features
8
+
9
+ - Supports [USFM](https://ubsicap.github.io/usfm/), [USX](https://ubsicap.github.io/usx/), and Codex (A JSON format).
10
+ - Download over 1000 Bible translations from [fetch.bible](https://fetch.bible/).
11
+ - Import Bible translations into a SQLite database.
12
+ - Upload to S3, a zip file, or a local directory.
13
+
14
+ ### Usage
15
+
16
+ ```
17
+ Usage: helloao [options] [command]
18
+
19
+ A CLI for managing a Free Use Bible API.
20
+
21
+ Options:
22
+ -V, --version output the version number
23
+ -h, --help display help for command
24
+
25
+ Commands:
26
+ init [options] [path] Initialize a new Bible API DB.
27
+ generate-translation-metadata Generates a metadata file for a translation.
28
+ import-translation [options] <dir> [dirs...] Imports a translation from the given directory into the database.
29
+ import-translations [options] <dir> Imports all translations from the given directory into the database.
30
+ import-commentary [options] <dir> [dirs...] Imports a commentary from the given directory into the database.
31
+ import-commentaries [options] <dir> Imports all commentaries from the given directory into the database.
32
+ upload-test-translation [options] <input> Uploads a translation to the HelloAO Free Bible API test S3 bucket.
33
+ Requires access to the HelloAO Free Bible API test S3 bucket.
34
+ For inquiries, please contact hello@helloao.org.
35
+ upload-test-translations [options] <input> Uploads all the translations in the given input directory to the HelloAO Free Bible API test S3 bucket.
36
+ Requires access to the HelloAO Free Bible API test S3 bucket.
37
+ For inquiries, please contact hello@helloao.org.
38
+ generate-translation-files [options] <input> <dir> Generates API files from the given input translation.
39
+ generate-translations-files [options] <input> <dir> Generates API files from the given input translations.
40
+ upload-api-files [options] <dest> Uploads API files to the specified destination. For S3, use the format s3://bucket-name/path/to/folder.
41
+ source-translations [options] <dir> [translations...] Finds translation sources from ebible.org and downloads it.
42
+ list-ebible-translations [search] List available eBible translations. Optionally filter by search term.
43
+ fetch-audio [options] <dir> [translations...] Fetches the specified audio translations and places them in the given directory.
44
+ Translations should be in the format "translationId/audioId". e.g. "BSB/gilbert"
45
+ fetch-bible-metadata <dir> Fetches the Theographic bible metadata and places it in the given directory.
46
+ fetch-tyndale-open-resources <dir> Fetches the Tyndale Open Bible Resources and places it in the given directory.
47
+ help [command] display help for command
48
+ ```
49
+
50
+ > **Audio timings.** The `import-audio-timings <file>` command loads per-verse start times for a chapter's audio into the database, from a JSON array of `{ translationId, bookId, chapterNumber, reader, verses }` records. To generate that file from the audio itself, see [`tools/audio-timings`](../../tools/audio-timings/README.md), which transcribes a chapter with whisperX and aligns the result against the chapter's known verse text.
51
+
52
+ The `@helloao/cli` package can also be used as a library.
53
+
54
+ The library exports a variety of actions, utilities, and supporting classes designed to assist with generating and managing a Free Use Bible API.
55
+
56
+ There are 6 main exports:
57
+
58
+ - `actions` - This export contains function versions of the CLI commands. They make it easy to call a CLI command from a script.
59
+ - `db` - This export contains functions that make working with a database easier. It supports operations like importing translations into a database, inserting chapters, verses, etc. and getting an updated database instance from a path.
60
+ - `downloads` - This export contains functions that make downloading files easier.
61
+ - `files` - This export contains functions that make working with files easier. It has functions to load files from a translation, discover translation metadata from the filesystem, and classes that support uploading API files to the local file system or to a zip archive.
62
+ - `uploads` - This export contains functions that make it easy to upload an API to a destination like S3, the local filesystem, or a zip archive.
63
+ - `s3` - This export contains a class that can upload files to S3.
64
+
65
+ Here are some common operations that you might want to perform:
66
+
67
+ #### Get a SQL Database
68
+
69
+ ```typescript
70
+ import { db } from '@helloao/cli';
71
+
72
+ const pathToDb = './bible-database.db';
73
+ const database = await db.getDb(pathToDb);
74
+
75
+ // do work on the database
76
+
77
+ // Close it when you are done.
78
+ database.close();
79
+ ```
80
+
81
+ #### Import a translation into a database from a directory
82
+
83
+ ```typescript
84
+ import { db } from '@helloao/cli';
85
+
86
+ const pathToDb = './bible-database.db';
87
+ const database = await db.getDb(pathToDb);
88
+
89
+ // Get a DOMParser for parsing USX.
90
+ // On Node.js, you may have to import jsdom or linkedom.
91
+ const parser = new DOMParser();
92
+
93
+ const pathToTranslation = './path/to/translation';
94
+
95
+ // Whether to overwrite files that already exist in the database.
96
+ // The system will automatically determine the hashes of the input files and overwrite changed files if needed, so this is only needed
97
+ // when you know that they need to be overwritten.
98
+ const overwrite = false;
99
+ await db.importTranslations(database, pathToTranslation, parser, overwrite);
100
+ ```
101
+
102
+ #### Generate an API from a translation
103
+
104
+ ```typescript
105
+ import { files, uploads } from '@helloao/cli';
106
+ import { generation } from '@helloao/tools';
107
+ import { toAsyncIterable } from '@helloao/tools/parser/iterators';
108
+
109
+ const translationPath = './path/to/translation';
110
+ const translationFiles = await files.loadTranslationFiles(translationPath);
111
+
112
+ // Used to parse XML
113
+ const domParser = new DOMParser();
114
+
115
+ // Generate a dataset from the files
116
+ // Datasets organize all the files and their content
117
+ // by translation, book, chapter, and verse
118
+ const dataset = generation.dataset.generateDataset(files, parser);
119
+
120
+ // You can optionally specifiy a prefix that should be added to all API
121
+ // links
122
+ const pathPrefix = '';
123
+
124
+ // Generate an API representation from the files
125
+ // This adds links between chapters and additional metadata.
126
+ const api = generation.api.generateApiForDataset(dataset, {
127
+ pathPrefix,
128
+ });
129
+
130
+ // Generate output files from the API representation.
131
+ // This will give us a list of files and file paths that represent
132
+ // the entire API.
133
+ const outputFiles = generation.api.generateFilesForApi(api);
134
+
135
+ // Optionally upload files by using:
136
+ // const dest = 's3://my-bucket';
137
+ // await uploads.serializeAndUploadDatasets(dest, toAsyncIterable(outputFiles));
138
+ ```