generaltranslation 7.5.0 → 7.6.1

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.
package/dist/index.d.ts CHANGED
@@ -1,10 +1,14 @@
1
- import { CustomMapping, FormatVariables, I18nextMessage, IcuMessage, TranslateManyResult, TranslationError, TranslationResult, Updates, EnqueueEntriesOptions, EnqueueEntriesResult, EnqueueFilesOptions, EnqueueFilesResult, FileToTranslate, CheckFileTranslationsOptions, CheckFileTranslationsResult, DownloadFileBatchOptions, DownloadFileBatchResult, FetchTranslationsOptions, FetchTranslationsResult, DownloadFileOptions, EntryMetadata, Entry } from './types';
1
+ import { CustomMapping, FormatVariables, I18nextMessage, IcuMessage, TranslateManyResult, TranslationError, TranslationResult, Updates, EnqueueEntriesOptions, EnqueueEntriesResult, EnqueueFilesResult, CheckFileTranslationsOptions, CheckFileTranslationsResult, DownloadFileBatchOptions, DownloadFileBatchResult, FetchTranslationsOptions, FetchTranslationsResult, DownloadFileOptions, EntryMetadata, Entry } from './types';
2
2
  import { LocaleProperties } from './locales/getLocaleProperties';
3
3
  import { JsxChildren } from './internal';
4
+ import { SetupProjectResult } from './translate/setupProject';
5
+ import { CheckSetupStatusResult } from './translate/checkSetupStatus';
6
+ import { ShouldSetupProjectResult } from './translate/shouldSetupProject';
7
+ import { EnqueueOptions } from './translate/enqueueFiles';
4
8
  import { FileTranslationQuery } from './types-dir/checkFileTranslations';
5
9
  import { CheckTranslationStatusOptions, TranslationStatusResult } from './types-dir/translationStatus';
6
10
  import { CustomRegionMapping } from './locales/getRegionProperties';
7
- import { FileUpload, UploadFilesOptions } from './types-dir/uploadFiles';
11
+ import { FileUpload, FileUploadRef, UploadFilesOptions, UploadFilesResponse } from './types-dir/uploadFiles';
8
12
  /**
9
13
  * Type representing the constructor parameters for the GT class.
10
14
  * @typedef {Object} GTConstructorParams
@@ -115,34 +119,53 @@ export declare class GT {
115
119
  */
116
120
  enqueueEntries(updates: Updates, options?: EnqueueEntriesOptions): Promise<EnqueueEntriesResult>;
117
121
  /**
118
- * Enqueues files for translation processing.
122
+ * Enqueues project setup job using the specified file references
119
123
  *
120
- * @param {FileToTranslate[]} files - Array of files to enqueue for translation.
121
- * @param {EnqueueFilesOptions} options - Options for enqueueing files.
122
- * @returns {Promise<EnqueueFilesResult>} The result of the enqueue operation.
124
+ * This method creates setup jobs that will process source file references
125
+ * and generate a project setup. The files parameter contains references (IDs) to source
126
+ * files that have already been uploaded via uploadSourceFiles. The setup jobs are queued
127
+ * for processing and will generate a project setup based on the source files.
123
128
  *
124
- * @example
125
- * const gt = new GT({
126
- * sourceLocale: 'en-US',
127
- * targetLocale: 'es-ES',
128
- * locales: ['en-US', 'es-ES', 'fr-FR']
129
- * });
129
+ * @param {FileUploadRef[]} files - Array of file references containing IDs of previously uploaded source files
130
+ * @param {number} [timeoutMs] - Optional timeout in milliseconds for the API request
131
+ * @returns {Promise<SetupProjectResult>} Object containing the jobId and status
132
+ */
133
+ setupProject(files: FileUploadRef[], timeoutMs?: number): Promise<SetupProjectResult>;
134
+ /**
135
+ * Checks the current status of a project setup job by its unique identifier.
130
136
  *
131
- * const result = await gt.enqueueFiles([
132
- * {
133
- * content: 'Hello, world!',
134
- * fileName: 'Button.tsx',
135
- * fileFormat: 'TS',
136
- * dataFormat: 'JSX',
137
- * },
138
- * ], {
139
- * sourceLocale: 'en-US',
140
- * targetLocales: ['es-ES', 'fr-FR'],
141
- * publish: true,
142
- * description: 'Translations for the Button component',
143
- * });
137
+ * This method polls the API to determine whether a setup job is still running,
138
+ * has completed successfully, or has failed. Setup jobs are created when
139
+ * uploading source files to initialize project translation workflows.
140
+ *
141
+ * @param {string} jobId - The unique identifier of the setup job to check
142
+ * @param {number} [timeoutMs] - Optional timeout in milliseconds for the API request
143
+ * @returns {Promise<CheckSetupStatusResult>} Object containing the job status
144
+ */
145
+ checkSetupStatus(jobId: string, timeoutMs?: number): Promise<CheckSetupStatusResult>;
146
+ /**
147
+ * Checks if a prpject requires setup.
148
+ *
149
+ * This method queries API to check if a project has been set up and returns
150
+ * true if setup is missing
151
+ *
152
+ * @returns {Promise<ShouldSetupProjectResult>} Object containing shouldSetupProject
153
+ */
154
+ shouldSetupProject(): Promise<ShouldSetupProjectResult>;
155
+ /**
156
+ * Enqueues translation jobs for previously uploaded source files.
157
+ *
158
+ * This method creates translation jobs that will process existing source files
159
+ * and generate translations in the specified target languages. The files parameter
160
+ * contains references (IDs) to source files that have already been uploaded via
161
+ * uploadSourceFiles. The translation jobs are queued for processing and will
162
+ * generate translated content based on the source files and target locales provided.
163
+ *
164
+ * @param {FileUploadRef[]} files - Array of file references containing IDs of previously uploaded source files
165
+ * @param {EnqueueOptions} options - Configuration options including source locale, target locales, and job settings
166
+ * @returns {Promise<EnqueueFilesResult>} Result containing job IDs, queue status, and processing information
144
167
  */
