@helloao/cli 0.0.18 → 0.0.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.
@@ -0,0 +1,240 @@
1
+ import { InputTranslationMetadata } from '@helloao/tools/generation/index.js';
2
+ import { UploadApiFromDatabaseOptions, UploadApiOptions } from './uploads.js';
3
+ export interface GetTranslationsItem {
4
+ id: string;
5
+ language: string;
6
+ direction: 'ltr' | 'rtl';
7
+ year: number;
8
+ name_local: string;
9
+ name_english: string;
10
+ name_abbrev: string;
11
+ attribution: string;
12
+ attribution_url: string;
13
+ licenses: RuntimeLicense[];
14
+ }
15
+ export interface RuntimeLicense {
16
+ id: string | null;
17
+ name: string;
18
+ restrictions: MetaRestrictions;
19
+ url: string;
20
+ }
21
+ export interface MetaRestrictions {
22
+ limit_verses: number | null;
23
+ limit_book_ratio: number | null;
24
+ limit_content_ratio: number | null;
25
+ forbid_commercial: boolean;
26
+ forbid_derivatives: boolean | 'same-license';
27
+ forbid_attributionless: boolean;
28
+ forbid_other: boolean;
29
+ }
30
+ export interface InitDbOptions {
31
+ /**
32
+ * The path to the source database to copy the schema from.
33
+ */
34
+ source?: string;
35
+ /**
36
+ * Whether to overwrite the existing database.
37
+ */
38
+ overwrite?: boolean;
39
+ /**
40
+ * The languages to copy from the source database. If not specified, then all languages will be copied.
41
+ */
42
+ language?: string[];
43
+ }
44
+ export interface ConvertToUsx3Options {
45
+ /**
46
+ * Whether to overwrite existing files in output directory.
47
+ */
48
+ overwrite?: boolean;
49
+ }
50
+ export interface SourceTranslationsOptions {
51
+ /**
52
+ * Whether to convert USFM files to USX3 format after download.
53
+ */
54
+ convertToUsx3?: boolean;
55
+ /**
56
+ * Options for USX3 conversion.
57
+ */
58
+ conversionOptions?: ConvertToUsx3Options;
59
+ /**
60
+ * Whether to track downloads in database.
61
+ */
62
+ useDatabase?: boolean;
63
+ /**
64
+ * Path to BibleMultiConverter.jar file. If not provided, will search common locations.
65
+ */
66
+ bibleMultiConverterPath?: string;
67
+ /**
68
+ * Whether to overwrite existing files in output directory.
69
+ *
70
+ * If database tracking is enabled, this will prevent overwriting files that were not tracked in the database.
71
+ */
72
+ overwrite?: boolean;
73
+ /**
74
+ * The database to use for tracking downloads.
75
+ */
76
+ db?: string | null;
77
+ }
78
+ export declare function getMetaPath(): Promise<string | null>;
79
+ /**
80
+ * Initializes a new Bible API DB.
81
+ * @param dbPath The path to the database. If null or empty, then the "bible-api.db" will be used from the current working directory.
82
+ * @param options The options for the initialization.
83
+ */
84
+ export declare function initDb(dbPath: string | null, options: InitDbOptions): Promise<void>;
85
+ export interface ImportTranslationOptions {
86
+ /**
87
+ * Whether to forcibly import the translations, even if they have already been imported.
88
+ */
89
+ overwrite?: boolean;
90
+ /**
91
+ * The database to import the translations into.
92
+ */
93
+ db?: string | null;
94
+ }
95
+ /**
96
+ * Imports a translation from the given directory into the database in the current working directory.
97
+ * @param dir The directory that the translation is located in.
98
+ * @param dirs Any extra directories that should be imported.
99
+ * @param options The options for the import.
100
+ */
101
+ export declare function importTranslation(dir: string, dirs: string[], options: ImportTranslationOptions): Promise<void>;
102
+ /**
103
+ * Imports all the translations from the given directory into the database in the current working directory.
104
+ * @param dir The directory that the translations are located in.
105
+ * @param options The options.
106
+ */
107
+ export declare function importTranslations(dir: string, options: ImportTranslationOptions): Promise<void>;
108
+ /**
109
+ * Imports a commentary from the given directory into the database in the current working directory.
110
+ * @param dir The directory that the commentary is located in.
111
+ * @param dirs Any extra directories that should be imported.
112
+ * @param options The options for the import.
113
+ */
114
+ export declare function importCommentary(dir: string, dirs: string[], options: ImportTranslationOptions): Promise<void>;
115
+ /**
116
+ * Imports all the commentaries from the given directory into the database in the current working directory.
117
+ * @param dir The directory that the commentaries are located in.
118
+ * @param options The options.
119
+ */
120
+ export declare function importCommentaries(dir: string, options: ImportTranslationOptions): Promise<void>;
121
+ /**
122
+ * Imports the API from the given directory into the database in the current working directory.
123
+ * @param dir The directory that the API is located in.
124
+ * @param options The options.
125
+ */
126
+ export declare function importApi(dir: string, options: ImportTranslationOptions): Promise<void>;
127
+ export interface FetchTranslationsOptions {
128
+ /**
129
+ * Fetch all translations. If omitted, only undownloaded translations will be fetched.
130
+ */
131
+ all?: boolean;
132
+ }
133
+ /**
134
+ * Fetches the specified audio translations and places them in the given directory.
135
+ * Translations should be in the format "translationId/audioId". e.g. "BSB/gilbert"
136
+ * @param dir The directory that the translations should be placed in.
137
+ * @param translations The translations that should be downloaded.
138
+ * @param options The options.
139
+ */
140
+ export declare function fetchAudio(dir: string, translations: string[], options?: FetchTranslationsOptions): Promise<void>;
141
+ /**
142
+ * Generates the translation files directly from the translations stored in the given input directory.
143
+ * @param input The input directory that the translations are stored in.
144
+ * @param dest The destination to upload the API files to.
145
+ * @param options The options for the generation.
146
+ */
147
+ export declare function generateTranslationsFiles(input: string, dest: string, options: UploadApiFromDatabaseOptions): Promise<void>;
148
+ /**
149
+ * Instructions for manual USFM to USX3 conversion using BibleMultiConverter
150
+ */
151
+ export declare const CONVERSION_INSTRUCTIONS: {
152
+ downloadUrl: string;
153
+ javaRequirement: string;
154
+ getConversionCommand: (inputDir: string, outputDir: string, filenamePattern?: string) => string;
155
+ examples: {
156
+ windows: string;
157
+ unix: string;
158
+ };
159
+ };
160
+ /**
161
+ * Prints conversion instructions for the user
162
+ */
163
+ export declare function printConversionInstructions(): void;
164
+ /**
165
+ * Downloads and processes USFM files from eBible.org.
166
+ * Can optionally convert to USX3 format and/or track in database.
167
+ */
168
+ export declare function sourceTranslations(outputDir: string, translations?: string[], options?: SourceTranslationsOptions): Promise<void>;
169
+ export declare function listEBibleTranslations(searchTerm?: string): Promise<void>;
170
+ /**
171
+ * Generates the translation files directly from the translation stored in the given input directory.
172
+ * @param input The input directory that the translation is stored in.
173
+ * @param dest The destination to upload the API files to.
174
+ * @param options The options for the generation.
175
+ */
176
+ export declare function generateTranslationFiles(input: string, dest: string, options: UploadApiOptions): Promise<void>;
177
+ /**
178
+ * The options for uploading the test translations.
179
+ */
180
+ export interface UploadTestTranslationOptions extends UploadApiOptions {
181
+ /**
182
+ * The s3 URL to upload the translations to.
183
+ * Defaults to "s3://ao-bible-api-public-uploads"
184
+ */
185
+ s3Url?: string;
186
+ /**
187
+ * The metadata that should be used for the translation.
188
+ */
189
+ translationMetadata?: InputTranslationMetadata;
190
+ /**
191
+ * The map of book IDs to common names.
192
+ */
193
+ bookNameMap?: Map<string, {
194
+ commonName: string;
195
+ }>;
196
+ }
197
+ export interface UploadTestTranslationResult {
198
+ /**
199
+ * The S3 URL where the translations were uploaded to.
200
+ */
201
+ uploadS3Url: string;
202
+ /**
203
+ * The HTTP URL that the version can be accessed at.
204
+ */
205
+ url: string;
206
+ /**
207
+ * The URL that the available translations can be accessed at.
208
+ */
209
+ availableTranslationsUrl: string;
210
+ /**
211
+ * The version that was uploaded.
212
+ * This is a SHA-256 hash of the input files.
213
+ */
214
+ version: string;
215
+ }
216
+ /**
217
+ * Generates the API files directly from the translations stored in the given input directory and
218
+ * uploads them to the HelloAO test s3 bucket.
219
+ *
220
+ * Requires access to the HelloAO test s3 bucket. Email hello@helloao.org for access.
221
+ *
222
+ * @param input The input directory that the translations are stored in.
223
+ * @param options The options to use for the upload.
224
+ */
225
+ export declare function uploadTestTranslations(input: string, options: UploadTestTranslationOptions): Promise<UploadTestTranslationResult>;
226
+ /**
227
+ * Generates the API files directly from the given translation and
228
+ * uploads them to the HelloAO test s3 bucket.
229
+ *
230
+ * Requires access to the HelloAO test s3 bucket. Email hello@helloao.org for access.
231
+ *
232
+ * @param input The input directory that the translations are stored in.
233
+ * @param options The options to use for the upload.
234
+ */
235
+ export declare function uploadTestTranslation(input: string, options: UploadTestTranslationOptions): Promise<UploadTestTranslationResult | undefined>;
236
+ /**
237
+ * Asks the user for the metadata for the translation.
238
+ */
239
+ export declare function askForMetadata(defaultId?: string): Promise<InputTranslationMetadata>;
240
+ //# sourceMappingURL=actions.d.ts.map
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Finds BibleMultiConverter.jar automatically in common locations
3
+ */
4
+ export declare function findBibleMultiConverterJar(providedPath?: string): Promise<string | null>;
5
+ /**
6
+ * Prompts user for BibleMultiConverter.jar location
7
+ */
8
+ export declare function promptForBibleMultiConverter(): Promise<string | null>;
9
+ /**
10
+ * Converts USFM directory to USX3 using BibleMultiConverter
11
+ */
12
+ export declare function convertUsfmToUsx3(inputDir: string, outputDir: string, jarPath: string): Promise<boolean>;
13
+ //# sourceMappingURL=conversion.d.ts.map
@@ -0,0 +1,157 @@
1
+ import { PrismaClient } from './prisma-gen/index.js';
2
+ import { Database } from 'better-sqlite3';
3
+ import { DatasetCommentary, DatasetCommentaryBook, DatasetCommentaryProfile, DatasetDataset, DatasetDatasetBook, DatasetOutput, DatasetTranslation, DatasetTranslationBook } from '@helloao/tools/generation/dataset.js';
4
+ import { InputFile, TranslationBookChapter, CommentaryBookChapter, DatasetBookChapter } from '@helloao/tools/generation/index.js';
5
+ import { GenerateApiOptions } from '@helloao/tools/generation/api.js';
6
+ import type { DOMParser } from 'linkedom';
7
+ import { Readable } from 'stream';
8
+ export declare function getMigrationsPath(): Promise<string | null>;
9
+ /**
10
+ * Imports the translations from the given directories into the database.
11
+ * @param db The database to import the translations into.
12
+ * @param dirs The directories to import the translations from.
13
+ * @param parser The DOM parser that should be used for USX files.
14
+ * @param overwrite Whether to force a reload of the translations.
15
+ */
16
+ export declare const importTranslations: (db: Database, dirs: string[], parser: DOMParser, overwrite: boolean) => Promise<void>;
17
+ /**
18
+ * Imports the commentaries from the given directories into the database.
19
+ * @param db The database to import the commentaries into.
20
+ * @param dirs The directories to import the commentaries from.
21
+ * @param parser The DOM parser that should be used for USX files.
22
+ * @param overwrite Whether to force a reload of the commentaries.
23
+ */
24
+ export declare const importCommentaries: (db: Database, dirs: string[], parser: DOMParser, overwrite: boolean) => Promise<void>;
25
+ /**
26
+ * Imports the files from the given directories into the database.
27
+ * @param loadFilesFromDir The function that should be used to load the files from the given directory.
28
+ * @param db The database to import the files into.
29
+ * @param dirs The directories to import the files from.
30
+ * @param parser The DOM parser that should be used for USX files.
31
+ * @param overwrite Whether to force a reload of the files.
32
+ */
33
+ export declare function importFiles(loadFilesFromDir: (path: string) => Promise<InputFile[] | null>, db: Database, dirs: string[], parser: DOMParser, overwrite: boolean): Promise<void>;
34
+ /**
35
+ * Imports a batch of translations from the given directories into the database.
36
+ * @param db The database to import the translations into.
37
+ * @param dirs The directories that contain the translations.
38
+ * @param parser The DOM parser that should be used for USX files.
39
+ * @param overwrite Whether to force a reload of the translations.
40
+ */
41
+ export declare const importTranslationBatch: (db: Database, dirs: string[], parser: DOMParser, overwrite: boolean) => Promise<void>;
42
+ /**
43
+ * Imports a batch of files from the given directories into the database.
44
+ * @param loadFilesFromDir The function that should be used to load the files from the given directory.
45
+ * @param db The database to import the files into.
46
+ * @param dirs The directories that contain the files.
47
+ * @param parser The DOM parser that should be used for USX files.
48
+ * @param overwrite Whether to force a reload of the files.
49
+ */
50
+ export declare function loadAndImportBatch(loadFilesFromDir: (path: string) => Promise<InputFile[] | null>, db: Database, dirs: string[], parser: DOMParser, overwrite: boolean): Promise<void>;
51
+ /**
52
+ * Parses and imports the given files into the database.
53
+ * @param db The database to import the files into.
54
+ * @param files The files that should be parsed.
55
+ * @param parser The DOM parser that should be used for USX files.
56
+ * @param overwrite Whether to force a reload of the translations.
57
+ */
58
+ export declare function importFileBatch(db: Database, files: InputFile[], parser: DOMParser, overwrite: boolean): Promise<void>;
59
+ /**
60
+ * Imports the given dataset output into the database.
61
+ * @param db The database to import the dataset into.
62
+ * @param output The dataset output to import.
63
+ */
64
+ export declare function importDatasetOutput(db: Database, output: DatasetOutput): void;
65
+ /**
66
+ * Filters the given input files to only include those that have changed.
67
+ * @param db The database to check for changes.
68
+ * @param files The files to filter.
69
+ */
70
+ export declare function getChangedOrNewInputFiles(db: Database, files: InputFile[]): InputFile[];
71
+ export declare function insertFileMetadata(db: Database, files: InputFile[]): void;
72
+ export declare function insertTranslations(db: Database, translations: DatasetTranslation[]): void;
73
+ export declare function insertTranslationBooks(db: Database, translation: DatasetTranslation, translationBooks: DatasetTranslationBook[]): void;
74
+ export declare function insertTranslationContent(db: Database, translation: DatasetTranslation, book: DatasetTranslationBook, chapters: TranslationBookChapter[]): void;
75
+ export declare function insertCommentaries(db: Database, commentaries: DatasetCommentary[]): void;
76
+ export declare function insertCommentaryBooks(db: Database, commentary: DatasetCommentary, commentaryBooks: DatasetCommentaryBook[]): void;
77
+ export declare function insertCommentaryProfiles(db: Database, commentary: DatasetCommentary, commentaryProfiles: DatasetCommentaryProfile[]): void;
78
+ export declare function insertCommentaryContent(db: Database, commentary: DatasetCommentary, book: DatasetCommentaryBook, chapters: CommentaryBookChapter[]): void;
79
+ export declare function insertDatasets(db: Database, datasets: DatasetDataset[]): void;
80
+ export declare function insertDatasetBooks(db: Database, dataset: DatasetDataset, datasetBooks: DatasetDatasetBook[]): void;
81
+ export declare function insertDatasetContent(db: Database, dataset: DatasetDataset, book: DatasetDatasetBook, chapters: DatasetBookChapter[]): void;
82
+ export declare function getDbPathFromDir(dir: string): string;
83
+ export declare function getDbPath(p?: string | null): string;
84
+ export declare function getPrismaDb(path?: string | null): PrismaClient<{
85
+ datasources: {
86
+ db: {
87
+ url: string;
88
+ };
89
+ };
90
+ }, never, import("prisma-gen/runtime/library.js").DefaultArgs>;
91
+ /**
92
+ * Gets the database from the given path. If no path is provided, the current working directory is used.
93
+ * @param path The path to the database. If not provided, the current working directory is used.
94
+ * @returns
95
+ */
96
+ export declare function getDb(path?: string | null): Promise<Database>;
97
+ export interface SerializedFile {
98
+ path: string;
99
+ content: string | Readable;
100
+ /**
101
+ * Gets the base64-encoded SHA256 hash of the content of the file.
102
+ */
103
+ sha256?(): string;
104
+ }
105
+ /**
106
+ * Loads the datasets from the database in a series of batches.
107
+ * @param db The database.
108
+ * @param perBatch The number of translations to load per batch.
109
+ * @param translationsToLoad The list of translations/commentaries to load. If not provided, all translations will be loaded.
110
+ */
111
+ export declare function loadDatasets(db: PrismaClient, perBatch?: number, translationsToLoad?: string[]): AsyncGenerator<DatasetOutput>;
112
+ /**
113
+ * Loads the translations from the database as a dataset.
114
+ * @param db The database.
115
+ * @param translationsPerBatch The number of translations to load per batch.
116
+ * @param translationsToLoad The list of translations to load. If not provided, all translations will be loaded.
117
+ */
118
+ export declare function loadTranslationDatasets(db: PrismaClient, translationsPerBatch?: number, translationsToLoad?: string[]): AsyncGenerator<DatasetOutput, void, unknown>;
119
+ /**
120
+ * Loads the commentaries from the database as a dataset.
121
+ * @param db The database.
122
+ * @param perBatch The number of translations to load per batch.
123
+ * @param commentariesToLoad The list of commentaries to load. If not provided, all commentaries will be loaded.
124
+ */
125
+ export declare function loadCommentaryDatasets(db: PrismaClient, perBatch?: number, commentariesToLoad?: string[]): AsyncGenerator<DatasetOutput, void, unknown>;
126
+ /**
127
+ * Loads the datasets from the database as a dataset.
128
+ * @param db The database.
129
+ * @param perBatch The number of translations to load per batch.
130
+ * @param datasetsToLoad The list of commentaries to load. If not provided, all commentaries will be loaded.
131
+ */
132
+ export declare function loadDatasetDatasets(db: PrismaClient, perBatch?: number, datasetsToLoad?: string[]): AsyncGenerator<DatasetOutput, void, unknown>;
133
+ export interface SerializeApiOptions extends GenerateApiOptions {
134
+ /**
135
+ * Whether the output should be pretty-printed.
136
+ */
137
+ pretty?: boolean;
138
+ }
139
+ /**
140
+ * Generates and serializes the API files for the datasets that are stored in the database.
141
+ * Yields each batch of serialized files.
142
+ * @param db The database that the dataset should be loaded from.
143
+ * @param options The options to use for serializing the files.
144
+ * @param apiOptions The options to use for generating the API files.
145
+ * @param translationsPerBatch The number of translations that should be loaded and written per batch.
146
+ * @param translations The list of translations that should be loaded. If not provided, all translations will be loaded.
147
+ */
148
+ export declare function serializeFilesFromDatabase(db: PrismaClient, options?: SerializeApiOptions, translationsPerBatch?: number, translations?: string[]): AsyncGenerator<SerializedFile[]>;
149
+ /**
150
+ * Generates and serializes the API files for the given datasets.
151
+ * Yields each batch of serialized files.
152
+ *
153
+ * @param datasets The datasets to serialize.
154
+ * @param options The options to use for generating and serializing the files.
155
+ */
156
+ export declare function serializeDatasets(datasets: AsyncIterable<DatasetOutput>, options?: SerializeApiOptions): AsyncGenerator<SerializedFile[]>;
157
+ //# sourceMappingURL=db.d.ts.map
@@ -0,0 +1,14 @@
1
+ import { Entry, ZipReader } from '@zip.js/zip.js';
2
+ export declare function downloadFile(url: string, path: string, onProgress?: (progress: number) => void): Promise<void>;
3
+ export declare function downloadResponse(response: Response, path: string, onProgress?: (progress: number) => void): Promise<void>;
4
+ /**
5
+ * Unzips a ZipReader to a specified directory.
6
+ * @param zip The ZipReader instance to read from.
7
+ * @param directory The directory to unzip files into.
8
+ * @param overwrite Wether to overwrite existing files.
9
+ * @param entryFilter A filter function to determine which entries to unzip.
10
+ * @param closeWhenDone Whether to close the ZipReader when done.
11
+ * @returns The number of files that matched the entry filter.
12
+ */
13
+ export declare function unzipToDirectory(zip: ZipReader<unknown>, directory: string, overwrite: boolean, entryFilter?: (entry: Entry) => boolean, closeWhenDone?: boolean): Promise<number>;
14
+ //# sourceMappingURL=downloads.d.ts.map
@@ -0,0 +1,6 @@
1
+ import { EBibleSource } from 'prisma-gen/index.js';
2
+ /**
3
+ * Fetches eBible translation metadata and returns EBibleSource objects.
4
+ */
5
+ export declare function fetchEBibleMetadata(): Promise<EBibleSource[]>;
6
+ //# sourceMappingURL=ebible.d.ts.map
@@ -0,0 +1,136 @@
1
+ import { InputFile, InputTranslationMetadata, OutputFile } from '@helloao/tools/generation/common-types.js';
2
+ import { Readable } from 'stream';
3
+ import { DatasetDataset } from '@helloao/tools/generation/dataset.js';
4
+ /**
5
+ * Defines an interface that contains information about a serialized file.
6
+ */
7
+ export interface Uploader {
8
+ /**
9
+ * Gets the ideal batch size for the uploader.
10
+ * Null if the uploader does not need batching.
11
+ */
12
+ idealBatchSize: number | null;
13
+ /**
14
+ * Uploads the given file.
15
+ * @param file The file to upload.
16
+ * @param overwrite Whether the file should be overwritten if it already exists.
17
+ * @returns True if the file was uploaded. False if the file was skipped due to already existing.
18
+ */
19
+ upload(file: SerializedFile, overwrite: boolean): Promise<boolean>;
20
+ /**
21
+ * Disposes resources that the uploader uses.
22
+ */
23
+ dispose?(): Promise<void>;
24
+ }
25
+ /**
26
+ * Defines an interface for a file that has been serialized.
27
+ */
28
+ export interface SerializedFile {
29
+ path: string;
30
+ content: string | Readable;
31
+ /**
32
+ * Gets the base64-encoded SHA256 hash of the content of the file.
33
+ */
34
+ sha256?(): string;
35
+ }
36
+ /**
37
+ * The options for serializing API files.
38
+ */
39
+ export interface SerializeApiOptions {
40
+ /**
41
+ * Whether the output should be pretty-printed.
42
+ */
43
+ pretty?: boolean;
44
+ }
45
+ /**
46
+ * Serializes the given output files into serialized files using the given options.
47
+ *
48
+ * Each iteration of the given files will be processed as a batch, and any mergable files will automatically be merged together and serialized in the final batch.
49
+ *
50
+ * @param files The files that should be serialized.
51
+ * @param options The options for serialization.
52
+ */
53
+ export declare function serializeOutputFiles(files: AsyncIterable<OutputFile[]>, options: SerializeApiOptions): AsyncGenerator<SerializedFile[]>;
54
+ /**
55
+ * Serializes the given output file content into a serialized file.
56
+ * @param path The path that the file should be saved to.
57
+ * @param content The content of the file.
58
+ * @param options The options for serialization.
59
+ */
60
+ export declare function serializeFile(path: string, content: OutputFile['content'], options: SerializeApiOptions): Promise<SerializedFile | null>;
61
+ /**
62
+ * Loads the files for the given translations.
63
+ * @param dir The directory that the translations exist in.
64
+ */
65
+ export declare function loadTranslationsFiles(dirs: string[]): Promise<InputFile[]>;
66
+ /**
67
+ * Loads the files for the given translation.
68
+ * @param translation The directory that the translation exists in.
69
+ * @returns The list of files that were loaded, or null if the translation has no metadata.
70
+ */
71
+ export declare function loadTranslationFiles(translation: string, translationMetadata?: InputTranslationMetadata): Promise<InputFile[] | null>;
72
+ /**
73
+ * Loads the files for the given commentaries.
74
+ * @param dir The directory that the commentaries exist in.
75
+ */
76
+ export declare function loadCommentariesFiles(dirs: string[]): Promise<InputFile[]>;
77
+ /**
78
+ * Loads the files for the given commentary.
79
+ * @param commentary The directory that the commentary exists in.
80
+ * @returns The list of files that were loaded, or null if the commentary has no metadata.
81
+ */
82
+ export declare function loadCommentaryFiles(commentary: string): Promise<InputFile[] | null>;
83
+ /**
84
+ * Imports all the datasets from the given directory into the database in the current working directory.
85
+ * @param dir The directory that the datasets are located in.
86
+ * @param options The options.
87
+ */
88
+ export declare function loadDatasetsFromDirectory(dir: string): Promise<DatasetDataset[]>;
89
+ export interface CollectionTranslationMetadata {
90
+ name: {
91
+ local: string;
92
+ abbrev: string;
93
+ english: string;
94
+ };
95
+ language: string;
96
+ year: number;
97
+ direction: 'ltr' | 'rtl';
98
+ copyright: {
99
+ licenses: any[];
100
+ attribution: string;
101
+ attribution_url: string;
102
+ };
103
+ id: string | null;
104
+ source: {
105
+ id: string;
106
+ };
107
+ }
108
+ /**
109
+ * Defines an uploader that is able to upload files to a directory.
110
+ */
111
+ export declare class FilesUploader implements Uploader {
112
+ private _dir;
113
+ constructor(dir: string);
114
+ get idealBatchSize(): number | null;
115
+ upload(file: SerializedFile, overwrite: boolean): Promise<boolean>;
116
+ }
117
+ /**
118
+ * Defines an uploader that is able to upload files into a zip file.
119
+ */
120
+ export declare class ZipUploader implements Uploader {
121
+ private _path;
122
+ private _initPromise;
123
+ private _fileHandle;
124
+ private _zip;
125
+ constructor(filePath: string);
126
+ private _init;
127
+ get idealBatchSize(): number | null;
128
+ upload(file: SerializedFile, _overwrite: boolean): Promise<boolean>;
129
+ dispose(): Promise<void>;
130
+ }
131
+ /**
132
+ * Calculates the SHa256 hash of the given input files.
133
+ * @param files The files to hash.
134
+ */
135
+ export declare function hashInputFiles(files: InputFile[]): string;
136
+ //# sourceMappingURL=files.d.ts.map
@@ -0,0 +1,8 @@
1
+ import * as db from './db.js';
2
+ import * as downloads from './downloads.js';
3
+ import * as uploads from './uploads.js';
4
+ import * as actions from './actions.js';
5
+ import * as files from './files.js';
6
+ import * as s3 from './s3.js';
7
+ export { db, downloads, uploads, actions, files, s3 };
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,44 @@
1
+ import { SerializedFile, Uploader } from './files.js';
2
+ import { AwsCredentialIdentity, Provider } from '@smithy/types';
3
+ export declare class S3Uploader implements Uploader {
4
+ private _client;
5
+ private _bucketName;
6
+ private _keyPrefix;
7
+ get idealBatchSize(): number;
8
+ constructor(bucketName: string, keyPrefix: string, profile: string | null | AwsCredentialIdentity | Provider<AwsCredentialIdentity>, region?: string);
9
+ upload(file: SerializedFile, overwrite: boolean): Promise<boolean>;
10
+ }
11
+ /**
12
+ * Parses the given S3 URL into its bucket name and object key.
13
+ * @param url The URL to parse.
14
+ */
15
+ export declare function parseS3Url(url: string): {
16
+ bucketName: string;
17
+ objectKey: string;
18
+ } | undefined;
19
+ /**
20
+ * Gets the HTTP URL for the given S3 URL.
21
+ * @param s3Url The S3 URL to convert.
22
+ */
23
+ export declare function getHttpUrl(s3Url: string): string | undefined;
24
+ /**
25
+ * A provider that gets the credentials directly from the user input.
26
+ */
27
+ export declare const askForAccessKeyProvider: Provider<AwsCredentialIdentity>;
28
+ /**
29
+ * Defines a provider that tries to get the credentials from the given list of providers.
30
+ * @param providers The providers to try.
31
+ */
32
+ export declare function providerChain(...providers: Provider<AwsCredentialIdentity>[]): Provider<AwsCredentialIdentity>;
33
+ /**
34
+ * Gets the default provider for the given options.
35
+ *
36
+ * Defaults first to using the provided access key and secret access key, then to using the given profile, then finally to asking the user for the access key.
37
+ * @param options
38
+ */
39
+ export declare function defaultProviderForOptions(options: {
40
+ accessKeyId?: string;
41
+ secretAccessKey?: string;
42
+ profile?: string;
43
+ }): Provider<AwsCredentialIdentity> | AwsCredentialIdentity;
44
+ //# sourceMappingURL=s3.d.ts.map