generaltranslation 9.5.5 → 9.5.7

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 (45) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/adapter/createGtApi.d.ts +2 -2
  3. package/dist/adapter/createGtApi.js +2 -2
  4. package/dist/{derive-CS-paSZ9.cjs → derive-DPDgh_1v.cjs} +4 -4
  5. package/dist/derive-DPDgh_1v.cjs.map +1 -0
  6. package/dist/{derive-Ctj9wXCT.mjs → derive-DZR18WqK.mjs} +4 -4
  7. package/dist/derive-DZR18WqK.mjs.map +1 -0
  8. package/dist/id.d.cts +1 -1
  9. package/dist/id.d.mts +1 -1
  10. package/dist/index.cjs +2 -2
  11. package/dist/index.d.cts +1 -1
  12. package/dist/index.d.mts +1 -1
  13. package/dist/index.mjs +2 -2
  14. package/dist/internal.cjs +3 -3
  15. package/dist/internal.cjs.map +1 -1
  16. package/dist/internal.d.cts +3 -3
  17. package/dist/internal.d.mts +3 -3
  18. package/dist/internal.mjs +3 -3
  19. package/dist/internal.mjs.map +1 -1
  20. package/dist/logging/errors.d.ts +0 -1
  21. package/dist/logging/errors.js +0 -9
  22. package/dist/runtime.cjs +1 -1
  23. package/dist/runtime.d.cts +1 -1
  24. package/dist/runtime.d.mts +1 -1
  25. package/dist/runtime.mjs +1 -1
  26. package/dist/{runtimeTranslate-_gLYFBvE.cjs → runtimeTranslate-B8BLxD_U.cjs} +3 -34
  27. package/dist/runtimeTranslate-B8BLxD_U.cjs.map +1 -0
  28. package/dist/{runtimeTranslate-CI936gg9.mjs → runtimeTranslate-CRWJMYly.mjs} +3 -34
  29. package/dist/runtimeTranslate-CRWJMYly.mjs.map +1 -0
  30. package/dist/translate/runtimeTranslate.js +1 -10
  31. package/dist/translate/utils/unwrapApiResult.d.ts +0 -3
  32. package/dist/translate/utils/unwrapApiResult.js +0 -3
  33. package/dist/{types-CEsh60Yt.d.mts → types-BxgnFr8M.d.cts} +3 -3
  34. package/dist/{types-yByDbKnV.d.cts → types-Ix4SHG5H.d.mts} +3 -3
  35. package/dist/types-dir/transformations.d.ts +2 -2
  36. package/dist/types.d.cts +1 -1
  37. package/dist/types.d.mts +1 -1
  38. package/dist/utils/minify.js +1 -1
  39. package/package.json +2 -2
  40. package/dist/derive-CS-paSZ9.cjs.map +0 -1
  41. package/dist/derive-Ctj9wXCT.mjs.map +0 -1
  42. package/dist/runtimeTranslate-CI936gg9.mjs.map +0 -1
  43. package/dist/runtimeTranslate-_gLYFBvE.cjs.map +0 -1
  44. package/dist/translate/utils/validateResponse.d.ts +0 -1
  45. package/dist/translate/utils/validateResponse.js +0 -72
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # generaltranslation
2
2
 
3
+ ## 9.5.7
4
+
5
+ ### Patch Changes
6
+
7
+ - [#2455](https://github.com/generaltranslation/gt/pull/2455) [`c220f39`](https://github.com/generaltranslation/gt/commit/c220f39182a61be3d8139bfe18c5bced0f2956dc) Thanks [@eoinest](https://github.com/eoinest)! - Fix `<RelativeTime>` inside `<T>`: rename its variable transformation suffix from `relative-time` to `relativetime` so `_gtt` parsing reads it in full, letting it render formatted time and hash like the extractors.
8
+
9
+ ## 9.5.6
10
+
11
+ ### Patch Changes
12
+
13
+ - [#2403](https://github.com/generaltranslation/gt/pull/2403) [`fe9f4b8`](https://github.com/generaltranslation/gt/commit/fe9f4b898548b94d7809be18f5e0dd9e80987428) Thanks [@chenxin-yan](https://github.com/chenxin-yan)! - Runtime translation errors with an empty or non-standard body now report the response status text, or the HTTP status code when there is none, instead of "Unknown error".
14
+
15
+ - Updated dependencies [[`9764db8`](https://github.com/generaltranslation/gt/commit/9764db8ddb466d243bbb44c7c9fb031053d683fa), [`bd632a8`](https://github.com/generaltranslation/gt/commit/bd632a888ce27257efeed8512eb6261a16987bb2)]:
16
+ - @generaltranslation/api@0.5.4
17
+
3
18
  ## 9.5.5
4
19
 
5
20
  ### Patch Changes
@@ -127,14 +127,14 @@ export declare function createGtApiAdapter(defaultConfig?: GtApiAdapterConfig):
127
127
  defaultLocale: string;
128
128
  };
129
129
  }>;
130
- /** Every project the configured credentials can read. */
130
+ /** Projects the signed-in user is a member of, or the API key is bound to. */
131
131
  listProjects(): Promise<{
132
132
  id: string;
133
133
  name: string;
134
134
  orgId: string;
135
135
  orgName: string;
136
136
  }[]>;
137
- /** Organizations where the signed-in user can create projects; user tokens only. */
137
+ /** Organizations the credentials can access; listing one does not grant project creation. */
138
138
  listOrgs(): Promise<{
139
139
  id: string;
140
140
  name: string;
@@ -555,7 +555,7 @@ export function createGtApiAdapter(defaultConfig) {
555
555
  });
556
556
  });
557
557
  },
