generaltranslation 9.3.0 → 9.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/adapter/createGtApi.d.ts +102 -0
  3. package/dist/adapter/createGtApi.js +368 -0
  4. package/dist/{derive-Yxp38Tjn.cjs → derive-2CDqwrvS.cjs} +20 -1
  5. package/dist/derive-2CDqwrvS.cjs.map +1 -0
  6. package/dist/{derive-BEA36WQM.mjs → derive-CTzR56T_.mjs} +9 -2
  7. package/dist/derive-CTzR56T_.mjs.map +1 -0
  8. package/dist/id/hashSource.d.ts +2 -1
  9. package/dist/id/hashSource.js +3 -2
  10. package/dist/id/types.d.ts +2 -0
  11. package/dist/{id-BMOKDfiZ.mjs → id-X2zyx5Jk.mjs} +5 -3
  12. package/dist/id-X2zyx5Jk.mjs.map +1 -0
  13. package/dist/{id-BpSNpXZu.cjs → id-pdr3R1xs.cjs} +5 -3
  14. package/dist/{id-BpSNpXZu.cjs.map → id-pdr3R1xs.cjs.map} +1 -1
  15. package/dist/id.cjs +1 -1
  16. package/dist/id.d.cts +4 -2
  17. package/dist/id.d.mts +4 -2
  18. package/dist/id.mjs +1 -1
  19. package/dist/index.cjs +2 -2
  20. package/dist/index.d.cts +1 -1
  21. package/dist/index.d.mts +1 -1
  22. package/dist/index.mjs +2 -2
  23. package/dist/internal.cjs +174 -2
  24. package/dist/internal.cjs.map +1 -1
  25. package/dist/internal.d.cts +108 -4
  26. package/dist/internal.d.mts +108 -4
  27. package/dist/internal.d.ts +3 -1
  28. package/dist/internal.js +2 -1
  29. package/dist/internal.mjs +172 -2
  30. package/dist/internal.mjs.map +1 -1
  31. package/dist/openapi.json +4929 -2181
  32. package/dist/{runtime-DeF1Ef5w.cjs → runtime-BGUJYxhI.cjs} +3 -2
  33. package/dist/runtime-BGUJYxhI.cjs.map +1 -0
  34. package/dist/{runtime-CqKaoInO.mjs → runtime-BiKgjDUI.mjs} +3 -2
  35. package/dist/runtime-BiKgjDUI.mjs.map +1 -0
  36. package/dist/runtime.cjs +1 -1
  37. package/dist/runtime.d.cts +1 -1
  38. package/dist/runtime.d.mts +1 -1
  39. package/dist/runtime.mjs +1 -1
  40. package/dist/translate/translateMany.js +1 -1
  41. package/dist/{types-BUNfoXph.d.mts → types-Dp1drjxq.d.mts} +7 -3
  42. package/dist/{types-Do446qa9.d.cts → types-bCr8pV1Z.d.cts} +7 -3
  43. package/dist/types-dir/api/entry.d.ts +3 -0
  44. package/dist/types.d.cts +2 -2
  45. package/dist/types.d.mts +2 -2
  46. package/dist/types.d.ts +1 -0
  47. package/dist/utils/base64.d.ts +3 -0
  48. package/dist/utils/base64.js +7 -0
  49. package/package.json +2 -2
  50. package/dist/derive-BEA36WQM.mjs.map +0 -1
  51. package/dist/derive-Yxp38Tjn.cjs.map +0 -1
  52. package/dist/id-BMOKDfiZ.mjs.map +0 -1
  53. package/dist/runtime-CqKaoInO.mjs.map +0 -1
  54. package/dist/runtime-DeF1Ef5w.cjs.map +0 -1
package/dist/internal.mjs CHANGED
@@ -1,6 +1,8 @@
1
1
  import { a as defaultCacheUrl, c as formatDiagnosticErrorDetails, i as defaultBaseUrl, n as isErrorResult, o as defaultRuntimeApiUrl, r as unwrapApiResult, s as createDiagnosticMessage, u as libraryDefaultLocale } from "./unwrapApiResult-BzGfPw75.mjs";
