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,90 @@
|
|
|
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 apiRequest from './utils/apiRequest';
|
|
38
|
+
import { processBatches } from './utils/batch';
|
|
39
|
+
/**
|
|
40
|
+
* @internal
|
|
41
|
+
* Processes file moves by cloning source files and translations with new fileIds.
|
|
42
|
+
* Called when the CLI detects that files have been moved/renamed.
|
|
43
|
+
* @param moves - Array of move mappings (old fileId to new fileId)
|
|
44
|
+
* @param options - Options including branchId and timeout
|
|
45
|
+
* @param config - The configuration for the API call.
|
|
46
|
+
* @returns Promise resolving to the move results
|
|
47
|
+
*/
|
|
48
|
+
export default function _processFileMoves(moves, options, config) {
|
|
49
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
50
|
+
var batchResult, succeeded, failed;
|
|
51
|
+
var _this = this;
|
|
52
|
+
return __generator(this, function (_a) {
|
|
53
|
+
switch (_a.label) {
|
|
54
|
+
case 0:
|
|
55
|
+
if (moves.length === 0) {
|
|
56
|
+
return [2 /*return*/, {
|
|
57
|
+
results: [],
|
|
58
|
+
summary: { total: 0, succeeded: 0, failed: 0 },
|
|
59
|
+
}];
|
|
60
|
+
}
|
|
61
|
+
return [4 /*yield*/, processBatches(moves, function (batch) { return __awaiter(_this, void 0, void 0, function () {
|
|
62
|
+
var result;
|
|
63
|
+
return __generator(this, function (_a) {
|
|
64
|
+
switch (_a.label) {
|
|
65
|
+
case 0: return [4 /*yield*/, apiRequest(config, '/v2/project/files/moves', {
|
|
66
|
+
body: { branchId: options.branchId, moves: batch },
|
|
67
|
+
timeout: options.timeout,
|
|
68
|
+
})];
|
|
69
|
+
case 1:
|
|
70
|
+
result = _a.sent();
|
|
71
|
+
return [2 /*return*/, result.results];
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
}); }, { batchSize: 100 })];
|
|
75
|
+
case 1:
|
|
76
|
+
batchResult = _a.sent();
|
|
77
|
+
succeeded = batchResult.data.filter(function (r) { return r.success; }).length;
|
|
78
|
+
failed = batchResult.data.filter(function (r) { return !r.success; }).length;
|
|
79
|
+
return [2 /*return*/, {
|
|
80
|
+
results: batchResult.data,
|
|
81
|
+
summary: {
|
|
82
|
+
total: moves.length,
|
|
83
|
+
succeeded: succeeded,
|
|
84
|
+
failed: failed,
|
|
85
|
+
},
|
|
86
|
+
}];
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type PublishFileEntry = {
|
|
2
|
+
fileId: string;
|
|
3
|
+
versionId: string;
|
|
4
|
+
branchId?: string;
|
|
5
|
+
publish: boolean;
|
|
6
|
+
fileName?: string;
|
|
7
|
+
};
|
|
8
|
+
export type PublishFilesResult = {
|
|
9
|
+
results: {
|
|
10
|
+
fileId: string;
|
|
11
|
+
versionId: string;
|
|
12
|
+
locale?: string;
|
|
13
|
+
branchId: string;
|
|
14
|
+
success: boolean;
|
|
15
|
+
error?: string;
|
|
16
|
+
}[];
|
|
17
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
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 apiRequest from './utils/apiRequest';
|
|
38
|
+
/**
|
|
39
|
+
* @internal
|
|
40
|
+
* Publishes or unpublishes files on the CDN.
|
|
41
|
+
* @param files - Array of file entries with publish flags
|
|
42
|
+
* @param config - The configuration for the API call.
|
|
43
|
+
* @returns The result of the API call.
|
|
44
|
+
*/
|
|
45
|
+
export default function _publishFiles(files, config) {
|
|
46
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
47
|
+
return __generator(this, function (_a) {
|
|
48
|
+
switch (_a.label) {
|
|
49
|
+
case 0: return [4 /*yield*/, apiRequest(config, '/v2/project/files/publish', {
|
|
50
|
+
body: { files: files },
|
|
51
|
+
})];
|
|
52
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
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 apiRequest from './utils/apiRequest';
|
|
38
|
+
/**
|
|
39
|
+
* @internal
|
|
40
|
+
* Queries branch information from the API.
|
|
41
|
+
* @param query - Object mapping the current branch and incoming branches
|
|
42
|
+
* @param config - The configuration for the API call.
|
|
43
|
+
* @returns The branch information.
|
|
44
|
+
*/
|
|
45
|
+
export default function _queryBranchData(query, config) {
|
|
46
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
47
|
+
return __generator(this, function (_a) {
|
|
48
|
+
return [2 /*return*/, apiRequest(config, '/v2/project/branches/info', {
|
|
49
|
+
body: query,
|
|
50
|
+
})];
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export type FileDataQuery = {
|
|
2
|
+
sourceFiles?: {
|
|
3
|
+
fileId: string;
|
|
4
|
+
versionId: string;
|
|
5
|
+
branchId: string;
|
|
6
|
+
}[];
|
|
7
|
+
translatedFiles?: {
|
|
8
|
+
fileId: string;
|
|
9
|
+
versionId: string;
|
|
10
|
+
branchId: string;
|
|
11
|
+
locale: string;
|
|
12
|
+
}[];
|
|
13
|
+
};
|
|
14
|
+
export type FileDataResult = {
|
|
15
|
+
sourceFiles?: {
|
|
16
|
+
branchId: string;
|
|
17
|
+
fileId: string;
|
|
18
|
+
versionId: string;
|
|
19
|
+
fileName: string;
|
|
20
|
+
fileFormat: string;
|
|
21
|
+
dataFormat: string | null;
|
|
22
|
+
createdAt: string;
|
|
23
|
+
updatedAt: string;
|
|
24
|
+
approvalRequiredAt: string | null;
|
|
25
|
+
publishedAt: string | null;
|
|
26
|
+
locales: string[];
|
|
27
|
+
sourceLocale: string;
|
|
28
|
+
}[];
|
|
29
|
+
translatedFiles?: {
|
|
30
|
+
branchId: string;
|
|
31
|
+
fileId: string;
|
|
32
|
+
versionId: string;
|
|
33
|
+
fileFormat: string;
|
|
34
|
+
dataFormat: string | null;
|
|
35
|
+
createdAt: string;
|
|
36
|
+
updatedAt: string;
|
|
37
|
+
approvedAt: string | null;
|
|
38
|
+
publishedAt: string | null;
|
|
39
|
+
completedAt: string | null;
|
|
40
|
+
locale: string;
|
|
41
|
+
}[];
|
|
42
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
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 apiRequest from './utils/apiRequest';
|
|
38
|
+
/**
|
|
39
|
+
* @internal
|
|
40
|
+
* Queries data about one or more source or translation files.
|
|
41
|
+
* @param data - Object mapping source or translation file information
|
|
42
|
+
* @param options - The options for the API call.
|
|
43
|
+
* @param config - The configuration for the API call.
|
|
44
|
+
* @returns The file data.
|
|
45
|
+
*/
|
|
46
|
+
export default function _queryFileData(data_1) {
|
|
47
|
+
return __awaiter(this, arguments, void 0, function (data, options, config) {
|
|
48
|
+
var body;
|
|
49
|
+
var _a, _b;
|
|
50
|
+
if (options === void 0) { options = {}; }
|
|
51
|
+
return __generator(this, function (_c) {
|
|
52
|
+
body = {
|
|
53
|
+
sourceFiles: (_a = data.sourceFiles) === null || _a === void 0 ? void 0 : _a.map(function (item) { return ({
|
|
54
|
+
fileId: item.fileId,
|
|
55
|
+
versionId: item.versionId,
|
|
56
|
+
branchId: item.branchId,
|
|
57
|
+
}); }),
|
|
58
|
+
translatedFiles: (_b = data.translatedFiles) === null || _b === void 0 ? void 0 : _b.map(function (item) { return ({
|
|
59
|
+
fileId: item.fileId,
|
|
60
|
+
versionId: item.versionId,
|
|
61
|
+
branchId: item.branchId,
|
|
62
|
+
locale: item.locale,
|
|
63
|
+
}); }),
|
|
64
|
+
};
|
|
65
|
+
return [2 /*return*/, apiRequest(config, '/v2/project/files/info', {
|
|
66
|
+
body: body,
|
|
67
|
+
timeout: options.timeout,
|
|
68
|
+
})];
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,67 @@
|
|
|
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 apiRequest from './utils/apiRequest';
|
|
38
|
+
/**
|
|
39
|
+
* @internal
|
|
40
|
+
* Gets the source file and translation information for a given file ID and version ID.
|
|
41
|
+
* @param query - The file ID and version ID to get the source file and translation information for
|
|
42
|
+
* @param options - The options for the API call.
|
|
43
|
+
* @param config - The configuration for the request.
|
|
44
|
+
* @returns The source file and translation information for the given file ID and version ID
|
|
45
|
+
*/
|
|
46
|
+
export default function _querySourceFile(query, options, config) {
|
|
47
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
48
|
+
var branchId, versionId, fileId, searchParams, endpoint;
|
|
49
|
+
return __generator(this, function (_a) {
|
|
50
|
+
branchId = query.branchId;
|
|
51
|
+
versionId = query.versionId;
|
|
52
|
+
fileId = query.fileId;
|
|
53
|
+
searchParams = new URLSearchParams();
|
|
54
|
+
if (branchId) {
|
|
55
|
+
searchParams.set('branchId', branchId);
|
|
56
|
+
}
|
|
57
|
+
if (versionId) {
|
|
58
|
+
searchParams.set('versionId', versionId);
|
|
59
|
+
}
|
|
60
|
+
endpoint = "/v2/project/translations/files/status/".concat(encodeURIComponent(fileId), "?").concat(searchParams.toString());
|
|
61
|
+
return [2 /*return*/, apiRequest(config, endpoint, {
|
|
62
|
+
method: 'GET',
|
|
63
|
+
timeout: options.timeout,
|
|
64
|
+
})];
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
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 apiRequest from './utils/apiRequest';
|
|
38
|
+
/**
|
|
39
|
+
* @internal
|
|
40
|
+
* Enqueues files for project setup the General Translation API.
|
|
41
|
+
* @param files - References of files to translate (file content already uploaded)
|
|
42
|
+
* @param config - The configuration for the API call.
|
|
43
|
+
* @param timeoutMS - The timeout in milliseconds
|
|
44
|
+
* @returns The result of the API call.
|
|
45
|
+
*/
|
|
46
|
+
export default function _setupProject(files, config, options) {
|
|
47
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
48
|
+
return __generator(this, function (_a) {
|
|
49
|
+
return [2 /*return*/, apiRequest(config, '/v2/project/setup/generate', {
|
|
50
|
+
body: {
|
|
51
|
+
files: files.map(function (f) { return ({
|
|
52
|
+
branchId: f.branchId,
|
|
53
|
+
fileId: f.fileId,
|
|
54
|
+
versionId: f.versionId,
|
|
55
|
+
}); }),
|
|
56
|
+
locales: options === null || options === void 0 ? void 0 : options.locales,
|
|
57
|
+
force: options === null || options === void 0 ? void 0 : options.force,
|
|
58
|
+
},
|
|
59
|
+
timeout: options === null || options === void 0 ? void 0 : options.timeoutMs,
|
|
60
|
+
})];
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type SubmitUserEditDiff = {
|
|
2
|
+
fileName: string;
|
|
3
|
+
locale: string;
|
|
4
|
+
diff: string;
|
|
5
|
+
branchId: string;
|
|
6
|
+
versionId: string;
|
|
7
|
+
fileId: string;
|
|
8
|
+
localContent: string;
|
|
9
|
+
};
|
|
10
|
+
export type SubmitUserEditDiffsPayload = {
|
|
11
|
+
diffs: SubmitUserEditDiff[];
|
|
12
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
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 apiRequest from './utils/apiRequest';
|
|
38
|
+
import { processBatches } from './utils/batch';
|
|
39
|
+
/**
|
|
40
|
+
* @internal
|
|
41
|
+
* Submits user edit diffs so the service can learn/persist user-intended rules.
|
|
42
|
+
*/
|
|
43
|
+
export default function _submitUserEditDiffs(payload_1, config_1) {
|
|
44
|
+
return __awaiter(this, arguments, void 0, function (payload, config, options) {
|
|
45
|
+
var _this = this;
|
|
46
|
+
if (options === void 0) { options = {}; }
|
|
47
|
+
return __generator(this, function (_a) {
|
|
48
|
+
switch (_a.label) {
|
|
49
|
+
case 0: return [4 /*yield*/, processBatches(payload.diffs, function (batch) { return __awaiter(_this, void 0, void 0, function () {
|
|
50
|
+
return __generator(this, function (_a) {
|
|
51
|
+
switch (_a.label) {
|
|
52
|
+
case 0: return [4 /*yield*/, apiRequest(config, '/v2/project/files/diffs', {
|
|
53
|
+
body: { diffs: batch },
|
|
54
|
+
timeout: options.timeout,
|
|
55
|
+
})];
|
|
56
|
+
case 1:
|
|
57
|
+
_a.sent();
|
|
58
|
+
return [2 /*return*/, [{ success: true }]];
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}); }, { batchSize: 100 })];
|
|
62
|
+
case 1:
|
|
63
|
+
_a.sent();
|
|
64
|
+
return [2 /*return*/, { success: true }];
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|