558
- /** Every project the configured credentials can read. */
558
+ /** Projects the signed-in user is a member of, or the API key is bound to. */
559
559
  listProjects: function () {
560
560
  return __awaiter(this, void 0, void 0, function () {
561
561
  return __generator(this, function (_a) {
@@ -563,7 +563,7 @@ export function createGtApiAdapter(defaultConfig) {
563
563
  });
564
564
  });
565
565
  },
566
- /** Organizations where the signed-in user can create projects; user tokens only. */
566
+ /** Organizations the credentials can access; listing one does not grant project creation. */
567
567
  listOrgs: function () {
568
568
  return __awaiter(this, void 0, void 0, function () {
569
569
  return __generator(this, function (_a) {
@@ -1,4 +1,4 @@
1
- const require_runtimeTranslate = require("./runtimeTranslate-_gLYFBvE.cjs");
1
+ const require_runtimeTranslate = require("./runtimeTranslate-B8BLxD_U.cjs");
2
2
  const require_diagnostics = require("./diagnostics-DKtiPUvo.cjs");
3
3
  const require_file = require("./file-DNWSAhTC.cjs");
4
4
  let _generaltranslation_api = require("@generaltranslation/api");
@@ -312,11 +312,11 @@ function createGtApiAdapter(defaultConfig) {
312
312
  client: getClient()
313
313
  }));
314
314
  },
315
- /** Every project the configured credentials can read. */
315
+ /** Projects the signed-in user is a member of, or the API key is bound to. */
316
316
  async listProjects() {
317
317
  return collect((0, _generaltranslation_api.paginate)(_generaltranslation_api.listProjects, { client: getClient() }));
318
318
  },
319
- /** Organizations where the signed-in user can create projects; user tokens only. */
319
+ /** Organizations the credentials can access; listing one does not grant project creation. */
320
320
  async listOrgs() {
321
321
  return collect((0, _generaltranslation_api.paginate)(_generaltranslation_api.listOrgs, { client: getClient() }));
322
322
  },
@@ -709,4 +709,4 @@ Object.defineProperty(exports, "traverseIcu", {
709
709
  }
710
710
  });
711
711
 
712
- //# sourceMappingURL=derive-CS-paSZ9.cjs.map
712
+ //# sourceMappingURL=derive-DPDgh_1v.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"derive-DPDgh_1v.cjs","names":["isBinaryFileFormat","translate","translateWithConfig","translateMany","translateManyWithConfig","unwrapApiResult","isModelProvider","createDiagnosticMessage","supportedModelProviders","DEFAULT_BATCH_SIZE","listProjects","listOrgs","TYPE","TYPE"],"sources":["../src/utils/base64.ts","../src/utils/isSupportedFileFormatTransform.ts","../src/translate/utils/validateFileFormatTransform.ts","../src/adapter/createGtApi.ts","../src/derive/utils/traverseIcu.ts","../src/derive/utils/constants.ts","../src/derive/utils/regex.ts","../src/derive/utils/traverseHelpers.ts","../src/derive/decodeVars.ts","../src/derive/utils/sanitizeVar.ts","../src/derive/declareVar.ts","../src/derive/derive.ts"],"sourcesContent":["import { isBinaryFileFormat, type FileFormat } from '../types-dir/api/file';\n\n// Encode a string to base64\nexport function encode(data: string): string {\n if (typeof Buffer !== 'undefined') {\n // Node.js path.\n return Buffer.from(data, 'utf8').toString('base64');\n }\n // Browser path.\n const bytes = new TextEncoder().encode(data);\n let binary = '';\n for (let i = 0; i < bytes.length; i++) {\n binary += String.fromCharCode(bytes[i]);\n }\n return btoa(binary);\n}\n\n// Decode a base64 string to a string\nexport function decode(base64: string): string {\n if (typeof Buffer !== 'undefined') {\n // Node.js path.\n return Buffer.from(base64, 'base64').toString('utf8');\n }\n // Browser path.\n const binary = atob(base64);\n const bytes = new Uint8Array(binary.length);\n for (let i = 0; i < binary.length; i++) {\n bytes[i] = binary.charCodeAt(i);\n }\n return new TextDecoder().decode(bytes);\n}\n\nexport function encodeFileContent(\n content: string,\n fileFormat: FileFormat\n): string {\n return isBinaryFileFormat(fileFormat) ? content : encode(content);\n}\n\nexport function decodeFileContent(\n content: string,\n fileFormat: FileFormat\n): string {\n return isBinaryFileFormat(fileFormat) ? content : decode(content);\n}\n","import type { FileFormat } from '../types-dir/api/file';\n\nconst SUPPORTED_TRANSFORMATIONS = {\n GTJSON: ['GTJSON'],\n JSON: ['JSON'],\n PO: ['PO'],\n // POT templates can produce translated PO catalog files.\n POT: ['POT', 'PO'],\n YAML: ['YAML'],\n MDX: ['MDX'],\n MD: ['MD'],\n TS: ['TS'],\n JS: ['JS'],\n HTML: ['HTML'],\n TXT: ['TXT'],\n TWILIO_CONTENT_JSON: ['TWILIO_CONTENT_JSON'],\n LOTTIE: ['LOTTIE'],\n SVG: ['SVG'],\n DOT_STRINGS: ['DOT_STRINGS'],\n DOT_STRINGSDICT: ['DOT_STRINGSDICT'],\n ANDROID_STRINGS: ['ANDROID_STRINGS'],\n SRT: ['SRT'],\n RESX: ['RESX'],\n XCSTRINGS: ['XCSTRINGS'],\n} as const satisfies Record<FileFormat, FileFormat[]>;\n\n/**\n * This function checks if a file format transformation is supported during translation\n * @param from - The source file format.\n * @param to - The target file format.\n * @returns True if the transformation is supported, false otherwise\n */\nexport function isSupportedFileFormatTransform(\n from: FileFormat,\n to: FileFormat\n): boolean {\n const toFormats: FileFormat[] | undefined = SUPPORTED_TRANSFORMATIONS[from];\n return toFormats?.includes(to) ?? false;\n}\n","import type { FileFormat } from '../../types-dir/api/file';\nimport { isSupportedFileFormatTransform } from '../../utils/isSupportedFileFormatTransform';\n\nexport type FileFormatTransformInput = {\n fileFormat?: FileFormat;\n transformFormat?: FileFormat;\n fileName?: string;\n fileId?: string;\n};\n\n/**\n * Returns a user-facing validation error when a requested file format transform\n * is missing source format context or is not currently supported.\n */\nexport function getFileFormatTransformError(\n file: FileFormatTransformInput\n): string | undefined {\n if (!file.transformFormat) return undefined;\n const fileLabel = file.fileName ?? file.fileId ?? 'unknown file';\n if (!file.fileFormat) {\n return `fileFormat is required when transformFormat is provided for ${fileLabel}`;\n }\n if (!isSupportedFileFormatTransform(file.fileFormat, file.transformFormat)) {\n return `Unsupported file format transform: ${file.fileFormat} -> ${file.transformFormat}`;\n }\n return undefined;\n}\n\n/**\n * Validates file format transforms before sending upload/enqueue requests.\n */\nexport function validateFileFormatTransforms(\n files: FileFormatTransformInput[]\n): void {\n for (const file of files) {\n const error = getFileFormatTransformError(file);\n if (error) throw new Error(error);\n }\n}\n","import {\n createApiClient,\n createBranch,\n createProject,\n createProjectApiKey,\n createTag,\n DEFAULT_BATCH_SIZE,\n downloadFiles,\n enqueueFileTranslations,\n generateProjectContext,\n getBranchInfo,\n getFileInfo,\n getOrphanedFiles,\n getProjectInfo,\n getTranslationJobInfo,\n getTranslationStatus,\n listOrgs,\n listProjects,\n paginate,\n pollJobs,\n processBatches,\n processFileMoves,\n publishFiles,\n submitUserEditDiffs,\n uploadAssets,\n uploadSourceFiles,\n uploadTranslations,\n type ApiClientConfig,\n type AwaitJobsOptions,\n type CreateBranchData,\n type CreateProjectApiKeyData,\n type CreateProjectData,\n type CreateTagData,\n type DownloadFilesData,\n type EnqueueFileTranslationsData,\n type GenerateProjectContextData,\n type GetBranchInfoData,\n type GetFileInfoData,\n type GetTranslationJobInfoResponse,\n type GetTranslationStatusData,\n type ProcessFileMovesData,\n type PublishFilesData,\n type SubmitUserEditDiffsData,\n type UploadAssetsData,\n type UploadSourceFilesData,\n type UploadTranslationsData,\n} from '@generaltranslation/api';\nimport {\n resolveAliasLocale,\n resolveCanonicalLocale,\n standardizeLocale,\n} from '@generaltranslation/format';\nimport type { CustomMapping } from '@generaltranslation/format/types';\nimport type { DownloadedFile } from '../types-dir/api/downloadFileBatch';\nimport type {\n TranslateManyEntry,\n TranslateOptions,\n} from '../types-dir/api/entry';\nimport type { TranslateManyResult, TranslationResult } from '../types';\nimport { createDiagnosticMessage } from '../logging/diagnostics';\nimport {\n translate as translateWithConfig,\n translateMany as translateManyWithConfig,\n} from '../translate/runtimeTranslate';\nimport { decodeFileContent, encodeFileContent } from '../utils/base64';\nimport { unwrapApiResult } from '../translate/utils/unwrapApiResult';\nimport { validateFileFormatTransforms } from '../translate/utils/validateFileFormatTransform';\nimport { isModelProvider, supportedModelProviders } from './modelProvider';\n\nasync function collect<T>(iterable: AsyncIterable<T>): Promise<T[]> {\n const items: T[] = [];\n for await (const item of iterable) items.push(item);\n return items;\n}\n\nfunction normalizeJobStatus(job: GetTranslationJobInfoResponse[number]): {\n jobId: string;\n status: GetTranslationJobInfoResponse[number]['status'];\n error?: { message: string };\n} {\n return {\n jobId: job.jobId,\n status: job.status,\n ...(job.status === 'failed'\n ? { error: { message: job.error.message ?? '' } }\n : {}),\n };\n}\n\nexport type GtApiAdapterConfig = ApiClientConfig & {\n customMapping?: CustomMapping;\n};\n\nexport function createGtApiAdapter(defaultConfig?: GtApiAdapterConfig) {\n let client: ReturnType<typeof createApiClient> | undefined;\n let config: GtApiAdapterConfig | undefined;\n\n // Mapping resolves aliases; standardization also canonicalizes configured\n // spellings such as en-us before they cross the service boundary.\n function resolveServiceLocale(locale: string): string {\n return standardizeLocale(\n resolveCanonicalLocale(locale, config?.customMapping)\n );\n }\n\n // Upload responses echo the canonical locale; callers key lockfile entries\n // by the configured alias, so map it back before it leaves the adapter.\n function aliasUploadedFileLocale<T extends { locale?: string }>(file: T): T {\n return file.locale\n ? {\n ...file,\n locale: resolveAliasLocale(file.locale, config?.customMapping),\n }\n : file;\n }\n\n function getConfig(): GtApiAdapterConfig {\n if (!config) {\n throw new Error(\n 'API client not configured — call configureApiClient first'\n );\n }\n return config;\n }\n\n function getClient(timeoutMs?: number): ReturnType<typeof createApiClient> {\n if (timeoutMs === undefined && client) return client;\n return createApiClient({ ...getConfig(), timeoutMs });\n }\n\n function configure(nextConfig: GtApiAdapterConfig): void {\n client = createApiClient(nextConfig);\n config = { ...nextConfig };\n }\n\n async function translate(\n source: TranslateManyEntry,\n options: string | TranslateOptions,\n timeoutMs?: number | false\n ) {\n return translateWithConfig(source, options, {\n ...getConfig(),\n ...(timeoutMs !== undefined && { timeoutMs }),\n });\n }\n\n function translateMany(\n sources: TranslateManyEntry[],\n options: string | TranslateOptions,\n timeoutMs?: number | false\n ): Promise<TranslateManyResult>;\n function translateMany(\n sources: Record<string, TranslateManyEntry>,\n options: string | TranslateOptions,\n timeoutMs?: number | false\n ): Promise<Record<string, TranslationResult>>;\n async function translateMany(\n sources: TranslateManyEntry[] | Record<string, TranslateManyEntry>,\n options: string | TranslateOptions,\n timeoutMs?: number | false\n ): Promise<TranslateManyResult | Record<string, TranslationResult>> {\n return translateManyWithConfig(sources, options, {\n ...getConfig(),\n ...(timeoutMs !== undefined && { timeoutMs }),\n });\n }\n\n if (defaultConfig) configure(defaultConfig);\n\n // Raw service responses; the normalized adapter methods build on these and\n // compatibility facades (CLI) expose them unchanged.\n async function loadJobStatuses(\n jobIds: readonly string[],\n options: { signal?: AbortSignal; timeoutMs?: number } = {}\n ): Promise<GetTranslationJobInfoResponse> {\n return unwrapApiResult(\n await getTranslationJobInfo({\n body: { jobIds: [...jobIds] },\n client: getClient(options.timeoutMs),\n signal: options.signal,\n })\n );\n }\n\n async function loadProjectInfo(projectId?: string, timeoutMs?: number) {\n const resolvedProjectId = projectId ?? getConfig().projectId;\n if (!resolvedProjectId) {\n throw new Error('Project ID is required to fetch project information');\n }\n return unwrapApiResult(\n await getProjectInfo({\n client: getClient(timeoutMs),\n path: { projectId: resolvedProjectId },\n })\n );\n }\n\n return {\n configure,\n getClient,\n\n resolveAliasLocale(locale: string) {\n return resolveAliasLocale(locale, config?.customMapping);\n },\n\n resolveCanonicalLocale(locale: string) {\n return resolveServiceLocale(locale);\n },\n\n translate,\n translateMany,\n\n async queryBranchData(body: GetBranchInfoData['body']) {\n return unwrapApiResult(\n await getBranchInfo({ body, client: getClient() })\n );\n },\n\n async createBranch(body: CreateBranchData['body']) {\n return unwrapApiResult(await createBranch({ body, client: getClient() }));\n },\n\n async processFileMoves(\n moves: ProcessFileMovesData['body']['moves'],\n options: Pick<ProcessFileMovesData['body'], 'branchId'> & {\n timeout?: number;\n } = {}\n ) {\n const results = await processBatches(moves, async (batch) => {\n const response = unwrapApiResult(\n await processFileMoves({\n body: { branchId: options.branchId, moves: batch },\n client: getClient(options.timeout),\n })\n );\n return response.results;\n });\n const succeeded = results.filter(({ success }) => success).length;\n return {\n results,\n summary: {\n total: moves.length,\n succeeded,\n failed: results.length - succeeded,\n },\n };\n },\n\n async getOrphanedFiles(\n branchId: string,\n fileIds: string[],\n options: { timeout?: number } = {}\n ) {\n const request = async (batch: string[]) =>\n unwrapApiResult(\n await getOrphanedFiles({\n body: { branchId, fileIds: batch },\n client: getClient(options.timeout),\n })\n );\n\n if (fileIds.length === 0) return request([]);\n\n const results = await processBatches(fileIds, async (batch) => [\n await request(batch),\n ]);\n const orphanedFiles = new Map(\n results[0].orphanedFiles.map((file) => [file.fileId, file])\n );\n for (const result of results.slice(1)) {\n const batchFileIds = new Set(\n result.orphanedFiles.map((file) => file.fileId)\n );\n for (const fileId of Array.from(orphanedFiles.keys())) {\n if (!batchFileIds.has(fileId)) orphanedFiles.delete(fileId);\n }\n }\n return { orphanedFiles: Array.from(orphanedFiles.values()) };\n },\n\n async setupProject(\n files: GenerateProjectContextData['body']['files'],\n options: Omit<GenerateProjectContextData['body'], 'files'> & {\n timeoutMs?: number;\n } = {}\n ) {\n return unwrapApiResult(\n await generateProjectContext({\n body: {\n files: files.map(({ branchId, fileId, versionId }) => ({\n branchId,\n fileId,\n versionId,\n })),\n locales: options.locales?.map((locale) =>\n resolveServiceLocale(locale)\n ),\n force: options.force,\n },\n client: getClient(options.timeoutMs),\n })\n );\n },\n\n loadJobStatuses,\n\n async checkJobStatus(jobIds: string[], timeoutMs?: number) {\n const statuses = await loadJobStatuses(jobIds, { timeoutMs });\n return statuses.map(normalizeJobStatus);\n },\n\n async awaitJobs(jobIds: readonly string[], options?: AwaitJobsOptions) {\n const result = await pollJobs(\n jobIds,\n (pendingJobIds, signal) => loadJobStatuses(pendingJobIds, { signal }),\n options\n );\n return {\n ...result,\n jobs: result.jobs.map(normalizeJobStatus),\n };\n },\n\n async enqueueFiles(\n files: EnqueueFileTranslationsData['body']['files'],\n options: {\n sourceLocale?: string;\n targetLocales: string[];\n modelProvider?: string;\n force?: boolean;\n timeout?: number;\n }\n ) {\n validateFileFormatTransforms(files);\n const modelProvider = options.modelProvider;\n if (modelProvider !== undefined && !isModelProvider(modelProvider)) {\n throw new Error(\n createDiagnosticMessage({\n source: 'generaltranslation',\n severity: 'Error',\n whatHappened: `Unsupported model provider \\`${modelProvider}\\``,\n fix: `Use one of: ${supportedModelProviders.join(', ')}`,\n })\n );\n }\n const targetLocales = options.targetLocales.map((locale) =>\n resolveServiceLocale(locale)\n );\n const result = await processBatches(files, async (batch) => {\n const response = unwrapApiResult(\n await enqueueFileTranslations({\n body: {\n files: batch.map(\n ({\n branchId,\n fileId,\n versionId,\n fileName,\n transformFormat,\n }) => ({\n branchId,\n fileId,\n versionId,\n fileName,\n transformFormat,\n })\n ),\n targetLocales,\n sourceLocale: options.sourceLocale\n ? resolveServiceLocale(options.sourceLocale)\n : undefined,\n modelProvider,\n force: options.force,\n },\n client: getClient(options.timeout),\n })\n );\n const jobData =\n 'jobData' in response ? response.jobData : response.data;\n return Object.entries(jobData);\n });\n\n return {\n jobData: Object.fromEntries(result),\n locales: targetLocales,\n message: `Successfully enqueued ${result.length} file translation jobs in ${Math.ceil(files.length / DEFAULT_BATCH_SIZE)} batch(es)`,\n };\n },\n\n async createTag(body: CreateTagData['body']) {\n return unwrapApiResult(await createTag({ body, client: getClient() }));\n },\n\n async publishFiles(files: PublishFilesData['body']['files']) {\n // Compatibility callers pass entries carrying fileName; map only the\n // contract fields so nothing outside the generated body reaches the wire.\n return unwrapApiResult(\n await publishFiles({\n body: {\n files: files.map(({ fileId, versionId, branchId, publish }) => ({\n fileId,\n versionId,\n branchId,\n publish,\n })),\n },\n client: getClient(),\n })\n );\n },\n\n async submitUserEditDiffs(\n body: SubmitUserEditDiffsData['body'],\n options: { timeout?: number } = {}\n ) {\n return processBatches(body.diffs, async (diffs) => [\n unwrapApiResult(\n await submitUserEditDiffs({\n body: {\n projectId: body.projectId,\n diffs: diffs.map(\n ({\n diff,\n branchId,\n versionId,\n fileId,\n localContent,\n locale,\n }) => ({\n diff,\n branchId,\n versionId,\n fileId,\n localContent,\n locale: resolveServiceLocale(locale),\n })\n ),\n },\n client: getClient(options.timeout),\n })\n ),\n ]);\n },\n\n async createProject(\n orgId: CreateProjectData['path']['orgId'],\n body: CreateProjectData['body']\n ) {\n return unwrapApiResult(\n await createProject({\n path: { orgId },\n body: {\n ...body,\n defaultLocale: resolveServiceLocale(body.defaultLocale),\n },\n client: getClient(),\n })\n );\n },\n\n /** Projects the signed-in user is a member of, or the API key is bound to. */\n async listProjects() {\n return collect(paginate(listProjects, { client: getClient() }));\n },\n\n /** Organizations the credentials can access; listing one does not grant project creation. */\n async listOrgs() {\n return collect(paginate(listOrgs, { client: getClient() }));\n },\n\n async createProjectApiKey(\n projectId: CreateProjectApiKeyData['path']['projectId'],\n body: CreateProjectApiKeyData['body']\n ) {\n return unwrapApiResult(\n await createProjectApiKey({\n path: { projectId },\n body,\n client: getClient(),\n })\n );\n },\n\n loadProjectInfo,\n\n async getProjectInfo(projectId?: string, timeoutMs?: number) {\n const result = await loadProjectInfo(projectId, timeoutMs);\n return {\n ...result,\n defaultLocale: resolveAliasLocale(\n result.defaultLocale,\n config?.customMapping\n ),\n currentLocales: result.currentLocales.map((locale) =>\n resolveAliasLocale(locale, config?.customMapping)\n ),\n };\n },\n\n async queryFileData(body: GetFileInfoData['body'], timeoutMs?: number) {\n const result = unwrapApiResult(\n await getFileInfo({\n body: {\n ...body,\n translatedFiles: body.translatedFiles?.map((file) => ({\n ...file,\n locale: resolveServiceLocale(file.locale),\n })),\n },\n client: getClient(timeoutMs),\n })\n );\n return {\n ...result,\n translatedFiles: result.translatedFiles.map((file) => ({\n ...file,\n locale: resolveAliasLocale(file.locale, config?.customMapping),\n })),\n sourceFiles: result.sourceFiles.map((file) => ({\n ...file,\n sourceLocale: resolveAliasLocale(\n file.sourceLocale,\n config?.customMapping\n ),\n locales: file.locales.map((locale) =>\n resolveAliasLocale(locale, config?.customMapping)\n ),\n })),\n };\n },\n\n async querySourceFile(\n path: GetTranslationStatusData['path'],\n query: GetTranslationStatusData['query'] = {},\n timeoutMs?: number\n ) {\n const result = unwrapApiResult(\n await getTranslationStatus({\n path,\n query,\n client: getClient(timeoutMs),\n })\n );\n return {\n ...result,\n translations: result.translations.map((translation) => ({\n ...translation,\n locale: resolveAliasLocale(translation.locale, config?.customMapping),\n })),\n sourceFile: {\n ...result.sourceFile,\n sourceLocale: resolveAliasLocale(\n result.sourceFile.sourceLocale,\n config?.customMapping\n ),\n locales: result.sourceFile.locales.map((locale) =>\n resolveAliasLocale(locale, config?.customMapping)\n ),\n },\n };\n },\n\n async downloadFileBatch(\n files: DownloadFilesData['body'],\n options: { timeout?: number } = {}\n ) {\n const request = async (batch: DownloadFilesData['body']) =>\n unwrapApiResult(\n await downloadFiles({\n body: batch.map((file) => ({\n ...file,\n locale: file.locale\n ? resolveServiceLocale(file.locale)\n : undefined,\n })),\n client: getClient(options.timeout),\n })\n );\n const responses = await processBatches(files, async (batch) => [\n await request(batch),\n ]);\n return {\n files: responses.flatMap((response) =>\n response.files.map(\n (file): DownloadedFile => ({\n ...file,\n ...(file.locale && {\n locale: resolveAliasLocale(file.locale, config?.customMapping),\n }),\n data: decodeFileContent(file.data, file.fileFormat),\n metadata: file.metadata,\n })\n )\n ),\n count: responses.reduce((count, response) => count + response.count, 0),\n pending: responses.flatMap((response) =>\n (response.pending ?? []).map((file) => ({\n ...file,\n locale: resolveAliasLocale(file.locale, config?.customMapping),\n }))\n ),\n };\n },\n\n async uploadSourceFiles(\n files: Array<{\n source: UploadSourceFilesData['body']['data'][number]['source'];\n }>,\n options: { sourceLocale: string; timeout?: number }\n ) {\n const sourceLocale = resolveServiceLocale(options.sourceLocale);\n const result = await processBatches(files, async (batch) => {\n const response = unwrapApiResult(\n await uploadSourceFiles({\n body: {\n data: batch.map(({ source }) => ({\n source: {\n ...source,\n content: encodeFileContent(source.content, source.fileFormat),\n locale: resolveServiceLocale(source.locale),\n },\n })),\n sourceLocale,\n },\n client: getClient(options.timeout),\n })\n );\n return response.uploadedFiles.map(aliasUploadedFileLocale);\n });\n\n return { uploadedFiles: result };\n },\n\n async uploadFonts(\n fonts: UploadAssetsData['body']['assets'],\n options: { timeout?: number } = {}\n ) {\n const assets = await processBatches(\n fonts,\n async (batch) => {\n const result = unwrapApiResult(\n await uploadAssets({\n body: { assets: batch },\n client: getClient(options.timeout),\n })\n );\n return result.assets;\n },\n { batchSize: 50 }\n );\n return { assets, count: assets.length };\n },\n\n async uploadTranslations(\n files: UploadTranslationsData['body']['data'],\n options: { sourceLocale: string; timeout?: number }\n ) {\n validateFileFormatTransforms(files.map(({ source }) => source));\n const result = await processBatches(files, async (batch) => {\n const response = unwrapApiResult(\n await uploadTranslations({\n body: {\n data: batch.map(({ source, translations }) => ({\n source: {\n ...source,\n content: encodeFileContent(source.content, source.fileFormat),\n locale: resolveServiceLocale(source.locale),\n },\n translations: translations.map((translation) => ({\n ...translation,\n locale: resolveServiceLocale(translation.locale),\n content: encodeFileContent(\n translation.content,\n translation.fileFormat\n ),\n })),\n })),\n sourceLocale: resolveServiceLocale(options.sourceLocale),\n },\n client: getClient(options.timeout),\n })\n );\n return response.uploadedFiles.map(aliasUploadedFileLocale);\n });\n\n return { uploadedFiles: result };\n },\n };\n}\n\nexport type GtApiAdapter = ReturnType<typeof createGtApiAdapter>;\n","import {\n parse,\n TYPE,\n type MessageFormatElement,\n type ParserOptions,\n} from '@generaltranslation/icu';\n\ntype TraverseIcuOptions = ParserOptions & {\n recurseIntoVisited?: boolean;\n};\n\n/**\n * Given an ICU string, traverse the AST and call the visitor function for each element that matches the type T\n * @param icu - The ICU string to traverse\n * @param shouldVisit - A function that returns true if the element should be visited\n * @param visitor - A function that is called for each element that matches the type T\n * @returns The modified AST of the ICU string.\n *\n * @note This function is a heavy operation, use sparingly\n */\nexport function traverseIcu<T extends MessageFormatElement>({\n icuString,\n shouldVisit,\n visitor,\n options: { recurseIntoVisited = true, ...otherOptions },\n}: {\n icuString: string;\n shouldVisit: (element: MessageFormatElement) => element is T;\n visitor: (element: T) => void;\n options: TraverseIcuOptions;\n}): MessageFormatElement[] {\n const ast = parse(icuString, otherOptions);\n handleChildren(ast);\n return ast;\n\n function handleChildren(children: MessageFormatElement[]): void {\n children.map(handleChild);\n }\n\n function handleChild(child: MessageFormatElement) {\n // handle select var\n let visited = false;\n if (shouldVisit(child)) {\n visitor(child);\n visited = true;\n }\n // recurse on children\n if (!visited || recurseIntoVisited) {\n if (child.type === TYPE.select || child.type === TYPE.plural) {\n Object.values(child.options)\n .map((option) => option.value)\n .map(handleChildren);\n } else if (child.type === TYPE.tag) {\n handleChildren(child.children);\n }\n }\n }\n}\n","export const VAR_IDENTIFIER = '_gt_';\nexport const VAR_NAME_IDENTIFIER = '_gt_var_name';\n","import { VAR_IDENTIFIER } from './constants';\n\n// Regex for _gt_# select\nexport const GT_INDEXED_IDENTIFIER_REGEX = new RegExp(\n `^${VAR_IDENTIFIER}\\\\d+$`\n);\n\nexport const GT_UNINDEXED_IDENTIFIER_REGEX = new RegExp(`^${VAR_IDENTIFIER}$`);\n","import {\n GT_INDEXED_IDENTIFIER_REGEX,\n GT_UNINDEXED_IDENTIFIER_REGEX,\n} from './regex';\nimport { GTIndexedSelectElement, GTUnindexedSelectElement } from './types';\nimport { TYPE, type MessageFormatElement } from '@generaltranslation/icu';\n\n// Visit any _gt_# select\nexport function isGTIndexedSelectElement(\n child: MessageFormatElement\n): child is GTIndexedSelectElement {\n return (\n child.type === TYPE.select &&\n GT_INDEXED_IDENTIFIER_REGEX.test(child.value) &&\n !!child.options.other &&\n (child.options.other.value.length === 0 ||\n (child.options.other.value.length > 0 &&\n child.options.other.value[0]?.type === TYPE.literal))\n );\n}\n\n// Visit any _gt_ select\nexport function isGTUnindexedSelectElement(\n child: MessageFormatElement\n): child is GTUnindexedSelectElement {\n return (\n child.type === TYPE.select &&\n GT_UNINDEXED_IDENTIFIER_REGEX.test(child.value) &&\n !!child.options.other &&\n (child.options.other.value.length === 0 ||\n (child.options.other.value.length > 0 &&\n child.options.other.value[0]?.type === TYPE.literal))\n );\n}\n","import { traverseIcu } from './utils/traverseIcu';\nimport { VAR_IDENTIFIER } from './utils/constants';\nimport { GTUnindexedSelectElement } from './utils/types';\nimport { isGTUnindexedSelectElement } from './utils/traverseHelpers';\n\ntype Location = {\n start: number;\n end: number;\n value: string;\n};\n\n/**\n * Given an encoded ICU string, interpolate only _gt_ variables that have been marked with declareVar()\n * @example\n * const encodedIcu = \"Hi\" + declareVar(\"Brian\") + \", my name is {name}\"\n * // 'Hi {_gt_, select, other {Brian}}, my name is {name}'\n * decodeVars(encodedIcu)\n * // 'Hi Brian, my name is {name}'\n */\nexport function decodeVars(icuString: string): string {\n // Check if the string contains _gt_\n if (!icuString.includes(VAR_IDENTIFIER)) {\n return icuString;\n }\n\n // Record the location of the variable\n const variableLocations: Location[] = [];\n function visitor(child: GTUnindexedSelectElement): void {\n variableLocations.push({\n start: child.location?.start.offset ?? 0,\n end: child.location?.end.offset ?? 0,\n value:\n child.options.other.value.length > 0\n ? child.options.other.value[0].value\n : '',\n });\n }\n\n // Find all variable identifiers.\n traverseIcu({\n icuString,\n shouldVisit: isGTUnindexedSelectElement,\n visitor,\n options: {\n recurseIntoVisited: false,\n captureLocation: true,\n },\n });\n\n // Construct output string\n let previousIndex = 0;\n const outputList = [];\n for (let i = 0; i < variableLocations.length; i++) {\n outputList.push(icuString.slice(previousIndex, variableLocations[i].start));\n outputList.push(variableLocations[i].value);\n previousIndex = variableLocations[i].end;\n }\n if (previousIndex < icuString.length) {\n outputList.push(icuString.slice(previousIndex));\n }\n const outputString = outputList.join('');\n\n return outputString;\n}\n","/**\n * Sanitizes string by escaping ICU syntax\n *\n * Sanitize arbitrary string so it does not break the following ICU message syntax:\n * {_gt_, select, other {string_here}}\n *\n * Escapes ICU special characters by:\n * 1. Doubling all single quotes (U+0027 ')\n * 2. Adding a single quote before the first special character ({}<>)\n * 3. Adding a single quote after the last special character ({}<>)\n */\nexport function sanitizeVar(string: string): string {\n // First, double all single quotes (both ASCII and Unicode).\n let result = string.replace(/'/g, \"''\");\n\n // Find first and last positions of special characters\n const specialChars = /[{}<>]/;\n const firstSpecialIndex = result.search(specialChars);\n\n if (firstSpecialIndex === -1) {\n // No special characters; return with just doubled quotes.\n return result;\n }\n\n // Find last special character position\n let lastSpecialIndex = -1;\n for (let i = result.length - 1; i >= 0; i--) {\n if (specialChars.test(result[i])) {\n lastSpecialIndex = i;\n break;\n }\n }\n\n // Insert quotes around the special character region.\n result =\n result.slice(0, firstSpecialIndex) +\n \"'\" +\n result.slice(firstSpecialIndex, lastSpecialIndex + 1) +\n \"'\" +\n result.slice(lastSpecialIndex + 1);\n\n return result;\n}\n","import { VAR_IDENTIFIER, VAR_NAME_IDENTIFIER } from './utils/constants';\nimport { sanitizeVar } from './utils/sanitizeVar';\n\n/**\n * Mark as a non-translatable string. Use within a derive() call to mark content as not derivable (e.g., not possible to statically analyze).\n *\n * @example\n * function nonDerivableFunction() {\n * return Math.random();\n * }\n *\n * function derivableFunction() {\n * if (condition) {\n * return declareVar(nonDerivableFunction())\n * }\n * return 'John Doe';\n * }\n *\n * const gt = useGT();\n * gt(`My name is ${derive(derivableFunction())}`);\n *\n * @param {string | number | boolean | null | undefined} variable - The variable to sanitize.\n * @param {Object} [options] - The options for the sanitization.\n * @param {string} [options.$name] - The name of the variable.\n * @returns {string} The sanitized value.\n */\nexport function declareVar(\n variable: string | number | boolean | null | undefined,\n options?: { $name?: string }\n): string {\n // Variable section.\n const sanitizedVariable = sanitizeVar(String(variable ?? ''));\n const variableSection = ` other {${sanitizedVariable}}`;\n\n // Name section.\n let nameSection = '';\n if (options?.$name) {\n const sanitizedName = sanitizeVar(options.$name);\n nameSection = ` ${VAR_NAME_IDENTIFIER} {${sanitizedName}}`;\n }\n\n // interpolate\n return `{${VAR_IDENTIFIER}, select,${variableSection}${nameSection}}`;\n}\n","/**\n * Marks content as derivable by the GT compiler and CLI.\n *\n * Use `derive()` when a translation string or context needs content that is\n * computed from source code, but should still be discovered during extraction\n * instead of treated as a runtime interpolation variable. The CLI attempts to\n * resolve the derivable expression into every possible static value and\n * includes those values in the source content that gets translated.\n *\n * `derive()` returns its argument unchanged at runtime.\n *\n * Run `gt validate` after adding or changing `derive()` calls to verify that\n * each derivable expression can be resolved by the CLI before translating or\n * building.\n *\n * @example\n * ```jsx\n * function getSubject() {\n * return (Math.random() > 0.5) ? \"Alice\" : \"Brian\";\n * }\n * ...\n * gt(`My name is ${derive(getSubject())}`);\n * ```\n *\n * @param {T extends string | boolean | number | null | undefined} content - Content to derive for translation extraction.\n * @returns {T} The same content, unchanged at runtime.\n */\nexport function derive<T extends string | boolean | number | null | undefined>(\n content: T\n): T {\n return content;\n}\n"],"mappings":";;;;;;;AAGA,SAAgB,OAAO,MAAsB;AAC3C,KAAI,OAAO,WAAW,YAEpB,QAAO,OAAO,KAAK,MAAM,OAAO,CAAC,SAAS,SAAS;CAGrD,MAAM,QAAQ,IAAI,aAAa,CAAC,OAAO,KAAK;CAC5C,IAAI,SAAS;AACb,MAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,IAChC,WAAU,OAAO,aAAa,MAAM,GAAG;AAEzC,QAAO,KAAK,OAAO;;AAIrB,SAAgB,OAAO,QAAwB;AAC7C,KAAI,OAAO,WAAW,YAEpB,QAAO,OAAO,KAAK,QAAQ,SAAS,CAAC,SAAS,OAAO;CAGvD,MAAM,SAAS,KAAK,OAAO;CAC3B,MAAM,QAAQ,IAAI,WAAW,OAAO,OAAO;AAC3C,MAAK,IAAI,IAAI,GAAG,IAAI,OAAO,QAAQ,IACjC,O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MACA,OAAO,MAAM,mBAAmB,EAAE;AAEpC,QAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;ACfT,SAAgB,WACd,UACA,SACQ;CAGR,MAAM,kBAAkB,WADE,YAAY,OAAO,YAAY,GAAG,CACR,CAAC;CAGrD,IAAI,cAAc;AAClB,KAAI,SAAS,MAEX,eAAc,IAAI,oBAAoB,IADhB,YAAY,QAAQ,MACa,CAAC;AAI1D,QAAO,IAAI,eAAe,WAAW,kBAAkB,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACfrE,SAAgB,OACd,SACG;AACH,QAAO"}
@@ -1,4 +1,4 @@
1
- import { a as unwrapApiResult, n as translateMany, o as isModelProvider, s as supportedModelProviders, t as translate$1 } from "./runtimeTranslate-CI936gg9.mjs";
1
+ import { a as unwrapApiResult, n as translateMany, o as isModelProvider, s as supportedModelProviders, t as translate$1 } from "./runtimeTranslate-CRWJMYly.mjs";
2
2
  import { t as createDiagnosticMessage } from "./diagnostics-DKA2SkZB.mjs";
3
3
  import { n as isBinaryFileFormat } from "./file-BZmC4OTj.mjs";
4
4
  import { DEFAULT_BATCH_SIZE, createApiClient, createBranch, createProject, createProjectApiKey, createTag, downloadFiles, enqueueFileTranslations, generateProjectContext, getBranchInfo, getFileInfo, getOrphanedFiles, getProjectInfo, getTranslationJobInfo, getTranslationStatus, listOrgs, listProjects, paginate, pollJobs, processBatches, processFileMoves, publishFiles, submitUserEditDiffs, uploadAssets, uploadSourceFiles, uploadTranslations } from "@generaltranslation/api";
@@ -312,11 +312,11 @@ function createGtApiAdapter(defaultConfig) {
312
312
  client: getClient()
313
313
  }));