2
- import { a as isGTUnindexedSelectElement, c as decode, d as API_VERSION, i as isGTIndexedSelectElement, l as encode, n as declareVar, o as VAR_IDENTIFIER, r as decodeVars, s as traverseIcu, t as derive, u as isSupportedFileFormatTransform } from "./derive-BEA36WQM.mjs";
2
+ import { a as isGTUnindexedSelectElement, c as decode, d as encodeFileContent, f as isSupportedFileFormatTransform, i as isGTIndexedSelectElement, l as decodeFileContent, n as declareVar, o as VAR_IDENTIFIER, p as API_VERSION, r as decodeVars, s as traverseIcu, t as derive, u as encode } from "./derive-CTzR56T_.mjs";
3
3
  import { t as isVariable } from "./isVariable-8-Wy5FnX.mjs";
4
+ import { DEFAULT_BATCH_SIZE, createApiClient, createBranch, downloadFiles, enqueueFileTranslations, generateProjectContext, getFileInfo, getTranslationJobInfo, pollJobs, processBatches, uploadSourceFiles, uploadTranslations } from "@generaltranslation/api";
5
+ import { resolveAliasLocale, resolveCanonicalLocale } from "@generaltranslation/format";
4
6
  import { TYPE, printAST } from "@generaltranslation/icu";
5
7
  import { getCachedPluralRules } from "@generaltranslation/format/internal";
6
8
  //#region src/settings/plurals.ts
@@ -59,6 +61,174 @@ function minifyVariableType(variableType) {
59
61
  return VARIABLE_TRANSFORMATION_SUFFIXES_TO_MINIFIED_NAMES[variableType];
60
62
  }
61
63
  //#endregion
