generaltranslation 8.2.11 → 8.2.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/dist/{IntlCache-k2qfrDqB.cjs → IntlCache-CAW8tKhd.cjs} +12 -12
- package/dist/IntlCache-CAW8tKhd.cjs.map +1 -0
- package/dist/{IntlCache-Ccg_cQPR.mjs → IntlCache-WZk0rKvj.mjs} +12 -12
- package/dist/IntlCache-WZk0rKvj.mjs.map +1 -0
- package/dist/LocaleConfig.d.ts +59 -0
- package/dist/LocaleConfig.js +225 -0
- package/dist/backwards-compatability/dataConversion.d.ts +23 -0
- package/dist/backwards-compatability/dataConversion.js +207 -0
- package/dist/backwards-compatability/oldHashJsxChildren.d.ts +23 -0
- package/dist/backwards-compatability/oldHashJsxChildren.js +79 -0
- package/dist/backwards-compatability/oldTypes.d.ts +21 -0
- package/dist/backwards-compatability/oldTypes.js +1 -0
- package/dist/backwards-compatability/typeChecking.d.ts +21 -0
- package/dist/backwards-compatability/typeChecking.js +61 -0
- package/dist/{base64-CUcEPEC5.cjs → base64-2fu94Klt.cjs} +3 -3
- package/dist/base64-2fu94Klt.cjs.map +1 -0
- package/dist/{base64-C1sogiix.mjs → base64-DH0STixb.mjs} +3 -3
- package/dist/base64-DH0STixb.mjs.map +1 -0
- package/dist/cache/IntlCache.d.ts +26 -0
- package/dist/cache/IntlCache.js +84 -0
- package/dist/cache/types.d.ts +32 -0
- package/dist/cache/types.js +1 -0
- package/dist/{core-3SOQ5ND6.cjs → core-7RP541eY.cjs} +18 -20
- package/dist/core-7RP541eY.cjs.map +1 -0
- package/dist/{core-6rY3oy32.d.cts → core-I9pWGafA.d.mts} +8 -8
- package/dist/{core-BYVWty_t.d.mts → core-TLJoDpJP.d.cts} +8 -8
- package/dist/{core-Bx0m6GOp.mjs → core-isLphYAZ.mjs} +18 -20
- package/dist/core-isLphYAZ.mjs.map +1 -0
- package/dist/core.cjs +1 -1
- package/dist/core.d.cts +1 -1
- package/dist/core.d.mts +1 -1
- package/dist/core.d.ts +128 -0
- package/dist/core.js +137 -0
- package/dist/core.mjs +1 -1
- package/dist/derive/condenseVars.d.ts +7 -0
- package/dist/derive/condenseVars.js +30 -0
- package/dist/derive/declareVar.d.ts +26 -0
- package/dist/derive/declareVar.js +38 -0
- package/dist/derive/decodeVars.d.ts +9 -0
- package/dist/derive/decodeVars.js +52 -0
- package/dist/derive/derive.d.ts +53 -0
- package/dist/derive/derive.js +55 -0
- package/dist/derive/extractVars.d.ts +9 -0
- package/dist/derive/extractVars.js +34 -0
- package/dist/derive/index.d.ts +7 -0
- package/dist/derive/index.js +7 -0
- package/dist/derive/indexVars.d.ts +6 -0
- package/dist/derive/indexVars.js +52 -0
- package/dist/derive/utils/constants.d.ts +2 -0
- package/dist/derive/utils/constants.js +2 -0
- package/dist/derive/utils/regex.d.ts +2 -0
- package/dist/derive/utils/regex.js +4 -0
- package/dist/derive/utils/sanitizeVar.d.ts +12 -0
- package/dist/derive/utils/sanitizeVar.js +38 -0
- package/dist/derive/utils/traverseHelpers.d.ts +4 -0
- package/dist/derive/utils/traverseHelpers.js +22 -0
- package/dist/derive/utils/traverseIcu.d.ts +20 -0
- package/dist/derive/utils/traverseIcu.js +49 -0
- package/dist/derive/utils/types.d.ts +23 -0
- package/dist/derive/utils/types.js +1 -0
- package/dist/errors/ApiError.d.ts +7 -0
- package/dist/errors/ApiError.js +33 -0
- package/dist/errors/formattingErrors.d.ts +1 -0
- package/dist/errors/formattingErrors.js +3 -0
- package/dist/errors.d.ts +1 -0
- package/dist/errors.js +1 -0
- package/dist/formatting/custom-formats/CutoffFormat/CutoffFormat.d.ts +59 -0
- package/dist/formatting/custom-formats/CutoffFormat/CutoffFormat.js +147 -0
- package/dist/formatting/custom-formats/CutoffFormat/constants.d.ts +4 -0
- package/dist/formatting/custom-formats/CutoffFormat/constants.js +30 -0
- package/dist/formatting/custom-formats/CutoffFormat/types.d.ts +48 -0
- package/dist/formatting/custom-formats/CutoffFormat/types.js +2 -0
- package/dist/formatting/format.d.ts +1 -0
- package/dist/formatting/format.js +257 -0
- package/dist/id/hashSource.d.ts +25 -0
- package/dist/id/hashSource.js +98 -0
- package/dist/id/hashTemplate.d.ts +4 -0
- package/dist/id/hashTemplate.js +6 -0
- package/dist/id/types.d.ts +7 -0
- package/dist/id/types.js +1 -0
- package/dist/{id-COlX5v3V.cjs → id-CyiXsQrY.cjs} +9 -9
- package/dist/id-CyiXsQrY.cjs.map +1 -0
- package/dist/{id-BmOyfaug.mjs → id-DbD7K-HL.mjs} +9 -9
- package/dist/id-DbD7K-HL.mjs.map +1 -0
- package/dist/id.cjs +1 -1
- package/dist/id.d.cts +9 -9
- package/dist/id.d.mts +9 -9
- package/dist/id.d.ts +3 -0
- package/dist/id.js +3 -0
- package/dist/id.mjs +1 -1
- package/dist/index.cjs +140 -140
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +88 -88
- package/dist/index.d.mts +88 -88
- package/dist/index.d.ts +1019 -0
- package/dist/index.js +1664 -0
- package/dist/index.mjs +140 -140
- package/dist/index.mjs.map +1 -1
- package/dist/internal.cjs +41 -26
- package/dist/internal.cjs.map +1 -1
- package/dist/internal.d.cts +38 -23
- package/dist/internal.d.mts +38 -23
- package/dist/internal.d.ts +19 -0
- package/dist/internal.js +17 -0
- package/dist/internal.mjs +41 -26
- package/dist/internal.mjs.map +1 -1
- package/dist/locales/customLocaleMapping.d.ts +11 -0
- package/dist/locales/customLocaleMapping.js +23 -0
- package/dist/locales/determineLocale.d.ts +1 -0
- package/dist/locales/determineLocale.js +72 -0
- package/dist/locales/getLocaleDirection.d.ts +1 -0
- package/dist/locales/getLocaleDirection.js +89 -0
- package/dist/locales/getLocaleEmoji.d.ts +2 -0
- package/dist/locales/getLocaleEmoji.js +319 -0
- package/dist/locales/getLocaleName.d.ts +1 -0
- package/dist/locales/getLocaleName.js +45 -0
- package/dist/locales/getLocaleProperties.d.ts +32 -0
- package/dist/locales/getLocaleProperties.js +220 -0
- package/dist/locales/getPluralForm.d.ts +9 -0
- package/dist/locales/getPluralForm.js +63 -0
- package/dist/locales/getRegionProperties.d.ts +7 -0
- package/dist/locales/getRegionProperties.js +61 -0
- package/dist/locales/isSameDialect.d.ts +1 -0
- package/dist/locales/isSameDialect.js +41 -0
- package/dist/locales/isSameLanguage.d.ts +1 -0
- package/dist/locales/isSameLanguage.js +20 -0
- package/dist/locales/isSupersetLocale.d.ts +1 -0
- package/dist/locales/isSupersetLocale.js +22 -0
- package/dist/locales/isValidLocale.d.ts +1 -0
- package/dist/locales/isValidLocale.js +75 -0
- package/dist/locales/requiresTranslation.d.ts +1 -0
- package/dist/locales/requiresTranslation.js +32 -0
- package/dist/locales/resolveAliasLocale.d.ts +8 -0
- package/dist/locales/resolveAliasLocale.js +21 -0
- package/dist/locales/resolveCanonicalLocale.d.ts +8 -0
- package/dist/locales/resolveCanonicalLocale.js +13 -0
- package/dist/logging/errors.d.ts +10 -0
- package/dist/logging/errors.js +29 -0
- package/dist/logging/logger.d.ts +121 -0
- package/dist/logging/logger.js +259 -0
- package/dist/logging/warnings.d.ts +2 -0
- package/dist/logging/warnings.js +2 -0
- package/dist/projects/getProjectData.d.ts +1 -0
- package/dist/projects/getProjectData.js +87 -0
- package/dist/settings/plurals.d.ts +3 -0
- package/dist/settings/plurals.js +14 -0
- package/dist/settings/settings.d.ts +2 -0
- package/dist/settings/settings.js +2 -0
- package/dist/settings/settingsUrls.d.ts +3 -0
- package/dist/settings/settingsUrls.js +3 -0
- package/dist/translate/api.d.ts +1 -0
- package/dist/translate/api.js +1 -0
- package/dist/translate/awaitJobs.d.ts +19 -0
- package/dist/translate/awaitJobs.js +112 -0
- package/dist/translate/checkJobStatus.d.ts +8 -0
- package/dist/translate/checkJobStatus.js +55 -0
- package/dist/translate/createBranch.d.ts +10 -0
- package/dist/translate/createBranch.js +53 -0
- package/dist/translate/createTag.d.ts +19 -0
- package/dist/translate/createTag.js +67 -0
- package/dist/translate/downloadFileBatch.d.ts +1 -0
- package/dist/translate/downloadFileBatch.js +77 -0
- package/dist/translate/enqueueFiles.d.ts +8 -0
- package/dist/translate/enqueueFiles.js +96 -0
- package/dist/translate/getOrphanedFiles.d.ts +8 -0
- package/dist/translate/getOrphanedFiles.js +97 -0
- package/dist/translate/processFileMoves.d.ts +25 -0
- package/dist/translate/processFileMoves.js +90 -0
- package/dist/translate/publishFiles.d.ts +17 -0
- package/dist/translate/publishFiles.js +56 -0
- package/dist/translate/queryBranchData.d.ts +3 -0
- package/dist/translate/queryBranchData.js +53 -0
- package/dist/translate/queryFileData.d.ts +42 -0
- package/dist/translate/queryFileData.js +71 -0
- package/dist/translate/querySourceFile.d.ts +1 -0
- package/dist/translate/querySourceFile.js +67 -0
- package/dist/translate/setupProject.d.ts +11 -0
- package/dist/translate/setupProject.js +63 -0
- package/dist/translate/submitUserEditDiffs.d.ts +12 -0
- package/dist/translate/submitUserEditDiffs.js +68 -0
- package/dist/translate/translateMany.d.ts +1 -0
- package/dist/translate/translateMany.js +103 -0
- package/dist/translate/uploadSourceFiles.d.ts +1 -0
- package/dist/translate/uploadSourceFiles.js +87 -0
- package/dist/translate/uploadTranslations.d.ts +1 -0
- package/dist/translate/uploadTranslations.js +101 -0
- package/dist/translate/utils/apiRequest.d.ts +1 -0
- package/dist/translate/utils/apiRequest.js +130 -0
- package/dist/translate/utils/batch.d.ts +52 -0
- package/dist/translate/utils/batch.js +126 -0
- package/dist/translate/utils/fetchWithTimeout.d.ts +1 -0
- package/dist/translate/utils/fetchWithTimeout.js +93 -0
- package/dist/translate/utils/generateRequestHeaders.d.ts +2 -0
- package/dist/translate/utils/generateRequestHeaders.js +26 -0
- package/dist/translate/utils/handleFetchError.d.ts +1 -0
- package/dist/translate/utils/handleFetchError.js +12 -0
- package/dist/translate/utils/validateFileFormatTransform.d.ts +16 -0
- package/dist/translate/utils/validateFileFormatTransform.js +29 -0
- package/dist/translate/utils/validateResponse.d.ts +1 -0
- package/dist/translate/utils/validateResponse.js +72 -0
- package/dist/{types-Cy8q2XZX.d.mts → types-AHtYZIP-.d.mts} +63 -40
- package/dist/{types-NKhpChvT.d.cts → types-Bf8_Apq_.d.cts} +63 -40
- package/dist/types-dir/api/branch.d.ts +10 -0
- package/dist/types-dir/api/branch.js +1 -0
- package/dist/types-dir/api/checkFileTranslations.d.ts +37 -0
- package/dist/types-dir/api/checkFileTranslations.js +1 -0
- package/dist/types-dir/api/downloadFile.d.ts +3 -0
- package/dist/types-dir/api/downloadFile.js +1 -0
- package/dist/types-dir/api/downloadFileBatch.d.ts +35 -0
- package/dist/types-dir/api/downloadFileBatch.js +1 -0
- package/dist/types-dir/api/enqueueEntries.d.ts +21 -0
- package/dist/types-dir/api/enqueueEntries.js +1 -0
- package/dist/types-dir/api/enqueueFiles.d.ts +70 -0
- package/dist/types-dir/api/enqueueFiles.js +1 -0
- package/dist/types-dir/api/entry.d.ts +39 -0
- package/dist/types-dir/api/entry.js +1 -0
- package/dist/types-dir/api/fetchTranslations.d.ts +12 -0
- package/dist/types-dir/api/fetchTranslations.js +1 -0
- package/dist/types-dir/api/file.d.ts +57 -0
- package/dist/types-dir/api/file.js +1 -0
- package/dist/types-dir/api/json.d.ts +5 -0
- package/dist/types-dir/api/json.js +1 -0
- package/dist/types-dir/api/project.d.ts +7 -0
- package/dist/types-dir/api/project.js +1 -0
- package/dist/types-dir/api/translate.d.ts +34 -0
- package/dist/types-dir/api/translate.js +1 -0
- package/dist/types-dir/api/translateMany.d.ts +5 -0
- package/dist/types-dir/api/translateMany.js +1 -0
- package/dist/types-dir/api/translationStatus.d.ts +9 -0
- package/dist/types-dir/api/translationStatus.js +1 -0
- package/dist/types-dir/api/uploadFiles.d.ts +44 -0
- package/dist/types-dir/api/uploadFiles.js +1 -0
- package/dist/types-dir/jsx/content.d.ts +61 -0
- package/dist/types-dir/jsx/content.js +11 -0
- package/dist/types-dir/jsx/variables.d.ts +9 -0
- package/dist/types-dir/jsx/variables.js +1 -0
- package/dist/types-dir/transformations.d.ts +8 -0
- package/dist/types-dir/transformations.js +1 -0
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +2 -2
- package/dist/types.d.mts +2 -2
- package/dist/types.d.ts +129 -0
- package/dist/types.js +2 -0
- package/dist/types.mjs.map +1 -1
- package/dist/utils/base64.d.ts +2 -0
- package/dist/utils/base64.js +28 -0
- package/dist/utils/isSupportedFileFormatTransform.d.ts +8 -0
- package/dist/utils/isSupportedFileFormatTransform.js +26 -0
- package/dist/utils/isVariable.d.ts +2 -0
- package/dist/utils/isVariable.js +22 -0
- package/dist/utils/minify.d.ts +2 -0
- package/dist/utils/minify.js +10 -0
- package/dist/utils/stableStringify.d.ts +1 -0
- package/dist/utils/stableStringify.js +40 -0
- package/package.json +5 -6
- package/dist/IntlCache-Ccg_cQPR.mjs.map +0 -1
- package/dist/IntlCache-k2qfrDqB.cjs.map +0 -1
- package/dist/base64-C1sogiix.mjs.map +0 -1
- package/dist/base64-CUcEPEC5.cjs.map +0 -1
- package/dist/core-3SOQ5ND6.cjs.map +0 -1
- package/dist/core-Bx0m6GOp.mjs.map +0 -1
- package/dist/id-BmOyfaug.mjs.map +0 -1
- package/dist/id-COlX5v3V.cjs.map +0 -1
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
23
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
+
function step(op) {
|
|
26
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
28
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
29
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
+
switch (op[0]) {
|
|
31
|
+
case 0: case 1: t = op; break;
|
|
32
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
+
default:
|
|
36
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
+
if (t[2]) _.ops.pop();
|
|
41
|
+
_.trys.pop(); continue;
|
|
42
|
+
}
|
|
43
|
+
op = body.call(thisArg, _);
|
|
44
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
import { translationTimeoutError } from '../../logging/errors';
|
|
49
|
+
import { defaultTimeout } from '../../settings/settings';
|
|
50
|
+
/**
|
|
51
|
+
* @internal
|
|
52
|
+
*
|
|
53
|
+
* Wraps the fetch function with a timeout.
|
|
54
|
+
*
|
|
55
|
+
* @param url - The URL to fetch.
|
|
56
|
+
* @param options - The options to pass to the fetch function.
|
|
57
|
+
* @param timeout - The timeout in milliseconds.
|
|
58
|
+
* @returns The response from the fetch function.
|
|
59
|
+
*/
|
|
60
|
+
export default function fetchWithTimeout(url, options, timeout) {
|
|
61
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
62
|
+
var controller, signal, timeoutId, response, error_1;
|
|
63
|
+
return __generator(this, function (_a) {
|
|
64
|
+
switch (_a.label) {
|
|
65
|
+
case 0:
|
|
66
|
+
controller = new AbortController();
|
|
67
|
+
signal = controller.signal;
|
|
68
|
+
timeout = timeout ? timeout : defaultTimeout;
|
|
69
|
+
timeoutId = timeout
|
|
70
|
+
? setTimeout(function () { return controller.abort(); }, timeout)
|
|
71
|
+
: null;
|
|
72
|
+
_a.label = 1;
|
|
73
|
+
case 1:
|
|
74
|
+
_a.trys.push([1, 3, 4, 5]);
|
|
75
|
+
return [4 /*yield*/, fetch(url, __assign(__assign({}, options), { signal: signal }))];
|
|
76
|
+
case 2:
|
|
77
|
+
response = _a.sent();
|
|
78
|
+
return [2 /*return*/, response];
|
|
79
|
+
case 3:
|
|
80
|
+
error_1 = _a.sent();
|
|
81
|
+
if (error_1 instanceof Error && error_1.name === 'AbortError') {
|
|
82
|
+
throw translationTimeoutError(timeout);
|
|
83
|
+
}
|
|
84
|
+
throw error_1;
|
|
85
|
+
case 4:
|
|
86
|
+
if (timeoutId)
|
|
87
|
+
clearTimeout(timeoutId);
|
|
88
|
+
return [7 /*endfinally*/];
|
|
89
|
+
case 5: return [2 /*return*/];
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import { API_VERSION } from '../api';
|
|
13
|
+
export default function generateRequestHeaders(config, excludeContentType) {
|
|
14
|
+
if (excludeContentType === void 0) { excludeContentType = false; }
|
|
15
|
+
var authHeaders = __assign(__assign({}, (!excludeContentType && { 'Content-Type': 'application/json' })), { 'x-gt-project-id': config.projectId });
|
|
16
|
+
if (config.apiKey) {
|
|
17
|
+
if (config.apiKey.startsWith('gtx-internal-')) {
|
|
18
|
+
authHeaders['x-gt-internal-api-key'] = config.apiKey;
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
authHeaders['x-gt-api-key'] = config.apiKey;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
authHeaders['gt-api-version'] = API_VERSION;
|
|
25
|
+
return authHeaders;
|
|
26
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function handleFetchError(error: unknown, timeout: number): never;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { fetchLogger } from '../../logging/logger';
|
|
2
|
+
import { translationRequestFailedError, translationTimeoutError, } from '../../logging/errors';
|
|
3
|
+
export default function handleFetchError(error, timeout) {
|
|
4
|
+
if (error instanceof Error && error.name === 'AbortError') {
|
|
5
|
+
var errorMessage_1 = translationTimeoutError(timeout);
|
|
6
|
+
fetchLogger.error(errorMessage_1);
|
|
7
|
+
throw new Error(errorMessage_1);
|
|
8
|
+
}
|
|
9
|
+
var errorMessage = translationRequestFailedError(error instanceof Error ? error.message : String(error));
|
|
10
|
+
fetchLogger.error(errorMessage);
|
|
11
|
+
throw error;
|
|
12
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { FileFormat } from '../../types-dir/api/file';
|
|
2
|
+
export type FileFormatTransformInput = {
|
|
3
|
+
fileFormat?: FileFormat;
|
|
4
|
+
transformFormat?: FileFormat;
|
|
5
|
+
fileName?: string;
|
|
6
|
+
fileId?: string;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Returns a user-facing validation error when a requested file format transform
|
|
10
|
+
* is missing source format context or is not currently supported.
|
|
11
|
+
*/
|
|
12
|
+
export declare function getFileFormatTransformError(file: FileFormatTransformInput): string | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* Validates file format transforms before sending upload/enqueue requests.
|
|
15
|
+
*/
|
|
16
|
+
export declare function validateFileFormatTransforms(files: FileFormatTransformInput[]): void;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { isSupportedFileFormatTransform } from '../../utils/isSupportedFileFormatTransform';
|
|
2
|
+
/**
|
|
3
|
+
* Returns a user-facing validation error when a requested file format transform
|
|
4
|
+
* is missing source format context or is not currently supported.
|
|
5
|
+
*/
|
|
6
|
+
export function getFileFormatTransformError(file) {
|
|
7
|
+
var _a, _b;
|
|
8
|
+
if (!file.transformFormat)
|
|
9
|
+
return undefined;
|
|
10
|
+
var fileLabel = (_b = (_a = file.fileName) !== null && _a !== void 0 ? _a : file.fileId) !== null && _b !== void 0 ? _b : 'unknown file';
|
|
11
|
+
if (!file.fileFormat) {
|
|
12
|
+
return "fileFormat is required when transformFormat is provided for ".concat(fileLabel);
|
|
13
|
+
}
|
|
14
|
+
if (!isSupportedFileFormatTransform(file.fileFormat, file.transformFormat)) {
|
|
15
|
+
return "Unsupported file format transform: ".concat(file.fileFormat, " -> ").concat(file.transformFormat);
|
|
16
|
+
}
|
|
17
|
+
return undefined;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Validates file format transforms before sending upload/enqueue requests.
|
|
21
|
+
*/
|
|
22
|
+
export function validateFileFormatTransforms(files) {
|
|
23
|
+
for (var _i = 0, files_1 = files; _i < files_1.length; _i++) {
|
|
24
|
+
var file = files_1[_i];
|
|
25
|
+
var error = getFileFormatTransformError(file);
|
|
26
|
+
if (error)
|
|
27
|
+
throw new Error(error);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function validateResponse(response: Response): Promise<void>;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
12
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
import { apiError } from '../../logging/errors';
|
|
38
|
+
import { ApiError } from '../../errors/ApiError';
|
|
39
|
+
export default function validateResponse(response) {
|
|
40
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
41
|
+
var errorMsg, text, errorJson, _a, errorMessage, error;
|
|
42
|
+
return __generator(this, function (_b) {
|
|
43
|
+
switch (_b.label) {
|
|
44
|
+
case 0:
|
|
45
|
+
if (!!response.ok) return [3 /*break*/, 5];
|
|
46
|
+
errorMsg = 'Unknown error';
|
|
47
|
+
_b.label = 1;
|
|
48
|
+
case 1:
|
|
49
|
+
_b.trys.push([1, 3, , 4]);
|
|
50
|
+
return [4 /*yield*/, response.text()];
|
|
51
|
+
case 2:
|
|
52
|
+
text = _b.sent();
|
|
53
|
+
try {
|
|
54
|
+
errorJson = JSON.parse(text);
|
|
55
|
+
errorMsg = errorJson.error;
|
|
56
|
+
}
|
|
57
|
+
catch (_c) {
|
|
58
|
+
errorMsg = text || 'Unknown error';
|
|
59
|
+
}
|
|
60
|
+
return [3 /*break*/, 4];
|
|
61
|
+
case 3:
|
|
62
|
+
_a = _b.sent();
|
|
63
|
+
return [3 /*break*/, 4];
|
|
64
|
+
case 4:
|
|
65
|
+
errorMessage = apiError(response.status, response.statusText, errorMsg);
|
|
66
|
+
error = new ApiError(errorMessage, response.status, errorMsg);
|
|
67
|
+
throw error;
|
|
68
|
+
case 5: return [2 /*return*/];
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
}
|
|
@@ -71,31 +71,31 @@ type JsxChild = string | JsxElement | Variable;
|
|
|
71
71
|
*/
|
|
72
72
|
type StringFormat = 'ICU' | 'I18NEXT' | 'STRING';
|
|
73
73
|
/**
|
|
74
|
-
* The format of the content
|
|
74
|
+
* The format of the content.
|
|
75
75
|
*/
|
|
76
76
|
type DataFormat = 'JSX' | StringFormat;
|
|
77
77
|
/**
|
|
78
|
-
* String format content
|
|
78
|
+
* String format content.
|
|
79
79
|
*/
|
|
80
80
|
type StringContent = IcuMessage | StringMessage | I18nextMessage;
|
|
81
81
|
/**
|
|
82
|
-
* A content type representing JSX, ICU, and I18next messages
|
|
82
|
+
* A content type representing JSX, ICU, and I18next messages.
|
|
83
83
|
*/
|
|
84
84
|
type Content = JsxChildren | StringContent;
|
|
85
85
|
/**
|
|
86
|
-
* A content type representing JSX elements
|
|
86
|
+
* A content type representing JSX elements.
|
|
87
87
|
*/
|
|
88
88
|
type JsxChildren = JsxChild | JsxChild[];
|
|
89
89
|
/**
|
|
90
|
-
* A content type representing ICU messages
|
|
90
|
+
* A content type representing ICU messages.
|
|
91
91
|
*/
|
|
92
92
|
type IcuMessage = string;
|
|
93
93
|
/**
|
|
94
|
-
* A content type representing I18next messages
|
|
94
|
+
* A content type representing I18next messages.
|
|
95
95
|
*/
|
|
96
96
|
type I18nextMessage = string;
|
|
97
97
|
/**
|
|
98
|
-
* A content type representing plain strings
|
|
98
|
+
* A content type representing plain strings.
|
|
99
99
|
*/
|
|
100
100
|
type StringMessage = string;
|
|
101
101
|
//#endregion
|
|
@@ -110,7 +110,7 @@ type ActionType = 'fast';
|
|
|
110
110
|
* EntryMetadata is the metadata for a GTRequest.
|
|
111
111
|
*
|
|
112
112
|
* @param context - The context of the request.
|
|
113
|
-
* @param id - The
|
|
113
|
+
* @param id - The ID of the request.
|
|
114
114
|
* @param maxChars - The maxChars of the request.
|
|
115
115
|
* @param hash - The hash of the request.
|
|
116
116
|
*/
|
|
@@ -152,7 +152,14 @@ type TranslationStatusResult = {
|
|
|
152
152
|
count: number;
|
|
153
153
|
availableLocales: string[];
|
|
154
154
|
locales: string[];
|
|
155
|
-
localesWaitingForApproval:
|
|
155
|
+
localesWaitingForApproval: string[];
|
|
156
|
+
};
|
|
157
|
+
//#endregion
|
|
158
|
+
//#region src/types-dir/api/json.d.ts
|
|
159
|
+
type JsonPrimitive = string | number | boolean | null;
|
|
160
|
+
type JsonValue = JsonPrimitive | JsonValue[] | JsonObject;
|
|
161
|
+
type JsonObject = {
|
|
162
|
+
[key: string]: JsonValue;
|
|
156
163
|
};
|
|
157
164
|
//#endregion
|
|
158
165
|
//#region src/types-dir/api/checkFileTranslations.d.ts
|
|
@@ -195,10 +202,23 @@ type FileQueryResult = {
|
|
|
195
202
|
};
|
|
196
203
|
//#endregion
|
|
197
204
|
//#region src/types-dir/api/enqueueFiles.d.ts
|
|
205
|
+
type UpdateMetadata = {
|
|
206
|
+
id?: string;
|
|
207
|
+
hash?: string;
|
|
208
|
+
context?: string;
|
|
209
|
+
maxChars?: number;
|
|
210
|
+
dataFormat?: DataFormat;
|
|
211
|
+
actionType?: 'standard' | 'fast' | string;
|
|
212
|
+
staticId?: string;
|
|
213
|
+
format?: string;
|
|
214
|
+
filePaths?: string[];
|
|
215
|
+
sourceCode?: unknown;
|
|
216
|
+
contextDeriveExpr?: unknown;
|
|
217
|
+
_contextDeriveExpr?: unknown;
|
|
218
|
+
[key: string]: unknown;
|
|
219
|
+
};
|
|
198
220
|
type Updates = ({
|
|
199
|
-
metadata:
|
|
200
|
-
staticId?: string;
|
|
201
|
-
};
|
|
221
|
+
metadata: UpdateMetadata;
|
|
202
222
|
} & ({
|
|
203
223
|
dataFormat: 'JSX';
|
|
204
224
|
source: JsxChildren;
|
|
@@ -214,13 +234,13 @@ type Updates = ({
|
|
|
214
234
|
}))[];
|
|
215
235
|
/**
|
|
216
236
|
* Options for enqueueing files
|
|
217
|
-
* @param requireApproval - Whether to require approval for the files
|
|
218
|
-
* @param description - Optional description for the project
|
|
219
|
-
* @param sourceLocale - The project's source locale
|
|
220
|
-
* @param targetLocales - The locales to translate the files to
|
|
221
|
-
* @param version - Optional custom version ID to specify
|
|
222
|
-
* @param timeout - Optional timeout for the request
|
|
223
|
-
* @param modelProvider - Optional model provider to use
|
|
237
|
+
* @param requireApproval - Whether to require approval for the files.
|
|
238
|
+
* @param description - Optional description for the project.
|
|
239
|
+
* @param sourceLocale - The project's source locale.
|
|
240
|
+
* @param targetLocales - The locales to translate the files to.
|
|
241
|
+
* @param version - Optional custom version ID to specify.
|
|
242
|
+
* @param timeout - Optional timeout for the request.
|
|
243
|
+
* @param modelProvider - Optional model provider to use.
|
|
224
244
|
*/
|
|
225
245
|
type EnqueueFilesOptions = {
|
|
226
246
|
requireApproval?: boolean;
|
|
@@ -253,17 +273,17 @@ type EnqueueFilesResult = {
|
|
|
253
273
|
//#region src/types-dir/api/file.d.ts
|
|
254
274
|
type FileFormat = 'GTJSON' | 'JSON' | 'PO' | 'POT' | 'YAML' | 'MDX' | 'MD' | 'TS' | 'JS' | 'HTML' | 'TXT' | 'TWILIO_CONTENT_JSON';
|
|
255
275
|
/**
|
|
256
|
-
* Metadata for files or entries
|
|
276
|
+
* Metadata for files or entries.
|
|
257
277
|
*/
|
|
258
|
-
type FormatMetadata =
|
|
278
|
+
type FormatMetadata = JsonObject | Updates[number]['metadata'];
|
|
259
279
|
/**
|
|
260
|
-
* File object structure for uploading files
|
|
280
|
+
* File object structure for uploading files.
|
|
261
281
|
* @see {@link FileReferenceOptionalBranchId}
|
|
262
|
-
* @property {string} content - Content of the file
|
|
282
|
+
* @property {string} content - Content of the file.
|
|
263
283
|
* @property {string} locale - The locale of the file (e.g. 'en', 'de', 'es', etc.)
|
|
264
284
|
* @property {FormatMetadata} [formatMetadata] - Optional metadata for the file, specific to the format of the file
|
|
265
|
-
* @property {string} [incomingBranchId] - The ID of the incoming branch of the file
|
|
266
|
-
* @property {string} [checkedOutBranchId] - The ID of the checked
|
|
285
|
+
* @property {string} [incomingBranchId] - The ID of the incoming branch of the file.
|
|
286
|
+
* @property {string} [checkedOutBranchId] - The ID of the checked-out branch of the file.
|
|
267
287
|
*/
|
|
268
288
|
type FileToUpload = Omit<FileReference, 'branchId'> & {
|
|
269
289
|
content: string;
|
|
@@ -275,14 +295,14 @@ type FileToUpload = Omit<FileReference, 'branchId'> & {
|
|
|
275
295
|
checkedOutBranchId?: string;
|
|
276
296
|
};
|
|
277
297
|
/**
|
|
278
|
-
* File object structure for referencing files
|
|
279
|
-
* @property {string} fileId - The ID of the file
|
|
298
|
+
* File object structure for referencing files.
|
|
299
|
+
* @property {string} fileId - The ID of the file.
|
|
280
300
|
* @property {string} versionId - The ID of the version of the file
|
|
281
301
|
* @property {string} branchId - The ID of the branch of the file
|
|
282
302
|
* @property {string} locale - The locale of the file (e.g. 'en', 'de', 'es', etc.)
|
|
283
|
-
* @property {string} fileName - The name of the file
|
|
284
|
-
* @property {FileFormat} fileFormat - The format of the file (JSON, MDX, MD, etc.)
|
|
285
|
-
* @property {DataFormat} [dataFormat] - Optional format of the data within the file
|
|
303
|
+
* @property {string} fileName - The name of the file.
|
|
304
|
+
* @property {FileFormat} fileFormat - The format of the file (JSON, MDX, MD, etc.).
|
|
305
|
+
* @property {DataFormat} [dataFormat] - Optional format of the data within the file.
|
|
286
306
|
*/
|
|
287
307
|
type FileReference = {
|
|
288
308
|
fileId: string;
|
|
@@ -294,7 +314,7 @@ type FileReference = {
|
|
|
294
314
|
dataFormat?: DataFormat;
|
|
295
315
|
};
|
|
296
316
|
/**
|
|
297
|
-
* File reference object structure for referencing files
|
|
317
|
+
* File reference object structure for referencing files.
|
|
298
318
|
* @see {@link FileReference}
|
|
299
319
|
* @property {string} [branchId] - The ID of the branch of the file
|
|
300
320
|
*/
|
|
@@ -325,7 +345,7 @@ type DownloadedFile = {
|
|
|
325
345
|
locale?: string;
|
|
326
346
|
fileName?: string;
|
|
327
347
|
data: string;
|
|
328
|
-
metadata:
|
|
348
|
+
metadata: JsonObject;
|
|
329
349
|
fileFormat: FileFormat;
|
|
330
350
|
};
|
|
331
351
|
type DownloadFileBatchResult = {
|
|
@@ -339,7 +359,7 @@ type FetchTranslationsOptions = {
|
|
|
339
359
|
};
|
|
340
360
|
type RetrievedTranslation = {
|
|
341
361
|
locale: string;
|
|
342
|
-
translation:
|
|
362
|
+
translation: Content;
|
|
343
363
|
};
|
|
344
364
|
type RetrievedTranslations = RetrievedTranslation[];
|
|
345
365
|
type FetchTranslationsResult = {
|
|
@@ -395,7 +415,7 @@ type FileUpload = {
|
|
|
395
415
|
transformFormat?: FileFormat;
|
|
396
416
|
dataFormat?: DataFormat;
|
|
397
417
|
locale: string;
|
|
398
|
-
formatMetadata?: GTJsonFormatMetadata;
|
|
418
|
+
formatMetadata?: GTJsonFormatMetadata | FormatMetadata;
|
|
399
419
|
versionId?: string;
|
|
400
420
|
fileId?: string;
|
|
401
421
|
};
|
|
@@ -654,10 +674,13 @@ type Metadata = {
|
|
|
654
674
|
maxChars?: number;
|
|
655
675
|
context?: string;
|
|
656
676
|
id?: string;
|
|
677
|
+
hash?: string;
|
|
678
|
+
format?: string;
|
|
679
|
+
dataFormat?: DataFormat;
|
|
657
680
|
sourceLocale?: string;
|
|
658
681
|
actionType?: 'standard' | 'fast' | string;
|
|
659
682
|
filePaths?: string[];
|
|
660
|
-
[key: string]:
|
|
683
|
+
[key: string]: unknown;
|
|
661
684
|
};
|
|
662
685
|
type FormatVariables = Record<string, string | number | boolean | null | undefined | Date>;
|
|
663
686
|
/**
|
|
@@ -730,9 +753,9 @@ type JsxTranslationResult = {
|
|
|
730
753
|
/**
|
|
731
754
|
* TranslationRequestConfig is used to configure the translation request.
|
|
732
755
|
*
|
|
733
|
-
* @param projectId - The project
|
|
734
|
-
* @param baseUrl - The base
|
|
735
|
-
* @param apiKey - The
|
|
756
|
+
* @param projectId - The project ID of the translation request.
|
|
757
|
+
* @param baseUrl - The base URL of the translation request.
|
|
758
|
+
* @param apiKey - The API key of the translation request.
|
|
736
759
|
*/
|
|
737
760
|
type TranslationRequestConfig = {
|
|
738
761
|
projectId: string;
|
|
@@ -740,5 +763,5 @@ type TranslationRequestConfig = {
|
|
|
740
763
|
apiKey?: string;
|
|
741
764
|
};
|
|
742
765
|
//#endregion
|
|
743
|
-
export { FileReference as $, BranchDataResult as A,
|
|
744
|
-
//# sourceMappingURL=types-
|
|
766
|
+
export { FileReference as $, BranchDataResult as A, StringContent as At, FileUpload as B, ProcessMovesOptions as C, HtmlContentPropKeysRecord as Ct, FileDataQuery as D, JsxChild as Dt, OrphanedFile as E, IcuMessage as Et, DownloadFileOptions as F, LocaleProperties as Ft, FetchTranslationsOptions as G, UploadFilesResponse as H, PublishFileEntry as I, CustomMapping as It, DownloadFileBatchOptions as J, FetchTranslationsResult as K, PublishFilesResult as L, TranslationError as M, StringMessage as Mt, TranslationResult as N, Variable as Nt, FileDataResult as O, JsxChildren as Ot, TranslationResultReference as P, VariableType as Pt, FileFormat as Q, EnqueueEntriesOptions as R, MoveResult as S, HTML_CONTENT_PROPS as St, GetOrphanedFilesResult as T, I18nextMessage as Tt, CreateTagOptions as U, UploadFilesOptions as V, CreateTagResult as W, DownloadFileBatchResult as X, DownloadFileBatchRequest as Y, DownloadedFile as Z, AwaitJobsResult as _, TranslateManyEntry as _t, Metadata as a, CheckFileTranslationsOptions as at, JobStatus as b, DataFormat as bt, Update as c, FileTranslationQuery as ct, Transformation as d, JsonValue as dt, FileReferenceIds as et, TransformationPrefix as f, TranslationStatusResult as ft, AwaitJobsOptions as g, RuntimeTranslateManyOptions as gt, SubmitUserEditDiffsPayload as h, EntryMetadata as ht, JsxTranslationResult as i, Updates as it, TranslateManyResult as j, StringFormat as jt, BranchQuery as k, JsxElement as kt, _Content as l, JsonObject as lt, SubmitUserEditDiff as m, ActionType as mt, FormatVariables as n, EnqueueFilesOptions as nt, Request as o, FileQuery as ot, VariableTransformationSuffix as p, HashMetadata as pt, RetrievedTranslations as q, IcuTranslationResult as r, EnqueueFilesResult as rt, TranslationRequestConfig as s, FileQueryResult as st, ContentTranslationResult as t, FileToUpload as tt, InjectionType as u, JsonPrimitive as ut, JobResult as v, TranslateOptions as vt, ProcessMovesResponse as w, HtmlContentPropValuesRecord as wt, MoveMapping as x, GTProp as xt, CheckJobStatusResult as y, Content as yt, EnqueueEntriesResult as z };
|
|
767
|
+
//# sourceMappingURL=types-AHtYZIP-.d.mts.map
|