import { EnqueueFilesResult, CheckFileTranslationsOptions, DownloadFileBatchOptions, DownloadFileBatchResult, DownloadFileOptions } from './types'; import { SetupProjectResult, SetupProjectOptions, type SetupProjectFileReference } from './translate/setupProject'; import { type EnqueueFilesOptions } from './translate/enqueueFiles'; import { CreateTagOptions, CreateTagResult } from './translate/createTag'; import { FileQuery, FileQueryResult } from './types-dir/api/checkFileTranslations'; import { SubmitUserEditDiffsPayload } from './translate/submitUserEditDiffs'; import { FileUpload, UploadFilesOptions, UploadFilesResponse } from './types-dir/api/uploadFiles'; import { ProjectData } from './types-dir/api/project'; import { DownloadFileBatchRequest } from './types-dir/api/downloadFileBatch'; import { CheckJobStatusResult } from './translate/checkJobStatus'; import { AwaitJobsOptions, AwaitJobsResult } from './translate/awaitJobs'; import type { FileDataQuery, FileDataResult } from './translate/queryFileData'; import type { GetProjectInfoOptions, ProjectInfoResult } from './translate/getProjectInfo'; import type { BranchQuery } from './translate/queryBranchData'; import type { BranchDataResult } from './types-dir/api/branch'; import type { CreateBranchQuery, CreateBranchResult } from './translate/createBranch'; import type { FileReferenceIds } from './types-dir/api/file'; import { type MoveMapping, type ProcessMovesResponse, type ProcessMovesOptions } from './translate/processFileMoves'; import { type GetOrphanedFilesResult } from './translate/getOrphanedFiles'; import { type PublishFileEntry, type PublishFilesResult } from './translate/publishFiles'; import { GTRuntime } from './runtime'; export { GTRuntime, type GTConstructorParams } from './runtime'; export { decodeVars } from './derive/decodeVars'; export { declareVar } from './derive/declareVar'; export { derive } from './derive/derive'; export { LocaleConfig, type LocaleConfigConstructorParams, } from '@generaltranslation/format'; export { determineLocale, formatCurrency, formatCutoff, formatDateTime, formatList, formatListToParts, formatMessage, formatNum, formatRelativeTime, formatRelativeTimeFromDate, getLocaleDirection, getLocaleEmoji, getLocaleName, getLocaleProperties, getRegionProperties, isSameDialect, isSameLanguage, isSupersetLocale, isValidLocale, requiresTranslation, resolveAliasLocale, resolveCanonicalLocale, standardizeLocale, } from '@generaltranslation/format'; /** * GT is the core driver for the General Translation library. * It extends {@link GTRuntime} (locale management, formatting, and runtime * translation) with the project and file management API client used by * tooling such as the CLI. * * Browser-facing SDK code should construct {@link GTRuntime} instead so * production bundles do not ship the file management client. * * @class GT * @description A comprehensive toolkit for handling internationalization and localization. * * @example * const gt = new GT({ * sourceLocale: 'en-US', * targetLocale: 'es-ES', * locales: ['en-US', 'es-ES', 'fr-FR'] * }); */ export declare class GT extends GTRuntime { /** * Queries branch information from the API. * * @param {BranchQuery} query - Object mapping the current branch and incoming branches * @returns {Promise} The branch information. */ queryBranchData(query: BranchQuery): Promise; /** * Creates a new branch in the API. If the branch already exists, it will be returned. * * @param {CreateBranchQuery} query - Object mapping the branch name and default branch flag * @returns {Promise} The created branch information. */ createBranch(query: CreateBranchQuery): Promise; /** * Processes file moves by cloning source files and translations with new fileIds. * This is called when files have been moved/renamed and we want to preserve translations. * * @param {MoveMapping[]} moves - Array of move mappings (old fileId to new fileId) * @param {ProcessMovesOptions} options - Options including branchId and timeout * @returns {Promise} The move processing results. * * @example * const result = await gt.processFileMoves([ * { oldFileId: 'abc123', newFileId: 'def456', newFileName: 'locales/en.json' } * ], { branchId: 'main' }); */ processFileMoves(moves: MoveMapping[], options?: ProcessMovesOptions): Promise; /** * Gets orphaned files for a branch - files that exist on the branch * but whose fileIds are not in the provided list. * Used for move detection. * * @param {string} branchId - The branch to check for orphaned files. * @param {string[]} fileIds - List of current file IDs (files that are NOT orphaned) * @param {Object} options - Options including timeout. * @returns {Promise} The orphaned files. * * @example * const result = await gt.getOrphanedFiles('branch-id', ['file-1', 'file-2']); */ getOrphanedFiles(branchId: string, fileIds: string[], options?: { timeout?: number; }): Promise; /** * Enqueues project setup job using the specified file references * * This method creates setup jobs that will process source file references * and generate a project setup. The files parameter contains references (IDs) to source * files that have already been uploaded via uploadSourceFiles. The setup jobs are queued * for processing and will generate a project setup based on the source files. * * @param {SetupProjectFileReference[]} files - Array of file references containing IDs of previously uploaded source files * @param {SetupProjectOptions} [options] - Optional settings for target locales and timeout. * @returns {Promise} Object containing the jobId and status */ setupProject(files: SetupProjectFileReference[], options?: SetupProjectOptions): Promise; /** * Checks the current status of one or more project jobs by their unique identifiers. * * This method polls the API to determine whether one or more jobs are still running, * have completed successfully, or have failed. Jobs are created after calling either enqueueFiles or setupProject. * * @param {string[]} jobIds - The unique identifiers of the jobs to check. * @param {number} [timeoutMs] - Optional timeout in milliseconds for the API request. * @returns {Promise} Object containing the job status. * * @example * const result = await gt.checkJobStatus([ * 'job-123', * 'job-456', * ], 10000); */ checkJobStatus(jobIds: string[], timeoutMs?: number): Promise; /** * Polls job statuses until all jobs from enqueueFiles are finished or the timeout is reached. * * @param {EnqueueFilesResult} enqueueResult - The result returned from enqueueFiles. * @param {AwaitJobsOptions} [options] - Polling configuration (interval, timeout). * @returns {Promise} The final status of all jobs and whether they all completed. */ awaitJobs(enqueueResult: EnqueueFilesResult, options?: AwaitJobsOptions): Promise; /** * Enqueues translation jobs for previously uploaded source files. * * This method creates translation jobs that will process existing source files * and generate translations in the specified target languages. The files parameter * contains references (IDs) to source files that have already been uploaded via * uploadSourceFiles. The translation jobs are queued for processing and will * generate translated content based on the source files and target locales provided. * * @param {FileReferenceIds[]} files - Array of file references containing IDs of previously uploaded source files * @param {EnqueueFilesOptions} options - Configuration options including source locale, target locales, and job settings. * @returns {Promise} Result containing job IDs, queue status, and processing information. */ enqueueFiles(files: FileReferenceIds[], options: EnqueueFilesOptions): Promise; /** * Creates or upserts a file tag, associating a set of source files * with a user-defined tag ID and optional message. * * @param {CreateTagOptions} options - Tag creation options including tagId, sourceFileIds, and optional message * @returns {Promise} The created or updated tag. */ createTag(options: CreateTagOptions): Promise; /** * Publishes or unpublishes files on the CDN. * * @param {PublishFileEntry[]} files - Array of file entries with publish flags * @returns {Promise} Result containing per-file success/failure */ publishFiles(files: PublishFileEntry[]): Promise; /** * Submits user edit diffs for existing translations so future generations preserve user intent. * * @param {SubmitUserEditDiffsPayload} payload - Project-scoped diff payload. * @returns {Promise} Resolves when submission succeeds. */ submitUserEditDiffs(payload: SubmitUserEditDiffsPayload): Promise; /** * Queries data about one or more source or translation files. * * @param {FileDataQuery} data - Object mapping source and translation file information. * @param {CheckFileTranslationsOptions} options - Options for the API call. * @returns {Promise} The source and translation file data information. * * @example * const result = await gt.queryFileData({ * sourceFiles: [ * { fileId: '1234567890', versionId: '1234567890', branchId: '1234567890' }, * ], * translatedFiles: [ * { fileId: '1234567890', versionId: '1234567890', branchId: '1234567890', locale: 'es-ES' }, * ], * }, { * timeout: 10000, * }); * */ /** * Fetches project info (name, locales, review settings) for the * authenticated project. * @param options - The options for the API call. * @returns The project info. */ getProjectInfo(options?: GetProjectInfoOptions): Promise; queryFileData(data: FileDataQuery, options?: CheckFileTranslationsOptions): Promise; /** * Gets source and translation information for a given file ID and version ID. * * @param {FileQuery} data - File query containing file ID and version ID. * @param {CheckFileTranslationsOptions} options - Options for getting source and translation information. * @returns {Promise} The source file and translation information. * * @example * const result = await gt.querySourceFile( * { fileId: '1234567890', versionId: '1234567890' }, * { timeout: 10000 } * ); * */ querySourceFile(data: FileQuery, options?: CheckFileTranslationsOptions): Promise; /** * Get project data for a given project ID. * * @param {string} projectId - The ID of the project to get the data for. * @returns {Promise} The project data. * * @example * const result = await gt.getProjectData( * '1234567890' * ); * */ getProjectData(projectId: string, options?: { timeout?: number; }): Promise; /** * Downloads a single file. * * @param file - The file query object. * @param {string} file.fileId - The ID of the file to download. * @param {string} [file.branchId] - The ID of the branch to download the file from. If not provided, the default branch will be used. * @param {string} [file.locale] - The locale to download the file for. If not provided, the source file will be downloaded. * @param {string} [file.versionId] - The version ID to download the file from. If not provided, the latest version will be used. * @param {DownloadFileOptions} options - Options for downloading the file. * @returns {Promise} The downloaded file content. * * @example * const result = await gt.downloadFile({ * fileId: '1234567890', * branchId: '1234567890', * locale: 'es-ES', * versionId: '1234567890', * }, { * timeout: 10000, * }); */ downloadFile(file: { fileId: string; branchId?: string; locale?: string; versionId?: string; useLatestAvailableVersion?: boolean; }, options?: DownloadFileOptions): Promise; /** * Downloads multiple files in a batch. * * @param {DownloadFileBatchRequest} requests - Array of file query objects to download. * @param {DownloadFileBatchOptions} options - Options for the batch download. * @returns {Promise} The batch download results. * * @example * const result = await gt.downloadFileBatch([{ * fileId: '1234567890', * locale: 'es-ES', * versionId: '1234567890', * }], { * timeout: 10000, * }); */ downloadFileBatch(requests: DownloadFileBatchRequest, options?: DownloadFileBatchOptions): Promise; /** * Uploads source files to the translation service without any translation content. * * This method creates or replaces source file entries in your project. Each uploaded * file becomes a source that can later be translated into target languages. The files * are processed and stored as base entries that serve as the foundation for generating * translations through the translation workflow. * * @param {Array<{source: FileUpload}>} files - Array of objects containing source file data to upload * @param {UploadFilesOptions} options - Configuration options including source locale and other upload settings. * @returns {Promise} Upload result containing file IDs, version information, and upload status. */ uploadSourceFiles(files: { source: FileUpload; }[], options: UploadFilesOptions): Promise; /** * Uploads translation files that correspond to previously uploaded source files. * * This method allows you to provide translated content for existing source files in your project. * Each translation must reference an existing source file and include the translated content * along with the target locale information. This is used when you have pre-existing translations * that you want to upload directly rather than generating them through the translation service. * * @param {Array<{source: FileUpload, translations: FileUpload[]}>} files - Array of file objects where: * - `source`: Reference to the existing source file (contains IDs but no content). * - `translations`: Array of translated files, each containing content, locale, and reference IDs * @param {UploadFilesOptions} options - Configuration options including source locale and upload settings. * @returns {Promise} Upload result containing translation IDs, status, and processing information. */ uploadTranslations(files: { source: FileUpload; translations: FileUpload[]; }[], options: UploadFilesOptions): Promise; }