64
+ //#region src/adapter/createGtApi.ts
65
+ function createGtApiAdapter(defaultConfig) {
66
+ let client = defaultConfig ? createApiClient(defaultConfig) : void 0;
67
+ let configuredClientConfig = defaultConfig;
68
+ let customMapping;
69
+ function getClient() {
70
+ if (!client) throw new Error("API client not configured — call configureApiClient first");
71
+ return client;
72
+ }
73
+ function getClientConfig() {
74
+ if (!configuredClientConfig) throw new Error("API client not configured — call configureApiClient first");
75
+ return configuredClientConfig;
76
+ }
77
+ function configure(config) {
78
+ const { customMapping: mapping, ...clientConfig } = config;
79
+ client = createApiClient(clientConfig);
80
+ configuredClientConfig = clientConfig;
81
+ customMapping = mapping;
82
+ }
83
+ return {
84
+ configure,
85
+ getClient,
86
+ getClientConfig,
87
+ resolveAliasLocale(locale) {
88
+ return resolveAliasLocale(locale, customMapping);
89
+ },
90
+ resolveCanonicalLocale(locale) {
91
+ return resolveCanonicalLocale(locale, customMapping);
92
+ },
93
+ async createBranch(body) {
94
+ return unwrapApiResult(await createBranch({
95
+ body,
96
+ client: getClient()
97
+ }));
98
+ },
99
+ async queryFileData(body) {
100
+ const result = unwrapApiResult(await getFileInfo({
101
+ body: {
102
+ ...body,
103
+ translatedFiles: body.translatedFiles?.map((file) => ({
104
+ ...file,
105
+ locale: resolveCanonicalLocale(file.locale, customMapping)
106
+ }))
107
+ },
108
+ client: getClient()
109
+ }));
110
+ return {
111
+ ...result,
112
+ translatedFiles: result.translatedFiles.map((file) => ({
113
+ ...file,
114
+ locale: resolveAliasLocale(file.locale, customMapping)
115
+ })),
116
+ sourceFiles: result.sourceFiles.map((file) => ({
117
+ ...file,
118
+ sourceLocale: resolveAliasLocale(file.sourceLocale, customMapping),
119
+ locales: file.locales.map((locale) => resolveAliasLocale(locale, customMapping))
120
+ }))
121
+ };
122
+ },
123
+ async downloadFileBatch(files) {
124
+ const request = async (batch) => unwrapApiResult(await downloadFiles({
125
+ body: batch.map((file) => ({
126
+ ...file,
127
+ locale: file.locale ? resolveCanonicalLocale(file.locale, customMapping) : void 0
128
+ })),
129
+ client: getClient()
130
+ }));
131
+ const responses = await processBatches(files, async (batch) => [await request(batch)]);
132
+ return {
133
+ files: responses.flatMap((response) => response.files.map((file) => ({
134
+ ...file,
135
+ ...file.locale && { locale: resolveAliasLocale(file.locale, customMapping) },
136
+ data: decodeFileContent(file.data, file.fileFormat),
137
+ metadata: file.metadata
138
+ }))),
139
+ count: responses.reduce((count, response) => count + response.count, 0),
140
+ pending: responses.flatMap((response) => response.pending ?? [])
141
+ };
142
+ },
143
+ async setupProject(files, options = {}) {
144
+ return unwrapApiResult(await generateProjectContext({
145
+ body: {
146
+ files: files.map(({ branchId, fileId, versionId }) => ({
147
+ branchId,
148
+ fileId,
149
+ versionId
150
+ })),
151
+ locales: options.locales?.map((locale) => resolveCanonicalLocale(locale, customMapping)),
152
+ force: options.force
153
+ },
154
+ client: getClient()
155
+ }));
156
+ },
157
+ async enqueueFiles(files, options) {
158
+ const targetLocales = options.targetLocales.map((locale) => resolveCanonicalLocale(locale, customMapping));
159
+ const result = await processBatches(files, async (batch) => {
160
+ const response = unwrapApiResult(await enqueueFileTranslations({
161
+ body: {
162
+ files: batch.map(({ branchId, fileId, versionId, fileName, transformFormat }) => ({
163
+ branchId,
164
+ fileId,
165
+ versionId,
166
+ fileName,
167
+ transformFormat
168
+ })),
169
+ targetLocales,
170
+ sourceLocale: options.sourceLocale ? resolveCanonicalLocale(options.sourceLocale, customMapping) : void 0,
171
+ modelProvider: options.modelProvider,
172
+ force: options.force
173
+ },
174
+ client: getClient()
175
+ }));
176
+ const jobData = "jobData" in response ? response.jobData : response.data;
177
+ return Object.entries(jobData);
178
+ });
179
+ return {
180
+ jobData: Object.fromEntries(result),
181
+ locales: targetLocales,
182
+ message: `Successfully enqueued ${result.length} file translation jobs in ${Math.ceil(files.length / DEFAULT_BATCH_SIZE)} batch(es)`
183
+ };
184
+ },
185
+ async uploadSourceFiles(files, options) {
186
+ const sourceLocale = resolveCanonicalLocale(options.sourceLocale, customMapping);
187
+ return { uploadedFiles: await processBatches(files, async (batch) => {
188
+ return unwrapApiResult(await uploadSourceFiles({
189
+ body: {
190
+ data: batch.map(({ source }) => ({ source: {
191
+ ...source,
192
+ content: encodeFileContent(source.content, source.fileFormat),
193
+ locale: resolveCanonicalLocale(source.locale, customMapping)
194
+ } })),
195
+ sourceLocale
196
+ },
197
+ client: getClient()
198
+ })).uploadedFiles;
199
+ }) };
200
+ },
201
+ async awaitJobs(jobIds, options) {
202
+ return pollJobs(jobIds, async (pendingJobIds, signal) => unwrapApiResult(await getTranslationJobInfo({
203
+ body: { jobIds: pendingJobIds },
204
+ client: getClient(),
205
+ signal
206
+ })), options);
207
+ },
208
+ async uploadTranslations(files, options) {
209
+ return { uploadedFiles: await processBatches(files, async (batch) => {
210
+ return unwrapApiResult(await uploadTranslations({
211
+ body: {
212
+ data: batch.map(({ source, translations }) => ({
213
+ source: {
214
+ ...source,
215
+ content: encodeFileContent(source.content, source.fileFormat)
216
+ },
217
+ translations: translations.map((translation) => ({
218
+ ...translation,
219
+ locale: resolveCanonicalLocale(translation.locale, customMapping),
220
+ content: encodeFileContent(translation.content, translation.fileFormat)
221
+ }))
222
+ })),
223
+ sourceLocale: resolveCanonicalLocale(options.sourceLocale, customMapping)
224
+ },
225
+ client: getClient()
226
+ })).uploadedFiles;
227
+ }) };
228
+ }
229
+ };
230
+ }
231
+ //#endregion
62
232
  //#region src/derive/indexVars.ts