314
314
  },
315
- /** Every project the configured credentials can read. */
315
+ /** Projects the signed-in user is a member of, or the API key is bound to. */
316
316
  async listProjects() {
317
317
  return collect(paginate(listProjects, { client: getClient() }));
318
318
  },
319
- /** Organizations where the signed-in user can create projects; user tokens only. */
319
+ /** Organizations the credentials can access; listing one does not grant project creation. */
320
320
  async listOrgs() {
321
321
  return collect(paginate(listOrgs, { client: getClient() }));
322
322
  },
@@ -632,4 +632,4 @@ function derive(content) {
632
632
  //#endregion
633
633
  export { isGTUnindexedSelectElement as a, createGtApiAdapter as c, decodeFileContent as d, encode as f, isGTIndexedSelectElement as i, isSupportedFileFormatTransform as l, declareVar as n, VAR_IDENTIFIER as o, encodeFileContent as p, decodeVars as r, traverseIcu as s, derive as t, decode as u };
634
634
 
635
- //# sourceMappingURL=derive-Ctj9wXCT.mjs.map
635
+ //# sourceMappingURL=derive-DZR18WqK.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"derive-DZR18WqK.mjs","names":["translateWithConfig","translateMany","translateManyWithConfig"],"sources":["../src/utils/base64.ts","../src/utils/isSupportedFileFormatTransform.ts","../src/translate/utils/validateFileFormatTransform.ts","../src/adapter/createGtApi.ts","../src/derive/utils/traverseIcu.ts","../src/derive/utils/constants.ts","../src/derive/utils/regex.ts","../src/derive/utils/traverseHelpers.ts","../src/derive/decodeVars.ts","../src/derive/utils/sanitizeVar.ts","../src/derive/declareVar.ts","../src/derive/derive.ts"],"sourcesContent":["import { isBinaryFileFormat, type FileFormat } from '../types-dir/api/file';\n\n// Encode a string to base64\nexport function encode(data: string): string {\n if (typeof Buffer !== 'undefined') {\n // Node.js path.\n return Buffer.from(data, 'utf8').toString('base64');\n }\n // Browser path.\n const bytes = new TextEncoder().encode(data);\n let binary = '';\n for (let i = 0; i < bytes.length; i++) {\n binary += String.fromCharCode(bytes[i]);\n }\n return btoa(binary);\n}\n\n// Decode a base64 string to a string\nexport function decode(base64: string): string {\n if (typeof Buffer !== 'undefined') {\n // Node.js path.\n return Buffer.from(base64, 'base64').toString('utf8');\n }\n // Browser path.\n const binary = atob(base64);\n const bytes = new Uint8Array(binary.length);\n for (let i = 0; i < binary.length; i++) {\n bytes[i] = binary.charCodeAt(i);\n }\n return new TextDecoder().decode(bytes);\n}\n\nexport function encodeFileContent(\n content: string,\n fileFormat: FileFormat\n): string {\n return isBinaryFileFormat(fileFormat) ? content : encode(content);\n}\n\nexport function decodeFileContent(\n content: string,\n fileFormat: FileFormat\n): string {\n return isBinaryFileFormat(fileFormat) ? content : decode(content);\n}\n","import type { FileFormat } from '../types-dir/api/file';\n\nconst SUPPORTED_TRANSFORMATIONS = {\n GTJSON: ['GTJSON'],\n JSON: ['JSON'],\n PO: ['PO'],\n // POT templates can produce translated PO catalog files.\n POT: ['POT', 'PO'],\n YAML: ['YAML'],\n MDX: ['MDX'],\n MD: ['MD'],\n TS: ['TS'],\n JS: ['JS'],\n HTML: ['HTML'],\n TXT: ['TXT'],\n TWILIO_CONTENT_JSON: ['TWILIO_CONTENT_JSON'],\n LOTTIE: ['LOTTIE'],\n SVG: ['SVG'],\n DOT_STRINGS: ['DOT_STRINGS'],\n DOT_STRINGSDICT: ['DOT_STRINGSDICT'],\n ANDROID_STRINGS: ['ANDROID_STRINGS'],\n SRT: ['SRT'],\n RESX: ['RESX'],\n XCSTRINGS: ['XCSTRINGS'],\n} as const satisfies Record<FileFormat, FileFormat[]>;\n\n/**\n * This function checks if a file format transformation is supported during translation\n * @param from - The source file format.\n * @param to - The target file format.\n * @returns True if the transformation is supported, false otherwise\n */\nexport function isSupportedFileFormatTransform(\n from: FileFormat,\n to: FileFormat\n): boolean {\n const toFormats: FileFormat[] | undefined = SUPPORTED_TRANSFORMATIONS[from];\n return toFormats?.includes(to) ?? false;\n}\n","import type { FileFormat } from '../../types-dir/api/file';\nimport { isSupportedFileFormatTransform } from '../../utils/isSupportedFileFormatTransform';\n\nexport type FileFormatTransformInput = {\n fileFormat?: FileFormat;\n transformFormat?: FileFormat;\n fileName?: string;\n fileId?: string;\n};\n\n/**\n * Returns a user-facing validation error when a requested file format transform\n * is missing source format context or is not currently supported.\n */\nexport function getFileFormatTransformError(\n file: FileFormatTransformInput\n): string | undefined {\n if (!file.transformFormat) return undefined;\n const fileLabel = file.fileName ?? file.fileId ?? 'unknown file';\n if (!file.fileFormat) {\n return `fileFormat is required when transformFormat is provided for ${fileLabel}`;\n }\n if (!isSupportedFileFormatTransform(file.fileFormat, file.transformFormat)) {\n return `Unsupported file format transform: ${file.fileFormat} -> ${file.transformFormat}`;\n }\n return undefined;\n}\n\n/**\n * Validates file format transforms before sending upload/enqueue requests.\n */\nexport function validateFileFormatTransforms(\n files: FileFormatTransformInput[]\n): void {\n for (const file of files) {\n const error = getFileFormatTransformError(file);\n if (error) throw new Error(error);\n }\n}\n","import {\n createApiClient,\n createBranch,\n createProject,\n createProjectApiKey,\n createTag,\n DEFAULT_BATCH_SIZE,\n downloadFiles,\n enqueueFileTranslations,\n generateProjectContext,\n getBranchInfo,\n getFileInfo,\n getOrphanedFiles,\n getProjectInfo,\n getTranslationJobInfo,\n getTranslationStatus,\n listOrgs,\n listProjects,\n paginate,\n pollJobs,\n processBatches,\n processFileMoves,\n publishFiles,\n submitUserEditDiffs,\n uploadAssets,\n uploadSourceFiles,\n uploadTranslations,\n type ApiClientConfig,\n type AwaitJobsOptions,\n type CreateBranchData,\n type CreateProjectApiKeyData,\n type CreateProjectData,\n type CreateTagData,\n type DownloadFilesData,\n type EnqueueFileTranslationsData,\n type GenerateProjectContextData,\n type GetBranchInfoData,\n type GetFileInfoData,\n type GetTranslationJobInfoResponse,\n type GetTranslationStatusData,\n type ProcessFileMovesData,\n type PublishFilesData,\n type SubmitUserEditDiffsData,\n type UploadAssetsData,\n type UploadSourceFilesData,\n type UploadTranslationsData,\n} from '@generaltranslation/api';\nimport {\n resolveAliasLocale,\n resolveCanonicalLocale,\n standardizeLocale,\n} from '@generaltranslation/format';\nimport type { CustomMapping } from '@generaltranslation/format/types';\nimport type { DownloadedFile } from '../types-dir/api/downloadFileBatch';\nimport type {\n TranslateManyEntry,\n TranslateOptions,\n} from '../types-dir/api/entry';\nimport type { TranslateManyResult, TranslationResult } from '../types';\nimport { createDiagnosticMessage } from '../logging/diagnostics';\nimport {\n translate as translateWithConfig,\n translateMany as translateManyWithConfig,\n} from '../translate/runtimeTranslate';\nimport { decodeFileContent, encodeFileContent } from '../utils/base64';\nimport { unwrapApiResult } from '../translate/utils/unwrapApiResult';\nimport { validateFileFormatTransforms } from '../translate/utils/validateFileFormatTransform';\nimport { isModelProvider, supportedModelProviders } from './modelProvider';\n\nasync function collect<T>(iterable: AsyncIterable<T>): Promise<T[]> {\n const items: T[] = [];\n for await (const item of iterable) items.push(item);\n return items;\n}\n\nfunction normalizeJobStatus(job: GetTranslationJobInfoResponse[number]): {\n jobId: string;\n status: GetTranslationJobInfoResponse[number]['status'];\n error?: { message: string };\n} {\n return {\n jobId: job.jobId,\n status: job.status,\n ...(job.status === 'failed'\n ? { error: { message: job.error.message ?? '' } }\n : {}),\n };\n}\n\nexport type GtApiAdapterConfig = ApiClientConfig & {\n customMapping?: CustomMapping;\n};\n\nexport function createGtApiAdapter(defaultConfig?: GtApiAdapterConfig) {\n let client: ReturnType<typeof createApiClient> | undefined;\n let config: GtApiAdapterConfig | undefined;\n\n // Mapping resolves aliases; standardization also canonicalizes configured\n // spellings such as en-us before they cross the service boundary.\n function resolveServiceLocale(locale: string): string {\n return standardizeLocale(\n resolveCanonicalLocale(locale, config?.customMapping)\n );\n }\n\n // Upload responses echo the canonical locale; callers key lockfile entries\n // by the configured alias, so map it back before it leaves the adapter.\n function aliasUploadedFileLocale<T extends { locale?: string }>(file: T): T {\n return file.locale\n ? {\n ...file,\n locale: resolveAliasLocale(file.locale, config?.customMapping),\n }\n : file;\n }\n\n function getConfig(): GtApiAdapterConfig {\n if (!config) {\n throw new Error(\n 'API client not configured — call configureApiClient first'\n );\n }\n return config;\n }\n\n function getClient(timeoutMs?: number): ReturnType<typeof createApiClient> {\n if (timeoutMs === undefined && client) return client;\n return createApiClient({ ...getConfig(), timeoutMs });\n }\n\n function configure(nextConfig: GtApiAdapterConfig): void {\n client = createApiClient(nextConfig);\n config = { ...nextConfig };\n }\n\n async function translate(\n source: TranslateManyEntry,\n options: string | TranslateOptions,\n timeoutMs?: number | false\n ) {\n return translateWithConfig(source, options, {\n ...getConfig(),\n ...(timeoutMs !== undefined && { timeoutMs }),\n });\n }\n\n function translateMany(\n sources: TranslateManyEntry[],\n options: string | TranslateOptions,\n timeoutMs?: number | false\n ): Promise<TranslateManyResult>;\n function translateMany(\n sources: Record<string, TranslateManyEntry>,\n options: string | TranslateOptions,\n timeoutMs?: number | false\n ): Promise<Record<string, TranslationResult>>;\n async function translateMany(\n sources: TranslateManyEntry[] | Record<string, TranslateManyEntry>,\n options: string | TranslateOptions,\n timeoutMs?: number | false\n ): Promise<TranslateManyResult | Record<string, TranslationResult>> {\n return translateManyWithConfig(sources, options, {\n ...getConfig(),\n ...(timeoutMs !== undefined && { timeoutMs }),\n });\n }\n\n if (defaultConfig) configure(defaultConfig);\n\n // Raw service responses; the normalized adapter methods build on these and\n // compatibility facades (CLI) expose them unchanged.\n async function loadJobStatuses(\n jobIds: readonly string[],\n options: { signal?: AbortSignal; timeoutMs?: number } = {}\n ): Promise<GetTranslationJobInfoResponse> {\n return unwrapApiResult(\n await getTranslationJobInfo({\n body: { jobIds: [...jobIds] },\n client: getClient(options.timeoutMs),\n signal: options.signal,\n })\n );\n }\n\n async function loadProjectInfo(projectId?: string, timeoutMs?: number) {\n const resolvedProjectId = projectId ?? getConfig().projectId;\n if (!resolvedProjectId) {\n throw new Error('Project ID is required to fetch project information');\n }\n return unwrapApiResult(\n await getProjectInfo({\n client: getClient(timeoutMs),\n path: { projectId: resolvedProjectId },\n })\n );\n }\n\n return {\n configure,\n getClient,\n\n resolveAliasLocale(locale: string) {\n return resolveAliasLocale(locale, config?.customMapping);\n },\n\n resolveCanonicalLocale(locale: string) {\n return resolveServiceLocale(locale);\n },\n\n translate,\n translateMany,\n\n async queryBranchData(body: GetBranchInfoData['body']) {\n return unwrapApiResult(\n await getBranchInfo({ body, client: getClient() })\n );\n },\n\n async createBranch(body: CreateBranchData['body']) {\n return unwrapApiResult(await createBranch({ body, client: getClient() }));\n },\n\n async processFileMoves(\n moves: ProcessFileMovesData['body']['moves'],\n options: Pick<ProcessFileMovesData['body'], 'branchId'> & {\n timeout?: number;\n } = {}\n ) {\n const results = await processBatches(moves, async (batch) => {\n const response = unwrapApiResult(\n await processFileMoves({\n body: { branchId: options.branchId, moves: batch },\n client: getClient(options.timeout),\n })\n );\n return response.results;\n });\n const succeeded = results.filter(({ success }) => success).length;\n return {\n results,\n summary: {\n total: moves.length,\n succeeded,\n failed: results.length - succeeded,\n },\n };\n },\n\n async getOrphanedFiles(\n branchId: string,\n fileIds: string[],\n options: { timeout?: number } = {}\n ) {\n const request = async (batch: string[]) =>\n unwrapApiResult(\n await getOrphanedFiles({\n body: { branchId, fileIds: batch },\n client: getClient(options.timeout),\n })\n );\n\n if (fileIds.length === 0) return request([]);\n\n const results = await processBatches(fileIds, async (batch) => [\n await request(batch),\n ]);\n const orphanedFiles = new Map(\n results[0].orphanedFiles.map((file) => [file.fileId, file])\n );\n for (const result of results.slice(1)) {\n const batchFileIds = new Set(\n result.orphanedFiles.map((file) => file.fileId)\n );\n for (const fileId of Array.from(orphanedFiles.keys())) {\n if (!batchFileIds.has(fileId)) orphanedFiles.delete(fileId);\n }\n }\n return { orphanedFiles: Array.from(orphanedFiles.values()) };\n },\n\n async setupProject(\n files: GenerateProjectContextData['body']['files'],\n options: Omit<GenerateProjectContextData['body'], 'files'> & {\n timeoutMs?: number;\n } = {}\n ) {\n return unwrapApiResult(\n await generateProjectContext({\n body: {\n files: files.map(({ branchId, fileId, versionId }) => ({\n branchId,\n fileId,\n versionId,\n })),\n locales: options.locales?.map((locale) =>\n resolveServiceLocale(locale)\n ),\n force: options.force,\n },\n client: getClient(options.timeoutMs),\n })\n );\n },\n\n loadJobStatuses,\n\n async checkJobStatus(jobIds: string[], timeoutMs?: number) {\n const statuses = await loadJobStatuses(jobIds, { timeoutMs });\n return statuses.map(normalizeJobStatus);\n },\n\n async awaitJobs(jobIds: readonly string[], options?: AwaitJobsOptions) {\n const result = await pollJobs(\n jobIds,\n (pendingJobIds, signal) => loadJobStatuses(pendingJobIds, { signal }),\n options\n );\n return {\n ...result,\n jobs: result.jobs.map(normalizeJobStatus),\n };\n },\n\n async enqueueFiles(\n files: EnqueueFileTranslationsData['body']['files'],\n options: {\n sourceLocale?: string;\n targetLocales: string[];\n modelProvider?: string;\n force?: boolean;\n timeout?: number;\n }\n ) {\n validateFileFormatTransforms(files);\n const modelProvider = options.modelProvider;\n if (modelProvider !== undefined && !isModelProvider(modelProvider)) {\n throw new Error(\n createDiagnosticMessage({\n source: 'generaltranslation',\n severity: 'Error',\n whatHappened: `Unsupported model provider \\`${modelProvider}\\``,\n fix: `Use one of: ${supportedModelProviders.join(', ')}`,\n })\n );\n }\n const targetLocales = options.targetLocales.map((locale) =>\n resolveServiceLocale(locale)\n );\n const result = await processBatches(files, async (batch) => {\n const response = unwrapApiResult(\n await enqueueFileTranslations({\n body: {\n files: batch.map(\n ({\n branchId,\n fileId,\n versionId,\n fileName,\n transformFormat,\n }) => ({\n branchId,\n fileId,\n versionId,\n fileName,\n transformFormat,\n })\n ),\n targetLocales,\n sourceLocale: options.sourceLocale\n ? resolveServiceLocale(options.sourceLocale)\n : undefined,\n modelProvider,\n force: options.force,\n },\n client: getClient(options.timeout),\n })\n );\n const jobData =\n 'jobData' in response ? response.jobData : response.data;\n return Object.entries(jobData);\n });\n\n return {\n jobData: Object.fromEntries(result),\n locales: targetLocales,\n message: `Successfully enqueued ${result.length} file translation jobs in ${Math.ceil(files.length / DEFAULT_BATCH_SIZE)} batch(es)`,\n };\n },\n\n async createTag(body: CreateTagData['body']) {\n return unwrapApiResult(await createTag({ body, client: getClient() }));\n },\n\n async publishFiles(files: PublishFilesData['body']['files']) {\n // Compatibility callers pass entries carrying fileName; map only the\n // contract fields so nothing outside the generated body reaches the wire.\n return unwrapApiResult(\n await publishFiles({\n body: {\n files: files.map(({ fileId, versionId, branchId, publish }) => ({\n fileId,\n versionId,\n branchId,\n publish,\n })),\n },\n client: getClient(),\n })\n );\n },\n\n async submitUserEditDiffs(\n body: SubmitUserEditDiffsData['body'],\n options: { timeout?: number } = {}\n ) {\n return processBatches(body.diffs, async (diffs) => [\n unwrapApiResult(\n await submitUserEditDiffs({\n body: {\n projectId: body.projectId,\n diffs: diffs.map(\n ({\n diff,\n branchId,\n versionId,\n fileId,\n localContent,\n locale,\n }) => ({\n diff,\n branchId,\n versionId,\n fileId,\n localContent,\n locale: resolveServiceLocale(locale),\n })\n ),\n },\n client: getClient(options.timeout),\n })\n ),\n ]);\n },\n\n async createProject(\n orgId: CreateProjectData['path']['orgId'],\n body: CreateProjectData['body']\n ) {\n return unwrapApiResult(\n await createProject({\n path: { orgId },\n body: {\n ...body,\n defaultLocale: resolveServiceLocale(body.defaultLocale),\n },\n client: getClient(),\n })\n );\n },\n\n /** Projects the signed-in user is a member of, or the API key is bound to. */\n async listProjects() {\n return collect(paginate(listProjects, { client: getClient() }));\n },\n\n /** Organizations the credentials can access; listing one does not grant project creation. */\n async listOrgs() {\n return collect(paginate(listOrgs, { client: getClient() }));\n },\n\n async createProjectApiKey(\n projectId: CreateProjectApiKeyData['path']['projectId'],\n body: CreateProjectApiKeyData['body']\n ) {\n return unwrapApiResult(\n await createProjectApiKey({\n path: { projectId },\n body,\n client: getClient(),\n })\n );\n },\n\n loadProjectInfo,\n\n async getProjectInfo(projectId?: string, timeoutMs?: number) {\n const result = await loadProjectInfo(projectId, timeoutMs);\n return {\n ...result,\n defaultLocale: resolveAliasLocale(\n result.defaultLocale,\n config?.customMapping\n ),\n currentLocales: result.currentLocales.map((locale) =>\n resolveAliasLocale(locale, config?.customMapping)\n ),\n };\n },\n\n async queryFileData(body: GetFileInfoData['body'], timeoutMs?: number) {\n const result = unwrapApiResult(\n await getFileInfo({\n body: {\n ...body,\n translatedFiles: body.translatedFiles?.map((file) => ({\n ...file,\n locale: resolveServiceLocale(file.locale),\n })),\n },\n client: getClient(timeoutMs),\n })\n );\n return {\n ...result,\n translatedFiles: result.translatedFiles.map((file) => ({\n ...file,\n locale: resolveAliasLocale(file.locale, config?.customMapping),\n })),\n sourceFiles: result.sourceFiles.map((file) => ({\n ...file,\n sourceLocale: resolveAliasLocale(\n file.sourceLocale,\n config?.customMapping\n ),\n locales: file.locales.map((locale) =>\n resolveAliasLocale(locale, config?.customMapping)\n ),\n })),\n };\n },\n\n async querySourceFile(\n path: GetTranslationStatusData['path'],\n query: GetTranslationStatusData['query'] = {},\n timeoutMs?: number\n ) {\n const result = unwrapApiResult(\n await getTranslationStatus({\n path,\n query,\n client: getClient(timeoutMs),\n })\n );\n return {\n ...result,\n translations: result.translations.map((translation) => ({\n ...translation,\n locale: resolveAliasLocale(translation.locale, config?.customMapping),\n })),\n sourceFile: {\n ...result.sourceFile,\n sourceLocale: resolveAliasLocale(\n result.sourceFile.sourceLocale,\n config?.customMapping\n ),\n locales: result.sourceFile.locales.map((locale) =>\n resolveAliasLocale(locale, config?.customMapping)\n ),\n },\n };\n },\n\n async downloadFileBatch(\n files: DownloadFilesData['body'],\n options: { timeout?: number } = {}\n ) {\n const request = async (batch: DownloadFilesData['body']) =>\n unwrapApiResult(\n await downloadFiles({\n body: batch.map((file) => ({\n ...file,\n locale: file.locale\n ? resolveServiceLocale(file.locale)\n : undefined,\n })),\n client: getClient(options.timeout),\n })\n );\n const responses = await processBatches(files, async (batch) => [\n await request(batch),\n ]);\n return {\n files: responses.flatMap((response) =>\n response.files.map(\n (file): DownloadedFile => ({\n ...file,\n ...(file.locale && {\n locale: resolveAliasLocale(file.locale, config?.customMapping),\n }),\n data: decodeFileContent(file.data, file.fileFormat),\n metadata: file.metadata,\n })\n )\n ),\n count: responses.reduce((count, response) => count + response.count, 0),\n pending: responses.flatMap((response) =>\n (response.pending ?? []).map((file) => ({\n ...file,\n locale: resolveAliasLocale(file.locale, config?.customMapping),\n }))\n ),\n };\n },\n\n async uploadSourceFiles(\n files: Array<{\n source: UploadSourceFilesData['body']['data'][number]['source'];\n }>,\n options: { sourceLocale: string; timeout?: number }\n ) {\n const sourceLocale = resolveServiceLocale(options.sourceLocale);\n const result = await processBatches(files, async (batch) => {\n const response = unwrapApiResult(\n await uploadSourceFiles({\n body: {\n data: batch.map(({ source }) => ({\n source: {\n ...source,\n content: encodeFileContent(source.content, source.fileFormat),\n locale: resolveServiceLocale(source.locale),\n },\n })),\n sourceLocale,\n },\n client: getClient(options.timeout),\n })\n );\n return response.uploadedFiles.map(aliasUploadedFileLocale);\n });\n\n return { uploadedFiles: result };\n },\n\n async uploadFonts(\n fonts: UploadAssetsData['body']['assets'],\n options: { timeout?: number } = {}\n ) {\n const assets = await processBatches(\n fonts,\n async (batch) => {\n const result = unwrapApiResult(\n await uploadAssets({\n body: { assets: batch },\n client: getClient(options.timeout),\n })\n );\n return result.assets;\n },\n { batchSize: 50 }\n );\n return { assets, count: assets.length };\n },\n\n async uploadTranslations(\n files: UploadTranslationsData['body']['data'],\n options: { sourceLocale: string; timeout?: number }\n ) {\n validateFileFormatTransforms(files.map(({ source }) => source));\n const result = await processBatches(files, async (batch) => {\n const response = unwrapApiResult(\n await uploadTranslations({\n body: {\n data: batch.map(({ source, translations }) => ({\n source: {\n ...source,\n content: encodeFileContent(source.content, source.fileFormat),\n locale: resolveServiceLocale(source.locale),\n },\n translations: translations.map((translation) => ({\n ...translation,\n locale: resolveServiceLocale(translation.locale),\n content: encodeFileContent(\n translation.content,\n translation.fileFormat\n ),\n })),\n })),\n sourceLocale: resolveServiceLocale(options.sourceLocale),\n },\n client: getClient(options.timeout),\n })\n );\n return response.uploadedFiles.map(aliasUploadedFileLocale);\n });\n\n return { uploadedFiles: result };\n },\n };\n}\n\nexport type GtApiAdapter = ReturnType<typeof createGtApiAdapter>;\n","import {\n parse,\n TYPE,\n type MessageFormatElement,\n type ParserOptions,\n} from '@generaltranslation/icu';\n\ntype TraverseIcuOptions = ParserOptions & {\n recurseIntoVisited?: boolean;\n};\n\n/**\n * Given an ICU string, traverse the AST and call the visitor function for each element that matches the type T\n * @param icu - The ICU string to traverse\n * @param shouldVisit - A function that returns true if the element should be visited\n * @param visitor - A function that is called for each element that matches the type T\n * @returns The modified AST of the ICU string.\n *\n * @note This function is a heavy operation, use sparingly\n */\nexport function traverseIcu<T extends MessageFormatElement>({\n icuString,\n shouldVisit,\n visitor,\n options: { recurseIntoVisited = true, ...otherOptions },\n}: {\n icuString: string;\n shouldVisit: (element: MessageFormatElement) => element is T;\n visitor: (element: T) => void;\n options: TraverseIcuOptions;\n}): MessageFormatElement[] {\n const ast = parse(icuString, otherOptions);\n handleChildren(ast);\n return ast;\n\n function handleChildren(children: MessageFormatElement[]): void {\n children.map(handleChild);\n }\n\n function handleChild(child: MessageFormatElement) {\n // handle select var\n let visited = false;\n if (shouldVisit(child)) {\n visitor(child);\n visited = true;\n }\n // recurse on children\n if (!visited || recurseIntoVisited) {\n if (child.type === TYPE.select || child.type === TYPE.plural) {\n Object.values(child.options)\n .map((option) => option.value)\n .map(handleChildren);\n } else if (child.type === TYPE.tag) {\n handleChildren(child.children);\n }\n }\n }\n}\n","export const VAR_IDENTIFIER = '_gt_';\nexport const VAR_NAME_IDENTIFIER = '_gt_var_name';\n","import { VAR_IDENTIFIER } from './constants';\n\n// Regex for _gt_# select\nexport const GT_INDEXED_IDENTIFIER_REGEX = new RegExp(\n `^${VAR_IDENTIFIER}\\\\d+$`\n);\n\nexport const GT_UNINDEXED_IDENTIFIER_REGEX = new RegExp(`^${VAR_IDENTIFIER}$`);\n","import {\n GT_INDEXED_IDENTIFIER_REGEX,\n GT_UNINDEXED_IDENTIFIER_REGEX,\n} from './regex';\nimport { GTIndexedSelectElement, GTUnindexedSelectElement } from './types';\nimport { TYPE, type MessageFormatElement } from '@generaltranslation/icu';\n\n// Visit any _gt_# select\nexport function isGTIndexedSelectElement(\n child: MessageFormatElement\n): child is GTIndexedSelectElement {\n return (\n child.type === TYPE.select &&\n GT_INDEXED_IDENTIFIER_REGEX.test(child.value) &&\n !!child.options.other &&\n (child.options.other.value.length === 0 ||\n (child.options.other.value.length > 0 &&\n child.options.other.value[0]?.type === TYPE.literal))\n );\n}\n\n// Visit any _gt_ select\nexport function isGTUnindexedSelectElement(\n child: MessageFormatElement\n): child is GTUnindexedSelectElement {\n return (\n child.type === TYPE.select &&\n GT_UNINDEXED_IDENTIFIER_REGEX.test(child.value) &&\n !!child.options.other &&\n (child.options.other.value.length === 0 ||\n (child.options.other.value.length > 0 &&\n child.options.other.value[0]?.type === TYPE.literal))\n );\n}\n","import { traverseIcu } from './utils/traverseIcu';\nimport { VAR_IDENTIFIER } from './utils/constants';\nimport { GTUnindexedSelectElement } from './utils/types';\nimport { isGTUnindexedSelectElement } from './utils/traverseHelpers';\n\ntype Location = {\n start: number;\n end: number;\n value: string;\n};\n\n/**\n * Given an encoded ICU string, interpolate only _gt_ variables that have been marked with declareVar()\n * @example\n * const encodedIcu = \"Hi\" + declareVar(\"Brian\") + \", my name is {name}\"\n * // 'Hi {_gt_, select, other {Brian}}, my name is {name}'\n * decodeVars(encodedIcu)\n * // 'Hi Brian, my name is {name}'\n */\nexport function decodeVars(icuString: string): string {\n // Check if the string contains _gt_\n if (!icuString.includes(VAR_IDENTIFIER)) {\n return icuString;\n }\n\n // Record the location of the variable\n const variableLocations: Location[] = [];\n function visitor(child: GTUnindexedSelectElement): void {\n variableLocations.push({\n start: child.location?.start.offset ?? 0,\n end: child.location?.end.offset ?? 0,\n value:\n child.options.other.value.length > 0\n ? child.options.other.value[0].value\n : '',\n });\n }\n\n // Find all variable identifiers.\n traverseIcu({\n icuString,\n shouldVisit: isGTUnindexedSelectElement,\n visitor,\n options: {\n recurseIntoVisited: false,\n captureLocation: true,\n },\n });\n\n // Construct output string\n let previousIndex = 0;\n const outputList = [];\n for (let i = 0; i < variableLocations.length; i++) {\n outputList.push(icuString.slice(previousIndex, variableLocations[i].start));\n outputList.push(variableLocations[i].value);\n previousIndex = variableLocations[i].end;\n }\n if (previousIndex < icuString.length) {\n outputList.push(icuString.slice(previousIndex));\n }\n const outputString = outputList.join('');\n\n return outputString;\n}\n","/**\n * Sanitizes string by escaping ICU syntax\n *\n * Sanitize arbitrary string so it does not break the following ICU message syntax:\n * {_gt_, select, other {string_here}}\n *\n * Escapes ICU special characters by:\n * 1. Doubling all single quotes (U+0027 ')\n * 2. Adding a single quote before the first special character ({}<>)\n * 3. Adding a single quote after the last special character ({}<>)\n */\nexport function sanitizeVar(string: string): string {\n // First, double all single quotes (both ASCII and Unicode).\n let result = string.replace(/'/g, \"''\");\n\n // Find first and last positions of special characters\n const specialChars = /[{}<>]/;\n const firstSpecialIndex = result.search(specialChars);\n\n if (firstSpecialIndex === -1) {\n // No special characters; return with just doubled quotes.\n return result;\n }\n\n // Find last special character position\n let lastSpecialIndex = -1;\n for (let i = result.length - 1; i >= 0; i--) {\n if (specialChars.test(result[i])) {\n lastSpecialIndex = i;\n break;\n }\n }\n\n // Insert quotes around the special character region.\n result =\n result.slice(0, firstSpecialIndex) +\n \"'\" +\n result.slice(firstSpecialIndex, lastSpecialIndex + 1) +\n \"'\" +\n result.slice(lastSpecialIndex + 1);\n\n return result;\n}\n","import { VAR_IDENTIFIER, VAR_NAME_IDENTIFIER } from './utils/constants';\nimport { sanitizeVar } from './utils/sanitizeVar';\n\n/**\n * Mark as a non-translatable string. Use within a derive() call to mark content as not derivable (e.g., not possible to statically analyze).\n *\n * @example\n * function nonDerivableFunction() {\n * return Math.random();\n * }\n *\n * function derivableFunction() {\n * if (condition) {\n * return declareVar(nonDerivableFunction())\n * }\n * return 'John Doe';\n * }\n *\n * const gt = useGT();\n * gt(`My name is ${derive(derivableFunction())}`);\n *\n * @param {string | number | boolean | null | undefined} variable - The variable to sanitize.\n * @param {Object} [options] - The options for the sanitization.\n * @param {string} [options.$name] - The name of the variable.\n * @returns {string} The sanitized value.\n */\nexport function declareVar(\n variable: string | number | boolean | null | undefined,\n options?: { $name?: string }\n): string {\n // Variable section.\n const sanitizedVariable = sanitizeVar(String(variable ?? ''));\n const variableSection = ` other {${sanitizedVariable}}`;\n\n // Name section.\n let nameSection = '';\n if (options?.$name) {\n const sanitizedName = sanitizeVar(options.$name);\n nameSection = ` ${VAR_NAME_IDENTIFIER} {${sanitizedName}}`;\n }\n\n // interpolate\n return `{${VAR_IDENTIFIER}, select,${variableSection}${nameSection}}`;\n}\n","/**\n * Marks content as derivable by the GT compiler and CLI.\n *\n * Use `derive()` when a translation string or context needs content that is\n * computed from source code, but should still be discovered during extraction\n * instead of treated as a runtime interpolation variable. The CLI attempts to\n * resolve the derivable expression into every possible static value and\n * includes those values in the source content that gets translated.\n *\n * `derive()` returns its argument unchanged at runtime.\n *\n * Run `gt validate` after adding or changing `derive()` calls to verify that\n * each derivable expression can be resolved by the CLI before translating or\n * building.\n *\n * @example\n * ```jsx\n * function getSubject() {\n * return (Math.random() > 0.5) ? \"Alice\" : \"Brian\";\n * }\n * ...\n * gt(`My name is ${derive(getSubject())}`);\n * ```\n *\n * @param {T extends string | boolean | number | null | undefined} content - Content to derive for translation extraction.\n * @returns {T} The same content, unchanged at runtime.\n */\nexport function derive<T extends string | boolean | number | null | undefined>(\n content: T\n): T {\n return content;\n}\n"],"mappings":";;;;;;;AAGA,SAAgB,OAAO,MAAsB;AAC3C,KAAI,OAAO,WAAW,YAEpB,QAAO,OAAO,KAAK,MAAM,OAAO,CAAC,SAAS,SAAS;CAGrD,MAAM,QAAQ,IAAI,aAAa,CAAC,OAAO,KAAK;CAC5C,IAAI,SAAS;AACb,MAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,IAChC,WAAU,OAAO,aAAa,MAAM,GAAG;AAEzC,QAAO,KAAK,OAAO;;AAIrB,SAAgB,OAAO,QAAwB;AAC7C,KAAI,OAAO,WAAW,YAEpB,QAAO,OAAO,KAAK,QAAQ,SAAS,CAAC,SAAS,OAAO;CAGvD,MAAM,SAAS,KAAK,OAAO;CAC3B,MAAM,QAAQ,IAAI,WAAW,OAAO,OAAO;AAC3C,MAAK,IAAI,IAAI,GAAG,IAAI,OAAO,QAAQ,IACjC,OAAM,KAAK,OAAO,WAAW,EAAE;AAEjC,QAAO,IAAI,aAAa,CAAC,OAAO,MA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I,IAAI,OAAO,SAAS,GAAG,KAAK,GAAG,IACtC,KAAI,aAAa,KAAK,OAAO,GAAG,EAAE;AAChC,qBAAmB;AACnB;;AAKJ,UACE,OAAO,MAAM,GAAG,kBAAkB,GAClC,MACA,OAAO,MAAM,mBAAmB,mBAAmB,EAAE,GACrD,MACA,OAAO,MAAM,mBAAmB,EAAE;AAEpC,QAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;ACfT,SAAgB,WACd,UACA,SACQ;CAGR,MAAM,kBAAkB,WADE,YAAY,OAAO,YAAY,GAAG,CACR,CAAC;CAGrD,IAAI,cAAc;AAClB,KAAI,SAAS,MAEX,eAAc,IAAI,oBAAoB,IADhB,YAAY,QAAQ,MACa,CAAC;AAI1D,QAAO,IAAI,eAAe,WAAW,kBAAkB,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACfrE,SAAgB,OACd,SACG;AACH,QAAO"}
package/dist/id.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { _ as JsxChildren, jt as HashMetadata } from "./types-yByDbKnV.cjs";
1
+ import { _ as JsxChildren, jt as HashMetadata } from "./types-BxgnFr8M.cjs";
2
2
 
3
3
  //#region src/id/hashSource.d.ts
4
4
  /**
package/dist/id.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { _ as JsxChildren, jt as HashMetadata } from "./types-CEsh60Yt.mjs";
1
+ import { _ as JsxChildren, jt as HashMetadata } from "./types-Ix4SHG5H.mjs";
2
2
 
3
3
  //#region src/id/hashSource.d.ts
4
4
  /**
package/dist/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_runtimeTranslate = require("./runtimeTranslate-_gLYFBvE.cjs");
3
- const require_derive = require("./derive-CS-paSZ9.cjs");
2
+ const require_runtimeTranslate = require("./runtimeTranslate-B8BLxD_U.cjs");
3
+ const require_derive = require("./derive-DPDgh_1v.cjs");
4
4
  const require_runtime = require("./runtime.cjs");
5
5
  let _generaltranslation_format = require("@generaltranslation/format");
6
6
  //#region src/index.ts
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as DownloadFileOptions, Ct as FileQueryResult, F as SubmitUserEditDiffsPayload, G as FileDataQuery, I as AwaitJobsOptions$1, J as BranchDataResult, K as FileDataResult, L as AwaitJobsResult, St as FileQuery, U as ProcessMovesOptions, V as MoveMapping, W as ProcessMovesResponse, at as SetupProjectFileReference, ct as EnqueueFilesOptions, dt as DownloadFileBatchResult, et as PublishFileEntry, gt as FileReferenceIds, it as UploadFilesResponse, lt as DownloadFileBatchOptions, n as CreateTagOptions, nt as FileUpload, ot as SetupProjectOptions, q as BranchQuery, r as CreateTagResult, rt as UploadFilesOptions, st as SetupProjectResult, tt as PublishFilesResult, u as GetOrphanedFilesResult, ut as DownloadFileBatchRequest, xt as CheckFileTranslationsOptions, yt as EnqueueFilesResult, z as CheckJobStatusResult } from "./types-yByDbKnV.cjs";
1
+ import { $ as DownloadFileOptions, Ct as FileQueryResult, F as SubmitUserEditDiffsPayload, G as FileDataQuery, I as AwaitJobsOptions$1, J as BranchDataResult, K as FileDataResult, L as AwaitJobsResult, St as FileQuery, U as ProcessMovesOptions, V as MoveMapping, W as ProcessMovesResponse, at as SetupProjectFileReference, ct as EnqueueFilesOptions, dt as DownloadFileBatchResult, et as PublishFileEntry, gt as FileReferenceIds, it as UploadFilesResponse, lt as DownloadFileBatchOptions, n as CreateTagOptions, nt as FileUpload, ot as SetupProjectOptions, q as BranchQuery, r as CreateTagResult, rt as UploadFilesOptions, st as SetupProjectResult, tt as PublishFilesResult, u as GetOrphanedFilesResult, ut as DownloadFileBatchRequest, xt as CheckFileTranslationsOptions, yt as EnqueueFilesResult, z as CheckJobStatusResult } from "./types-BxgnFr8M.cjs";
2
2
  import { GTConstructorParams, GTRuntime } from "./runtime.cjs";
3
3
  import { n as declareVar, r as decodeVars, t as derive } from "./derive-J2NQLqZm.cjs";
4
4
  import { CreateBranchResponse, GetProjectInfoResponse, UploadAssetsResponse } from "@generaltranslation/api";
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as DownloadFileOptions, Ct as FileQueryResult, F as SubmitUserEditDiffsPayload, G as FileDataQuery, I as AwaitJobsOptions$1, J as BranchDataResult, K as FileDataResult, L as AwaitJobsResult, St as FileQuery, U as ProcessMovesOptions, V as MoveMapping, W as ProcessMovesResponse, at as SetupProjectFileReference, ct as EnqueueFilesOptions, dt as DownloadFileBatchResult, et as PublishFileEntry, gt as FileReferenceIds, it as UploadFilesResponse, lt as DownloadFileBatchOptions, n as CreateTagOptions, nt as FileUpload, ot as SetupProjectOptions, q as BranchQuery, r as CreateTagResult, rt as UploadFilesOptions, st as SetupProjectResult, tt as PublishFilesResult, u as GetOrphanedFilesResult, ut as DownloadFileBatchRequest, xt as CheckFileTranslationsOptions, yt as EnqueueFilesResult, z as CheckJobStatusResult } from "./types-CEsh60Yt.mjs";
1
+ import { $ as DownloadFileOptions, Ct as FileQueryResult, F as SubmitUserEditDiffsPayload, G as FileDataQuery, I as AwaitJobsOptions$1, J as BranchDataResult, K as FileDataResult, L as AwaitJobsResult, St as FileQuery, U as ProcessMovesOptions, V as MoveMapping, W as ProcessMovesResponse, at as SetupProjectFileReference, ct as EnqueueFilesOptions, dt as DownloadFileBatchResult, et as PublishFileEntry, gt as FileReferenceIds, it as UploadFilesResponse, lt as DownloadFileBatchOptions, n as CreateTagOptions, nt as FileUpload, ot as SetupProjectOptions, q as BranchQuery, r as CreateTagResult, rt as UploadFilesOptions, st as SetupProjectResult, tt as PublishFilesResult, u as GetOrphanedFilesResult, ut as DownloadFileBatchRequest, xt as CheckFileTranslationsOptions, yt as EnqueueFilesResult, z as CheckJobStatusResult } from "./types-Ix4SHG5H.mjs";
2
2
  import { GTConstructorParams, GTRuntime } from "./runtime.mjs";
3
3
  import { n as declareVar, r as decodeVars, t as derive } from "./derive-VfZjYfIU.mjs";
4
4
  import { CreateBranchResponse, GetProjectInfoResponse, UploadAssetsResponse } from "@generaltranslation/api";
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { c as gtInstanceLogger, d as noSourceLocaleProvidedError, f as noTargetLocaleProvidedError, r as validateAuth } from "./runtimeTranslate-CI936gg9.mjs";
2
- import { c as createGtApiAdapter, n as declareVar, r as decodeVars, t as derive } from "./derive-Ctj9wXCT.mjs";
1
+ import { c as gtInstanceLogger, d as noSourceLocaleProvidedError, f as noTargetLocaleProvidedError, r as validateAuth } from "./runtimeTranslate-CRWJMYly.mjs";
2
+ import { c as createGtApiAdapter, n as declareVar, r as decodeVars, t as derive } from "./derive-DZR18WqK.mjs";
3
3
  import { GTRuntime } from "./runtime.mjs";
4
4
  import { LocaleConfig, 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";
5
5
  //#region src/index.ts
package/dist/internal.cjs CHANGED
@@ -1,8 +1,8 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_runtimeTranslate = require("./runtimeTranslate-_gLYFBvE.cjs");
2
+ const require_runtimeTranslate = require("./runtimeTranslate-B8BLxD_U.cjs");
3
3
  const require_diagnostics = require("./diagnostics-DKtiPUvo.cjs");
4
4
  const require_id = require("./id-DJ_59q21.cjs");
5
- const require_derive = require("./derive-CS-paSZ9.cjs");
5
+ const require_derive = require("./derive-DPDgh_1v.cjs");
6
6
  let _generaltranslation_api = require("@generaltranslation/api");
7
7
  let _generaltranslation_icu = require("@generaltranslation/icu");
8
8
  let _generaltranslation_format_internal = require("@generaltranslation/format/internal");
@@ -56,7 +56,7 @@ const VARIABLE_TRANSFORMATION_SUFFIXES_TO_MINIFIED_NAMES = {
56
56
  number: "n",
57
57
  datetime: "d",
58
58
  currency: "c",
59
- "relative-time": "rt"
59
+ relativetime: "rt"
60
60
  };
61
61
  function minifyVariableType(variableType) {
62
62
  return VARIABLE_TRANSFORMATION_SUFFIXES_TO_MINIFIED_NAMES[variableType];
@@ -1 +1 @@
1
- {"version":3,"file":"internal.cjs","names":["isGTUnindexedSelectElement","VAR_IDENTIFIER","isGTUnindexedSelectElement","VAR_IDENTIFIER","TYPE","traverseIcu","isGTIndexedSelectElement"],"sources":["../src/settings/plurals.ts","../src/locales/getPluralForm.ts","../src/utils/minify.ts","../src/derive/indexVars.ts","../src/derive/extractVars.ts","../src/derive/condenseVars.ts"],"sourcesContent":["export const pluralForms = [\n 'singular',\n 'plural',\n 'dual',\n 'zero',\n 'one',\n 'two',\n 'few',\n 'many',\n 'other',\n] as const;\nexport type PluralType = (typeof pluralForms)[number];\nexport function isAcceptedPluralForm(form: string): form is PluralType {\n return pluralForms.includes(form as (typeof pluralForms)[number]);\n}\n","import { getCachedPluralRules } from '@generaltranslation/format/internal';\n\nimport { pluralForms, PluralType } from '../settings/plurals';\nimport { libraryDefaultLocale } from '../settings/settings';\n\n/**\n * Given a number and a list of allowed plural forms, return the plural form that best fits the number.\n *\n * @param {number} n - The number to determine the plural form for.\n * @param {PluralType[]} forms - The allowed plural forms.\n * @returns {PluralType} The determined plural form, or an empty string if none fit.\n */\nexport function _getPluralForm(\n n: number,\n forms: readonly PluralType[] = pluralForms,\n locales: string[] = [libraryDefaultLocale]\n): PluralType | '' {\n const pluralRules = getCachedPluralRules(locales);\n const provisionalBranchName = pluralRules.select(n);\n // aliases\n const absN = Math.abs(n);\n // 0\n if (absN === 0 && forms.includes('zero')) return 'zero'; // override\n // 1\n if (absN === 1) {\n if (forms.includes('singular')) return 'singular'; // override\n if (forms.includes('one')) return 'one'; // override\n }\n if (provisionalBranchName === 'one' && forms.includes('singular'))\n return 'singular';\n // 2\n if (absN === 2) {\n if (forms.includes('dual')) return 'dual'; // override\n if (forms.includes('two')) return 'two'; // override\n }\n if (provisionalBranchName === 'two' && forms.includes('dual')) return 'dual';\n // fallbacks\n if (forms.includes(provisionalBranchName)) return provisionalBranchName;\n if (forms.includes('plural')) return 'plural';\n if (forms.includes('other')) return 'other';\n return '';\n}\n","import { VariableTransformationSuffix, VariableType } from '../types';\n\nconst VARIABLE_TRANSFORMATION_SUFFIXES_TO_MINIFIED_NAMES = {\n variable: 'v',\n number: 'n',\n datetime: 'd',\n currency: 'c',\n 'relative-time': 'rt',\n} as const;\n\nexport function minifyVariableType(\n variableType: VariableTransformationSuffix\n): VariableType {\n return VARIABLE_TRANSFORMATION_SUFFIXES_TO_MINIFIED_NAMES[variableType];\n}\n","import { VAR_IDENTIFIER } from './utils/constants';\nimport { traverseIcu } from './utils/traverseIcu';\nimport { GTUnindexedSelectElement } from './utils/types';\nimport { isGTUnindexedSelectElement } from './utils/traverseHelpers';\nimport type { IcuMessage } from '@generaltranslation/format/types';\n\ntype Location = {\n start: number;\n end: number;\n otherStart: number;\n otherEnd: number;\n};\n\n/**\n * Given an ICU string adds identifiers to each _gt_ placeholder\n * indexVars('Hello {_gt_} {_gt_} World') => 'Hello {_gt_1_} {_gt_2_} World'\n */\nexport function indexVars(icuString: IcuMessage): string {\n // Check if the string contains _gt_\n if (!icuString.includes(VAR_IDENTIFIER)) {\n return icuString;\n }\n\n // Record the location of the variable\n const variableLocations: Location[] = [];\n function visitor(child: GTUnindexedSelectElement): void {\n variableLocations.push({\n start: child.location?.start.offset ?? 0,\n end: child.location?.end.offset ?? 0,\n otherStart: child.options.other.location?.start.offset ?? 0,\n otherEnd: child.options.other.location?.end.offset ?? 0,\n });\n }\n\n // Find all variable identifiers.\n traverseIcu({\n icuString,\n shouldVisit: isGTUnindexedSelectElement,\n visitor,\n options: { recurseIntoVisited: false, captureLocation: true },\n });\n\n // Index each variable and collapse the other option.\n const result = [];\n let current = 0;\n for (let i = 0; i < variableLocations.length; i++) {\n const { start, end, otherStart, otherEnd } = variableLocations[i];\n // Before the variable\n result.push(icuString.slice(current, start));\n // Replace the variable with the new identifier (+1 is for the curly brace)\n result.push(icuString.slice(start, start + VAR_IDENTIFIER.length + 1));\n\n // Add the new identifier.\n result.push(String(i + 1));\n // After the variable\n result.push(icuString.slice(start + VAR_IDENTIFIER.length + 1, otherStart));\n // Before the other option\n result.push('{}');\n // The other option\n result.push(icuString.slice(otherEnd, end));\n current = end;\n }\n result.push(icuString.slice(current, icuString.length));\n\n return result.join('');\n}\n","import { VAR_IDENTIFIER } from './utils/constants';\nimport { isGTUnindexedSelectElement } from './utils/traverseHelpers';\nimport { traverseIcu } from './utils/traverseIcu';\nimport { GTUnindexedSelectElement } from './utils/types';\n/**\n * Given an unindexed ICU string, extracts all the _gt_ variables and an indexed mapping of the variable to the values\n *\n * extractVars('Hello {_gt_, select, other {World}}') => { _gt_1: 'World' }\n *\n * @param {string} icuString - The ICU string to extract variables from.\n * @returns {Record<string, string>} A mapping of the variable to the value.\n */\nexport function extractVars(icuString: string): Record<string, string> {\n // Check if the string contains _gt_\n if (!icuString.includes(VAR_IDENTIFIER)) {\n return {};\n }\n\n // Extract all the _gt_# variables\n let index = 1;\n const variables: Record<string, string> = {};\n function visitor(child: GTUnindexedSelectElement): void {\n variables[child.value + index] = child.options.other.value.length\n ? child.options.other.value[0]?.value\n : '';\n index += 1;\n }\n\n traverseIcu({\n icuString,\n shouldVisit: isGTUnindexedSelectElement,\n visitor,\n options: { recurseIntoVisited: false },\n });\n\n return variables;\n}\n","import { printAST, TYPE, type ArgumentElement } from '@generaltranslation/icu';\nimport { traverseIcu } from './utils/traverseIcu';\nimport { VAR_IDENTIFIER } from './utils/constants';\nimport { GTIndexedSelectElement } from './utils/types';\nimport { isGTIndexedSelectElement } from './utils/traverseHelpers';\ninterface GTIndexedArgumentElement extends ArgumentElement {\n value: `${typeof VAR_IDENTIFIER}${number}`;\n}\n\nconst CONTAINS_INDEXED_GT_REGEX = new RegExp(`${VAR_IDENTIFIER}\\\\d+`);\n\n/**\n * Given an indexed ICU string, condenses any select to an argument\n * Unindexed _gt_ source strings and indexed _gt_# translation strings\n * are mutually exclusive.\n * indexVars('Hello {_gt_1, select, other {World}}') => 'Hello {_gt_1}'\n * @param {string} icuString - The ICU string to condense.\n * @returns {string} The condensed ICU string.\n */\nexport function condenseVars(icuString: string): string {\n // Check if the string contains an indexed _gt_ identifier.\n if (!CONTAINS_INDEXED_GT_REGEX.test(icuString)) {\n return icuString;\n }\n\n // Replace with argument\n function visitor(child: GTIndexedSelectElement): void {\n (child as unknown as GTIndexedArgumentElement).type = TYPE.argument;\n Reflect.deleteProperty(child, 'options');\n }\n\n const ast = traverseIcu({\n icuString,\n shouldVisit: isGTIndexedSelectElement,\n visitor,\n options: { recurseIntoVisited: false },\n });\n\n // Serialize\n return printAST(ast);\n}\n"],"mappings":";;;;;;;;;AAAA,MAAa,cAAc;CACzB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AAED,SAAgB,qBAAqB,MAAkC;AACrE,QAAO,YAAY,SAAS,KAAqC;;;;;;;;;;;ACDnE,SAAgB,eACd,GACA,QAA+B,aAC/B,UAAoB,CAAA,KAAsB,EACzB;CAEjB,MAAM,yBAAA,GAAA,oCAAA,sBADmC,QACA,CAAC,OAAO,EAAE;CAEnD,MAAM,OAAO,KAAK,IAAI,EAAE;AAExB,KAAI,SAAS,KAAK,MAAM,SAAS,OAAO,CAAE,QAAO;AAEjD,KAAI,SAAS,GAAG;AACd,MAAI,MAAM,SAAS,WAAW,CAAE,QAAO;AACvC,MAAI,MAAM,SAAS,MAAM,CAAE,QAAO;;AAEpC,KAAI,0BAA0B,SAAS,MAAM,SAAS,WAAW,CAC/D,QAAO;AAET,KAAI,SAAS,GAAG;AACd,MAAI,MAAM,SAAS,OAAO,CAAE,QAAO;AACnC,MAAI,MAAM,SAAS,MAAM,CAAE,QAAO;;AAEpC,KAAI,0BAA0B,SAAS,MAAM,SAAS,OAAO,CAAE,QAAO;AAEtE,KAAI,MAAM,S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U,OAAO,CAAC;AAEvD,QAAO,OAAO,KAAK,GAAG;;;;;;;;;;;;ACpDxB,SAAgB,YAAY,WAA2C;AAErE,KAAI,CAAC,UAAU,SAAA,OAAwB,CACrC,QAAO,EAAE;CAIX,IAAI,QAAQ;CACZ,MAAM,YAAoC,EAAE;CAC5C,SAAS,QAAQ,OAAuC;AACtD,YAAU,MAAM,QAAQ,SAAS,MAAM,QAAQ,MAAM,MAAM,SACvD,MAAM,QAAQ,MAAM,MAAM,IAAI,QAC9B;AACJ,WAAS;;AAGX,gBAAA,YAAY;EACV;EACA,aAAaC,eAAAA;EACb;EACA,SAAS,EAAE,oBAAoB,OAAO;EACvC,CAAC;AAEF,QAAO;;;;AC1BT,MAAM,4BAA4B,IAAI,OAAO,GAAGC,eAAAA,eAAe,MAAM;;;;;;;;;AAUrE,SAAgB,aAAa,WAA2B;AAEtD,KAAI,CAAC,0BAA0B,KAAK,UAAU,CAC5C,QAAO;CAIT,SAAS,QAAQ,OAAqC;AACnD,QAA8C,OAAOC,wBAAAA,KAAK;AAC3D,UAAQ,eAAe,OAAO,UAAU;;AAW1C,SAAA,GAAA,wBAAA,UARYC,eAAAA,YAAY;EACtB;EACA,aAAaC,eAAAA;EACb;EACA,SAAS,EAAE,oBAAoB,OAAO;EACvC,CAGkB,CAAC"}
1
+ {"version":3,"file":"internal.cjs","names":["isGTUnindexedSelectElement","VAR_IDENTIFIER","isGTUnindexedSelectElement","VAR_IDENTIFIER","TYPE","traverseIcu","isGTIndexedSelectElement"],"sources":["../src/settings/plurals.ts","../src/locales/getPluralForm.ts","../src/utils/minify.ts","../src/derive/indexVars.ts","../src/derive/extractVars.ts","../src/derive/condenseVars.ts"],"sourcesContent":["export const pluralForms = [\n 'singular',\n 'plural',\n 'dual',\n 'zero',\n 'one',\n 'two',\n 'few',\n 'many',\n 'other',\n] as const;\nexport type PluralType = (typeof pluralForms)[number];\nexport function isAcceptedPluralForm(form: string): form is PluralType {\n return pluralForms.includes(form as (typeof pluralForms)[number]);\n}\n","import { getCachedPluralRules } from '@generaltranslation/format/internal';\n\nimport { pluralForms, PluralType } from '../settings/plurals';\nimport { libraryDefaultLocale } from '../settings/settings';\n\n/**\n * Given a number and a list of allowed plural forms, return the plural form that best fits the number.\n *\n * @param {number} n - The number to determine the plural form for.\n * @param {PluralType[]} forms - The allowed plural forms.\n * @returns {PluralType} The determined plural form, or an empty string if none fit.\n */\nexport function _getPluralForm(\n n: number,\n forms: readonly PluralType[] = pluralForms,\n locales: string[] = [libraryDefaultLocale]\n): PluralType | '' {\n const pluralRules = getCachedPluralRules(locales);\n const provisionalBranchName = pluralRules.select(n);\n // aliases\n const absN = Math.abs(n);\n // 0\n if (absN === 0 && forms.includes('zero')) return 'zero'; // override\n // 1\n if (absN === 1) {\n if (forms.includes('singular')) return 'singular'; // override\n if (forms.includes('one')) return 'one'; // override\n }\n if (provisionalBranchName === 'one' && forms.includes('singular'))\n return 'singular';\n // 2\n if (absN === 2) {\n if (forms.includes('dual')) return 'dual'; // override\n if (forms.includes('two')) return 'two'; // override\n }\n if (provisionalBranchName === 'two' && forms.includes('dual')) return 'dual';\n // fallbacks\n if (forms.includes(provisionalBranchName)) return provisionalBranchName;\n if (forms.includes('plural')) return 'plural';\n if (forms.includes('other')) return 'other';\n return '';\n}\n","import { VariableTransformationSuffix, VariableType } from '../types';\n\nconst VARIABLE_TRANSFORMATION_SUFFIXES_TO_MINIFIED_NAMES = {\n variable: 'v',\n number: 'n',\n datetime: 'd',\n currency: 'c',\n relativetime: 'rt',\n} as const;\n\nexport function minifyVariableType(\n variableType: VariableTransformationSuffix\n): VariableType {\n return VARIABLE_TRANSFORMATION_SUFFIXES_TO_MINIFIED_NAMES[variableType];\n}\n","import { VAR_IDENTIFIER } from './utils/constants';\nimport { traverseIcu } from './utils/traverseIcu';\nimport { GTUnindexedSelectElement } from './utils/types';\nimport { isGTUnindexedSelectElement } from './utils/traverseHelpers';\nimport type { IcuMessage } from '@generaltranslation/format/types';\n\ntype Location = {\n start: number;\n end: number;\n otherStart: number;\n otherEnd: number;\n};\n\n/**\n * Given an ICU string adds identifiers to each _gt_ placeholder\n * indexVars('Hello {_gt_} {_gt_} World') => 'Hello {_gt_1_} {_gt_2_} World'\n */\nexport function indexVars(icuString: IcuMessage): string {\n // Check if the string contains _gt_\n if (!icuString.includes(VAR_IDENTIFIER)) {\n return icuString;\n }\n\n // Record the location of the variable\n const variableLocations: Location[] = [];\n function visitor(child: GTUnindexedSelectElement): void {\n variableLocations.push({\n start: child.location?.start.offset ?? 0,\n end: child.location?.end.offset ?? 0,\n otherStart: child.options.other.location?.start.offset ?? 0,\n otherEnd: child.options.other.location?.end.offset ?? 0,\n });\n }\n\n // Find all variable identifiers.\n traverseIcu({\n icuString,\n shouldVisit: isGTUnindexedSelectElement,\n visitor,\n options: { recurseIntoVisited: false, captureLocation: true },\n });\n\n // Index each variable and collapse the other option.\n const result = [];\n let current = 0;\n for (let i = 0; i < variableLocations.length; i++) {\n const { start, end, otherStart, otherEnd } = variableLocations[i];\n // Before the variable\n result.push(icuString.slice(current, start));\n // Replace the variable with the new identifier (+1 is for the curly brace)\n result.push(icuString.slice(start, start + VAR_IDENTIFIER.length + 1));\n\n // Add the new identifier.\n result.push(String(i + 1));\n // After the variable\n result.push(icuString.slice(start + VAR_IDENTIFIER.length + 1, otherStart));\n // Before the other option\n result.push('{}');\n // The other option\n result.push(icuString.slice(otherEnd, end));\n current = end;\n }\n result.push(icuString.slice(current, icuString.length));\n\n return result.join('');\n}\n","import { VAR_IDENTIFIER } from './utils/constants';\nimport { isGTUnindexedSelectElement } from './utils/traverseHelpers';\nimport { traverseIcu } from './utils/traverseIcu';\nimport { GTUnindexedSelectElement } from './utils/types';\n/**\n * Given an unindexed ICU string, extracts all the _gt_ variables and an indexed mapping of the variable to the values\n *\n * extractVars('Hello {_gt_, select, other {World}}') => { _gt_1: 'World' }\n *\n * @param {string} icuString - The ICU string to extract variables from.\n * @returns {Record<string, string>} A mapping of the variable to the value.\n */\nexport function extractVars(icuString: string): Record<string, string> {\n // Check if the string contains _gt_\n if (!icuString.includes(VAR_IDENTIFIER)) {\n return {};\n }\n\n // Extract all the _gt_# variables\n let index = 1;\n const variables: Record<string, string> = {};\n function visitor(child: GTUnindexedSelectElement): void {\n variables[child.value + index] = child.options.other.value.length\n ? child.options.other.value[0]?.value\n : '';\n index += 1;\n }\n\n traverseIcu({\n icuString,\n shouldVisit: isGTUnindexedSelectElement,\n visitor,\n options: { recurseIntoVisited: false },\n });\n\n return variables;\n}\n","import { printAST, TYPE, type ArgumentElement } from '@generaltranslation/icu';\nimport { traverseIcu } from './utils/traverseIcu';\nimport { VAR_IDENTIFIER } from './utils/constants';\nimport { GTIndexedSelectElement } from './utils/types';\nimport { isGTIndexedSelectElement } from './utils/traverseHelpers';\ninterface GTIndexedArgumentElement extends ArgumentElement {\n value: `${typeof VAR_IDENTIFIER}${number}`;\n}\n\nconst CONTAINS_INDEXED_GT_REGEX = new RegExp(`${VAR_IDENTIFIER}\\\\d+`);\n\n/**\n * Given an indexed ICU string, condenses any select to an argument\n * Unindexed _gt_ source strings and indexed _gt_# translation strings\n * are mutually exclusive.\n * indexVars('Hello {_gt_1, select, other {World}}') => 'Hello {_gt_1}'\n * @param {string} icuString - The ICU string to condense.\n * @returns {string} The condensed ICU string.\n */\nexport function condenseVars(icuString: string): string {\n // Check if the string contains an indexed _gt_ identifier.\n if (!CONTAINS_INDEXED_GT_REGEX.test(icuString)) {\n return icuString;\n }\n\n // Replace with argument\n function visitor(child: GTIndexedSelectElement): void {\n (child as unknown as GTIndexedArgumentElement).type = TYPE.argument;\n Reflect.deleteProperty(child, 'options');\n }\n\n const ast = traverseIcu({\n icuString,\n shouldVisit: isGTIndexedSelectElement,\n visitor,\n options: { recurseIntoVisited: false },\n });\n\n // Serialize\n return printAST(ast);\n}\n"],"mappings":";;;;;;;;;AAAA,MAAa,cAAc;CACzB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AAED,SAAgB,qBAAq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AqC;AACnD,QAA8C,OAAOC,wBAAAA,KAAK;AAC3D,UAAQ,eAAe,OAAO,UAAU;;AAW1C,SAAA,GAAA,wBAAA,UARYC,eAAAA,YAAY;EACtB;EACA,aAAaC,eAAAA;EACb;EACA,SAAS,EAAE,oBAAoB,OAAO;EACvC,CAGkB,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import { i as formatDiagnosticErrorDetails, n as DiagnosticSeverity, r as createDiagnosticMessage, t as DiagnosticMessageInput } from "./diagnostics-CqAHg_Vc.cjs";
2
- import { Ft as TranslateManyEntry, It as TranslateOptions, N as VariableTransformationSuffix, O as Variable, Pt as RuntimeTranslateManyOptions, Y as TranslateManyResult, Z as TranslationResult, _ as JsxChildren, ft as DownloadedFile, g as JsxChild, k as VariableType, mt as FileFormat, v as JsxElement, y as LocaleProperties } from "./types-yByDbKnV.cjs";
2
+ import { Ft as TranslateManyEntry, It as TranslateOptions, N as VariableTransformationSuffix, O as Variable, Pt as RuntimeTranslateManyOptions, Y as TranslateManyResult, Z as TranslationResult, _ as JsxChildren, ft as DownloadedFile, g as JsxChild, k as VariableType, mt as FileFormat, v as JsxElement, y as LocaleProperties } from "./types-BxgnFr8M.cjs";
3
3
  import { n as declareVar, r as decodeVars, t as derive } from "./derive-J2NQLqZm.cjs";
4
4
  import * as _$_generaltranslation_api0 from "@generaltranslation/api";
5
5
  import { API_VERSION, ApiClientConfig, AwaitJobsOptions, CreateBranchData, CreateProjectApiKeyData, CreateProjectData, CreateTagData, DownloadFilesData, EnqueueFileTranslationsData, GenerateProjectContextData, GetBranchInfoData, GetFileInfoData, GetTranslationJobInfoResponse, GetTranslationStatusData, ModelProvider, ProcessFileMovesData, PublishFilesData, SubmitUserEditDiffsData, UploadAssetsData, UploadSourceFilesData, UploadTranslationsData, createApiClient } from "@generaltranslation/api";
@@ -187,13 +187,13 @@ declare function createGtApiAdapter(defaultConfig?: GtApiAdapterConfig): {
187
187
  orgId: string;
188
188
  defaultLocale: string;
189
189
  };
190
- }>; /** Every project the configured credentials can read. */
190
+ }>; /** Projects the signed-in user is a member of, or the API key is bound to. */
191
191
  listProjects(): Promise<{
192
192
  id: string;
193
193
  name: string;
194
194
  orgId: string;
195
195
  orgName: string;
196
- }[]>; /** Organizations where the signed-in user can create projects; user tokens only. */
196
+ }[]>; /** Organizations the credentials can access; listing one does not grant project creation. */
197
197
  listOrgs(): Promise<{
198
198
  id: string;
199
199
  name: string;
@@ -1,5 +1,5 @@
1
1
  import { i as formatDiagnosticErrorDetails, n as DiagnosticSeverity, r as createDiagnosticMessage, t as DiagnosticMessageInput } from "./diagnostics-BKjlDmJK.mjs";
2
- import { Ft as TranslateManyEntry, It as TranslateOptions, N as VariableTransformationSuffix, O as Variable, Pt as RuntimeTranslateManyOptions, Y as TranslateManyResult, Z as TranslationResult, _ as JsxChildren, ft as DownloadedFile, g as JsxChild, k as VariableType, mt as FileFormat, v as JsxElement, y as LocaleProperties } from "./types-CEsh60Yt.mjs";
2
+ import { Ft as TranslateManyEntry, It as TranslateOptions, N as VariableTransformationSuffix, O as Variable, Pt as RuntimeTranslateManyOptions, Y as TranslateManyResult, Z as TranslationResult, _ as JsxChildren, ft as DownloadedFile, g as JsxChild, k as VariableType, mt as FileFormat, v as JsxElement, y as LocaleProperties } from "./types-Ix4SHG5H.mjs";
3
3
  import { n as declareVar, r as decodeVars, t as derive } from "./derive-VfZjYfIU.mjs";
4
4
  import * as _$_generaltranslation_api0 from "@generaltranslation/api";
5
5
  import { API_VERSION, ApiClientConfig, AwaitJobsOptions, CreateBranchData, CreateProjectApiKeyData, CreateProjectData, CreateTagData, DownloadFilesData, EnqueueFileTranslationsData, GenerateProjectContextData, GetBranchInfoData, GetFileInfoData, GetTranslationJobInfoResponse, GetTranslationStatusData, ModelProvider, ProcessFileMovesData, PublishFilesData, SubmitUserEditDiffsData, UploadAssetsData, UploadSourceFilesData, UploadTranslationsData, createApiClient } from "@generaltranslation/api";
@@ -187,13 +187,13 @@ declare function createGtApiAdapter(defaultConfig?: GtApiAdapterConfig): {
187
187
  orgId: string;
188
188
  defaultLocale: string;
189
189
  };
190
- }>; /** Every project the configured credentials can read. */
190
+ }>; /** Projects the signed-in user is a member of, or the API key is bound to. */
191
191
  listProjects(): Promise<{
192
192
  id: string;
193
193
  name: string;
194
194
  orgId: string;
195
195
  orgName: string;
196
- }[]>; /** Organizations where the signed-in user can create projects; user tokens only. */
196
+ }[]>; /** Organizations the credentials can access; listing one does not grant project creation. */
197
197
  listOrgs(): Promise<{
198
198
  id: string;
199
199
  name: string;
package/dist/internal.mjs CHANGED
@@ -1,7 +1,7 @@
1
- import { a as unwrapApiResult, g as libraryDefaultLocale, h as defaultRuntimeApiUrl, i as isErrorResult, m as defaultCacheUrl, o as isModelProvider, p as defaultBaseUrl, s as supportedModelProviders } from "./runtimeTranslate-CI936gg9.mjs";
1
+ import { a as unwrapApiResult, g as libraryDefaultLocale, h as defaultRuntimeApiUrl, i as isErrorResult, m as defaultCacheUrl, o as isModelProvider, p as defaultBaseUrl, s as supportedModelProviders } from "./runtimeTranslate-CRWJMYly.mjs";
2
2
  import { n as formatDiagnosticErrorDetails, t as createDiagnosticMessage } from "./diagnostics-DKA2SkZB.mjs";
3
3
  import { r as isVariable } from "./id-B2wA7-S-.mjs";
4
- import { a as isGTUnindexedSelectElement, c as createGtApiAdapter, d as decodeFileContent, f as encode, i as isGTIndexedSelectElement, l as isSupportedFileFormatTransform, n as declareVar, o as VAR_IDENTIFIER, p as encodeFileContent, r as decodeVars, s as traverseIcu, t as derive, u as decode } from "./derive-Ctj9wXCT.mjs";
4
+ import { a as isGTUnindexedSelectElement, c as createGtApiAdapter, d as decodeFileContent, f as encode, i as isGTIndexedSelectElement, l as isSupportedFileFormatTransform, n as declareVar, o as VAR_IDENTIFIER, p as encodeFileContent, r as decodeVars, s as traverseIcu, t as derive, u as decode } from "./derive-DZR18WqK.mjs";
5
5
  import { API_VERSION } from "@generaltranslation/api";
6
6
  import { TYPE, printAST } from "@generaltranslation/icu";
7
7
  import { getCachedPluralRules } from "@generaltranslation/format/internal";
@@ -55,7 +55,7 @@ const VARIABLE_TRANSFORMATION_SUFFIXES_TO_MINIFIED_NAMES = {
55
55
  number: "n",
56
56
  datetime: "d",
57
57
  currency: "c",
58
- "relative-time": "rt"
58
+ relativetime: "rt"
59
59
  };
60
60
  function minifyVariableType(variableType) {
61
61
  return VARIABLE_TRANSFORMATION_SUFFIXES_TO_MINIFIED_NAMES[variableType];