145
- enqueueFiles(files: FileToTranslate[], options: EnqueueFilesOptions): Promise<EnqueueFilesResult>;
168
+ enqueueFiles(files: FileUploadRef[], options: EnqueueOptions): Promise<EnqueueFilesResult>;
146
169
  /**
147
170
  * Checks the translation status of files.
148
171
  *
@@ -174,6 +197,7 @@ export declare class GT {
174
197
  * @returns {Promise<TranslationStatusResult>} The translation status of the version.
175
198
  *
176
199
  * @example
200
+ * @deprecated Use the {@link checkFileTranslations} method instead. Will be removed in v7.0.0.
177
201
  * const gt = new GT({
178
202
  * sourceLocale: 'en-US',
179
203
  * targetLocale: 'es-ES',
@@ -319,10 +343,39 @@ export declare class GT {
319
343
  translateMany(sources: Entry[], globalMetadata?: {
320
344
  targetLocale: string;
321
345
  } & EntryMetadata): Promise<TranslateManyResult>;
322
- uploadFiles(files: {
346
+ /**
347
+ * Uploads source files to the translation service without any translation content.
348
+ *
349
+ * This method creates or replaces source file entries in your project. Each uploaded
350
+ * file becomes a source that can later be translated into target languages. The files
351
+ * are processed and stored as base entries that serve as the foundation for generating
352
+ * translations through the translation workflow.
353
+ *
354
+ * @param {Array<{source: FileUpload}>} files - Array of objects containing source file data to upload
355
+ * @param {UploadFilesOptions} options - Configuration options including source locale and other upload settings
356
+ * @returns {Promise<UploadFilesResponse>} Upload result containing file IDs, version information, and upload status
357
+ */
358
+ uploadSourceFiles(files: {
359
+ source: FileUpload;
360
+ }[], options: UploadFilesOptions): Promise<UploadFilesResponse>;
361
+ /**
362
+ * Uploads translation files that correspond to previously uploaded source files.
363
+ *
364
+ * This method allows you to provide translated content for existing source files in your project.
365
+ * Each translation must reference an existing source file and include the translated content
366
+ * along with the target locale information. This is used when you have pre-existing translations
367
+ * that you want to upload directly rather than generating them through the translation service.
368
+ *
369
+ * @param {Array<{source: FileUpload, translations: FileUpload[]}>} files - Array of file objects where:
370
+ * - `source`: Reference to the existing source file (contains IDs but no content)
371
+ * - `translations`: Array of translated files, each containing content, locale, and reference IDs
372
+ * @param {UploadFilesOptions} options - Configuration options including source locale and upload settings
373
+ * @returns {Promise<UploadFilesResponse>} Upload result containing translation IDs, status, and processing information
374
+ */
375
+ uploadTranslations(files: {
323
376
  source: FileUpload;
324
377
  translations: FileUpload[];
325
- }[], options: UploadFilesOptions): Promise<any>;
378
+ }[], options: UploadFilesOptions): Promise<UploadFilesResponse>;
326
379
  /**
327
380
  * Formats a message according to the specified locales and options.
328
381
  *