63
233
  /**
64
234
  * Given an ICU string adds identifiers to each _gt_ placeholder
@@ -150,6 +320,6 @@ function condenseVars(icuString) {
150
320
  }));
151
321
  }
152
322
  //#endregion
153
- export { API_VERSION, VAR_IDENTIFIER, condenseVars, createDiagnosticMessage, declareVar, decode, decodeVars, defaultBaseUrl, defaultCacheUrl, defaultRuntimeApiUrl, derive, encode, extractVars, formatDiagnosticErrorDetails, _getPluralForm as getPluralForm, indexVars, isAcceptedPluralForm, isErrorResult, isSupportedFileFormatTransform, isVariable, libraryDefaultLocale, minifyVariableType, pluralForms, unwrapApiResult };
323
+ export { API_VERSION, VAR_IDENTIFIER, condenseVars, createDiagnosticMessage, createGtApiAdapter, declareVar, decode, decodeFileContent, decodeVars, defaultBaseUrl, defaultCacheUrl, defaultRuntimeApiUrl, derive, encode, encodeFileContent, extractVars, formatDiagnosticErrorDetails, _getPluralForm as getPluralForm, indexVars, isAcceptedPluralForm, isErrorResult, isSupportedFileFormatTransform, isVariable, libraryDefaultLocale, minifyVariableType, pluralForms, unwrapApiResult };
154
324
 
155
325
  //# sourceMappingURL=internal.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"internal.mjs","names":[],"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;C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mjs","names":[],"sources":["../src/settings/plurals.ts","../src/locales/getPluralForm.ts","../src/utils/minify.ts","../src/adapter/createGtApi.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 {\n createApiClient,\n createBranch,\n DEFAULT_BATCH_SIZE,\n downloadFiles,\n enqueueFileTranslations,\n generateProjectContext,\n getFileInfo,\n getTranslationJobInfo,\n pollJobs,\n processBatches,\n uploadSourceFiles,\n uploadTranslations,\n type ApiClientConfig,\n type AwaitJobsOptions,\n type CreateBranchData,\n type DownloadFilesData,\n type EnqueueFileTranslationsData,\n type GenerateProjectContextData,\n type GetFileInfoData,\n type UploadSourceFilesData,\n type UploadTranslationsData,\n} from '@generaltranslation/api';\nimport {\n resolveAliasLocale,\n resolveCanonicalLocale,\n} from '@generaltranslation/format';\nimport type { CustomMapping } from '@generaltranslation/format/types';\nimport type { DownloadedFile } from '../types-dir/api/downloadFileBatch';\nimport { decodeFileContent, encodeFileContent } from '../utils/base64';\nimport { unwrapApiResult } from '../translate/utils/unwrapApiResult';\n\nexport type GtApiAdapterConfig = ApiClientConfig & {\n customMapping?: CustomMapping;\n};\n\nexport function createGtApiAdapter(defaultConfig?: ApiClientConfig) {\n let client = defaultConfig ? createApiClient(defaultConfig) : undefined;\n let configuredClientConfig = defaultConfig;\n let customMapping: CustomMapping | undefined;\n\n function getClient(): ReturnType<typeof createApiClient> {\n if (!client) {\n throw new Error(\n 'API client not configured — call configureApiClient first'\n );\n }\n return client;\n }\n\n function getClientConfig(): ApiClientConfig {\n if (!configuredClientConfig) {\n throw new Error(\n 'API client not configured — call configureApiClient first'\n );\n }\n return configuredClientConfig;\n }\n\n function configure(config: GtApiAdapterConfig): void {\n const { customMapping: mapping, ...clientConfig } = config;\n client = createApiClient(clientConfig);\n configuredClientConfig = clientConfig;\n customMapping = mapping;\n }\n\n return {\n configure,\n getClient,\n getClientConfig,\n\n resolveAliasLocale(locale: string) {\n return resolveAliasLocale(locale, customMapping);\n },\n\n resolveCanonicalLocale(locale: string) {\n return resolveCanonicalLocale(locale, customMapping);\n },\n\n async createBranch(body: CreateBranchData['body']) {\n return unwrapApiResult(await createBranch({ body, client: getClient() }));\n },\n\n async queryFileData(body: GetFileInfoData['body']) {\n const result = unwrapApiResult(\n await getFileInfo({\n body: {\n ...body,\n translatedFiles: body.translatedFiles?.map((file) => ({\n ...file,\n locale: resolveCanonicalLocale(file.locale, customMapping),\n })),\n },\n client: getClient(),\n })\n );\n return {\n ...result,\n translatedFiles: result.translatedFiles.map((file) => ({\n ...file,\n locale: resolveAliasLocale(file.locale, customMapping),\n })),\n sourceFiles: result.sourceFiles.map((file) => ({\n ...file,\n sourceLocale: resolveAliasLocale(file.sourceLocale, customMapping),\n locales: file.locales.map((locale) =>\n resolveAliasLocale(locale, customMapping)\n ),\n })),\n };\n },\n\n async downloadFileBatch(files: DownloadFilesData['body']) {\n const request = async (batch: DownloadFilesData['body']) =>\n unwrapApiResult(\n await downloadFiles({\n body: batch.map((file) => ({\n ...file,\n locale: file.locale\n ? resolveCanonicalLocale(file.locale, customMapping)\n : undefined,\n })),\n client: getClient(),\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, customMapping),\n }),\n data: decodeFileContent(file.data, file.fileFormat),\n // OpenAPI currently types metadata as an open object; the API emits\n // JSON values here, matching DownloadedFile's public contract.\n metadata: file.metadata as DownloadedFile['metadata'],\n })\n )\n ),\n count: responses.reduce((count, response) => count + response.count, 0),\n pending: responses.flatMap((response) => response.pending ?? []),\n };\n },\n\n async setupProject(\n files: GenerateProjectContextData['body']['files'],\n options: Omit<GenerateProjectContextData['body'], 'files'> = {}\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 resolveCanonicalLocale(locale, customMapping)\n ),\n force: options.force,\n },\n client: getClient(),\n })\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 }\n ) {\n const targetLocales = options.targetLocales.map((locale) =>\n resolveCanonicalLocale(locale, customMapping)\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 ? resolveCanonicalLocale(options.sourceLocale, customMapping)\n : undefined,\n // Consumers intentionally accept custom model-provider strings beyond\n // the OpenAPI enum; preserve the existing wire behavior at this boundary.\n modelProvider:\n options.modelProvider as EnqueueFileTranslationsData['body']['modelProvider'],\n force: options.force,\n },\n client: getClient(),\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 uploadSourceFiles(\n files: Array<{\n source: UploadSourceFilesData['body']['data'][number]['source'];\n }>,\n options: { sourceLocale: string }\n ) {\n const sourceLocale = resolveCanonicalLocale(\n options.sourceLocale,\n customMapping\n );\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: resolveCanonicalLocale(source.locale, customMapping),\n },\n })),\n sourceLocale,\n },\n client: getClient(),\n })\n );\n return response.uploadedFiles;\n });\n\n return { uploadedFiles: result };\n },\n\n async awaitJobs(jobIds: readonly string[], options?: AwaitJobsOptions) {\n return pollJobs(\n jobIds,\n async (pendingJobIds, signal) =>\n unwrapApiResult(\n await getTranslationJobInfo({\n body: { jobIds: pendingJobIds },\n client: getClient(),\n signal,\n })\n ),\n options\n );\n },\n\n async uploadTranslations(\n files: UploadTranslationsData['body']['data'],\n options: { sourceLocale: string }\n ) {\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 },\n translations: translations.map((translation) => ({\n ...translation,\n locale: resolveCanonicalLocale(\n translation.locale,\n customMapping\n ),\n content: encodeFileContent(\n translation.content,\n translation.fileFormat\n ),\n })),\n })),\n sourceLocale: resolveCanonicalLocale(\n options.sourceLocale,\n customMapping\n ),\n },\n client: getClient(),\n })\n );\n return response.uploadedFiles;\n });\n\n return { uploadedFiles: result };\n },\n };\n}\n\nexport type GtApiAdapter = ReturnType<typeof createGtApiAdapter>;\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,wBADc,qBAAqB,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;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