generaltranslation 8.2.12 → 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.
Files changed (240) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/LocaleConfig.d.ts +59 -0
  3. package/dist/LocaleConfig.js +225 -0
  4. package/dist/backwards-compatability/dataConversion.d.ts +23 -0
  5. package/dist/backwards-compatability/dataConversion.js +207 -0
  6. package/dist/backwards-compatability/oldHashJsxChildren.d.ts +23 -0
  7. package/dist/backwards-compatability/oldHashJsxChildren.js +79 -0
  8. package/dist/backwards-compatability/oldTypes.d.ts +21 -0
  9. package/dist/backwards-compatability/oldTypes.js +1 -0
  10. package/dist/backwards-compatability/typeChecking.d.ts +21 -0
  11. package/dist/backwards-compatability/typeChecking.js +61 -0
  12. package/dist/cache/IntlCache.d.ts +26 -0
  13. package/dist/cache/IntlCache.js +84 -0
  14. package/dist/cache/types.d.ts +32 -0
  15. package/dist/cache/types.js +1 -0
  16. package/dist/{core-CST4J4WU.cjs → core-7RP541eY.cjs} +2 -2
  17. package/dist/core-7RP541eY.cjs.map +1 -0
  18. package/dist/{core-D-E8qhLn.d.cts → core-I9pWGafA.d.mts} +2 -2
  19. package/dist/{core-CGhlXrrK.d.mts → core-TLJoDpJP.d.cts} +2 -2
  20. package/dist/{core-7RJsqw6c.mjs → core-isLphYAZ.mjs} +2 -2
  21. package/dist/core-isLphYAZ.mjs.map +1 -0
  22. package/dist/core.cjs +1 -1
  23. package/dist/core.d.cts +1 -1
  24. package/dist/core.d.mts +1 -1
  25. package/dist/core.d.ts +128 -0
  26. package/dist/core.js +137 -0
  27. package/dist/core.mjs +1 -1
  28. package/dist/derive/condenseVars.d.ts +7 -0
  29. package/dist/derive/condenseVars.js +30 -0
  30. package/dist/derive/declareVar.d.ts +26 -0
  31. package/dist/derive/declareVar.js +38 -0
  32. package/dist/derive/decodeVars.d.ts +9 -0
  33. package/dist/derive/decodeVars.js +52 -0
  34. package/dist/derive/derive.d.ts +53 -0
  35. package/dist/derive/derive.js +55 -0
  36. package/dist/derive/extractVars.d.ts +9 -0
  37. package/dist/derive/extractVars.js +34 -0
  38. package/dist/derive/index.d.ts +7 -0
  39. package/dist/derive/index.js +7 -0
  40. package/dist/derive/indexVars.d.ts +6 -0
  41. package/dist/derive/indexVars.js +52 -0
  42. package/dist/derive/utils/constants.d.ts +2 -0
  43. package/dist/derive/utils/constants.js +2 -0
  44. package/dist/derive/utils/regex.d.ts +2 -0
  45. package/dist/derive/utils/regex.js +4 -0
  46. package/dist/derive/utils/sanitizeVar.d.ts +12 -0
  47. package/dist/derive/utils/sanitizeVar.js +38 -0
  48. package/dist/derive/utils/traverseHelpers.d.ts +4 -0
  49. package/dist/derive/utils/traverseHelpers.js +22 -0
  50. package/dist/derive/utils/traverseIcu.d.ts +20 -0
  51. package/dist/derive/utils/traverseIcu.js +49 -0
  52. package/dist/derive/utils/types.d.ts +23 -0
  53. package/dist/derive/utils/types.js +1 -0
  54. package/dist/errors/ApiError.d.ts +7 -0
  55. package/dist/errors/ApiError.js +33 -0
  56. package/dist/errors/formattingErrors.d.ts +1 -0
  57. package/dist/errors/formattingErrors.js +3 -0
  58. package/dist/errors.d.ts +1 -0
  59. package/dist/errors.js +1 -0
  60. package/dist/formatting/custom-formats/CutoffFormat/CutoffFormat.d.ts +59 -0
  61. package/dist/formatting/custom-formats/CutoffFormat/CutoffFormat.js +147 -0
  62. package/dist/formatting/custom-formats/CutoffFormat/constants.d.ts +4 -0
  63. package/dist/formatting/custom-formats/CutoffFormat/constants.js +30 -0
  64. package/dist/formatting/custom-formats/CutoffFormat/types.d.ts +48 -0
  65. package/dist/formatting/custom-formats/CutoffFormat/types.js +2 -0
  66. package/dist/formatting/format.d.ts +1 -0
  67. package/dist/formatting/format.js +257 -0
  68. package/dist/id/hashSource.d.ts +25 -0
  69. package/dist/id/hashSource.js +98 -0
  70. package/dist/id/hashTemplate.d.ts +4 -0
  71. package/dist/id/hashTemplate.js +6 -0
  72. package/dist/id/types.d.ts +7 -0
  73. package/dist/id/types.js +1 -0
  74. package/dist/id.d.cts +1 -1
  75. package/dist/id.d.mts +1 -1
  76. package/dist/id.d.ts +3 -0
  77. package/dist/id.js +3 -0
  78. package/dist/index.cjs +1 -1
  79. package/dist/index.d.cts +2 -2
  80. package/dist/index.d.mts +2 -2
  81. package/dist/index.d.ts +1019 -0
  82. package/dist/index.js +1664 -0
  83. package/dist/index.mjs +1 -1
  84. package/dist/internal.cjs +1 -1
  85. package/dist/internal.cjs.map +1 -1
  86. package/dist/internal.d.cts +2 -2
  87. package/dist/internal.d.mts +2 -2
  88. package/dist/internal.d.ts +19 -0
  89. package/dist/internal.js +17 -0
  90. package/dist/internal.mjs +1 -1
  91. package/dist/internal.mjs.map +1 -1
  92. package/dist/locales/customLocaleMapping.d.ts +11 -0
  93. package/dist/locales/customLocaleMapping.js +23 -0
  94. package/dist/locales/determineLocale.d.ts +1 -0
  95. package/dist/locales/determineLocale.js +72 -0
  96. package/dist/locales/getLocaleDirection.d.ts +1 -0
  97. package/dist/locales/getLocaleDirection.js +89 -0
  98. package/dist/locales/getLocaleEmoji.d.ts +2 -0
  99. package/dist/locales/getLocaleEmoji.js +319 -0
  100. package/dist/locales/getLocaleName.d.ts +1 -0
  101. package/dist/locales/getLocaleName.js +45 -0
  102. package/dist/locales/getLocaleProperties.d.ts +32 -0
  103. package/dist/locales/getLocaleProperties.js +220 -0
  104. package/dist/locales/getPluralForm.d.ts +9 -0
  105. package/dist/locales/getPluralForm.js +63 -0
  106. package/dist/locales/getRegionProperties.d.ts +7 -0
  107. package/dist/locales/getRegionProperties.js +61 -0
  108. package/dist/locales/isSameDialect.d.ts +1 -0
  109. package/dist/locales/isSameDialect.js +41 -0
  110. package/dist/locales/isSameLanguage.d.ts +1 -0
  111. package/dist/locales/isSameLanguage.js +20 -0
  112. package/dist/locales/isSupersetLocale.d.ts +1 -0
  113. package/dist/locales/isSupersetLocale.js +22 -0
  114. package/dist/locales/isValidLocale.d.ts +1 -0
  115. package/dist/locales/isValidLocale.js +75 -0
  116. package/dist/locales/requiresTranslation.d.ts +1 -0
  117. package/dist/locales/requiresTranslation.js +32 -0
  118. package/dist/locales/resolveAliasLocale.d.ts +8 -0
  119. package/dist/locales/resolveAliasLocale.js +21 -0
  120. package/dist/locales/resolveCanonicalLocale.d.ts +8 -0
  121. package/dist/locales/resolveCanonicalLocale.js +13 -0
  122. package/dist/logging/errors.d.ts +10 -0
  123. package/dist/logging/errors.js +29 -0
  124. package/dist/logging/logger.d.ts +121 -0
  125. package/dist/logging/logger.js +259 -0
  126. package/dist/logging/warnings.d.ts +2 -0
  127. package/dist/logging/warnings.js +2 -0
  128. package/dist/projects/getProjectData.d.ts +1 -0
  129. package/dist/projects/getProjectData.js +87 -0
  130. package/dist/settings/plurals.d.ts +3 -0
  131. package/dist/settings/plurals.js +14 -0
  132. package/dist/settings/settings.d.ts +2 -0
  133. package/dist/settings/settings.js +2 -0
  134. package/dist/settings/settingsUrls.d.ts +3 -0
  135. package/dist/settings/settingsUrls.js +3 -0
  136. package/dist/translate/api.d.ts +1 -0
  137. package/dist/translate/api.js +1 -0
  138. package/dist/translate/awaitJobs.d.ts +19 -0
  139. package/dist/translate/awaitJobs.js +112 -0
  140. package/dist/translate/checkJobStatus.d.ts +8 -0
  141. package/dist/translate/checkJobStatus.js +55 -0
  142. package/dist/translate/createBranch.d.ts +10 -0
  143. package/dist/translate/createBranch.js +53 -0
  144. package/dist/translate/createTag.d.ts +19 -0
  145. package/dist/translate/createTag.js +67 -0
  146. package/dist/translate/downloadFileBatch.d.ts +1 -0
  147. package/dist/translate/downloadFileBatch.js +77 -0
  148. package/dist/translate/enqueueFiles.d.ts +8 -0
  149. package/dist/translate/enqueueFiles.js +96 -0
  150. package/dist/translate/getOrphanedFiles.d.ts +8 -0
  151. package/dist/translate/getOrphanedFiles.js +97 -0
  152. package/dist/translate/processFileMoves.d.ts +25 -0
  153. package/dist/translate/processFileMoves.js +90 -0
  154. package/dist/translate/publishFiles.d.ts +17 -0
  155. package/dist/translate/publishFiles.js +56 -0
  156. package/dist/translate/queryBranchData.d.ts +3 -0
  157. package/dist/translate/queryBranchData.js +53 -0
  158. package/dist/translate/queryFileData.d.ts +42 -0
  159. package/dist/translate/queryFileData.js +71 -0
  160. package/dist/translate/querySourceFile.d.ts +1 -0
  161. package/dist/translate/querySourceFile.js +67 -0
  162. package/dist/translate/setupProject.d.ts +11 -0
  163. package/dist/translate/setupProject.js +63 -0
  164. package/dist/translate/submitUserEditDiffs.d.ts +12 -0
  165. package/dist/translate/submitUserEditDiffs.js +68 -0
  166. package/dist/translate/translateMany.d.ts +1 -0
  167. package/dist/translate/translateMany.js +103 -0
  168. package/dist/translate/uploadSourceFiles.d.ts +1 -0
  169. package/dist/translate/uploadSourceFiles.js +87 -0
  170. package/dist/translate/uploadTranslations.d.ts +1 -0
  171. package/dist/translate/uploadTranslations.js +101 -0
  172. package/dist/translate/utils/apiRequest.d.ts +1 -0
  173. package/dist/translate/utils/apiRequest.js +130 -0
  174. package/dist/translate/utils/batch.d.ts +52 -0
  175. package/dist/translate/utils/batch.js +126 -0
  176. package/dist/translate/utils/fetchWithTimeout.d.ts +1 -0
  177. package/dist/translate/utils/fetchWithTimeout.js +93 -0
  178. package/dist/translate/utils/generateRequestHeaders.d.ts +2 -0
  179. package/dist/translate/utils/generateRequestHeaders.js +26 -0
  180. package/dist/translate/utils/handleFetchError.d.ts +1 -0
  181. package/dist/translate/utils/handleFetchError.js +12 -0
  182. package/dist/translate/utils/validateFileFormatTransform.d.ts +16 -0
  183. package/dist/translate/utils/validateFileFormatTransform.js +29 -0
  184. package/dist/translate/utils/validateResponse.d.ts +1 -0
  185. package/dist/translate/utils/validateResponse.js +72 -0
  186. package/dist/{types-BsGsgJWF.d.mts → types-AHtYZIP-.d.mts} +34 -11
  187. package/dist/{types-V5rqd1WR.d.cts → types-Bf8_Apq_.d.cts} +34 -11
  188. package/dist/types-dir/api/branch.d.ts +10 -0
  189. package/dist/types-dir/api/branch.js +1 -0
  190. package/dist/types-dir/api/checkFileTranslations.d.ts +37 -0
  191. package/dist/types-dir/api/checkFileTranslations.js +1 -0
  192. package/dist/types-dir/api/downloadFile.d.ts +3 -0
  193. package/dist/types-dir/api/downloadFile.js +1 -0
  194. package/dist/types-dir/api/downloadFileBatch.d.ts +35 -0
  195. package/dist/types-dir/api/downloadFileBatch.js +1 -0
  196. package/dist/types-dir/api/enqueueEntries.d.ts +21 -0
  197. package/dist/types-dir/api/enqueueEntries.js +1 -0
  198. package/dist/types-dir/api/enqueueFiles.d.ts +70 -0
  199. package/dist/types-dir/api/enqueueFiles.js +1 -0
  200. package/dist/types-dir/api/entry.d.ts +39 -0
  201. package/dist/types-dir/api/entry.js +1 -0
  202. package/dist/types-dir/api/fetchTranslations.d.ts +12 -0
  203. package/dist/types-dir/api/fetchTranslations.js +1 -0
  204. package/dist/types-dir/api/file.d.ts +57 -0
  205. package/dist/types-dir/api/file.js +1 -0
  206. package/dist/types-dir/api/json.d.ts +5 -0
  207. package/dist/types-dir/api/json.js +1 -0
  208. package/dist/types-dir/api/project.d.ts +7 -0
  209. package/dist/types-dir/api/project.js +1 -0
  210. package/dist/types-dir/api/translate.d.ts +34 -0
  211. package/dist/types-dir/api/translate.js +1 -0
  212. package/dist/types-dir/api/translateMany.d.ts +5 -0
  213. package/dist/types-dir/api/translateMany.js +1 -0
  214. package/dist/types-dir/api/translationStatus.d.ts +9 -0
  215. package/dist/types-dir/api/translationStatus.js +1 -0
  216. package/dist/types-dir/api/uploadFiles.d.ts +44 -0
  217. package/dist/types-dir/api/uploadFiles.js +1 -0
  218. package/dist/types-dir/jsx/content.d.ts +61 -0
  219. package/dist/types-dir/jsx/content.js +11 -0
  220. package/dist/types-dir/jsx/variables.d.ts +9 -0
  221. package/dist/types-dir/jsx/variables.js +1 -0
  222. package/dist/types-dir/transformations.d.ts +8 -0
  223. package/dist/types-dir/transformations.js +1 -0
  224. package/dist/types.d.cts +2 -2
  225. package/dist/types.d.mts +2 -2
  226. package/dist/types.d.ts +129 -0
  227. package/dist/types.js +2 -0
  228. package/dist/utils/base64.d.ts +2 -0
  229. package/dist/utils/base64.js +28 -0
  230. package/dist/utils/isSupportedFileFormatTransform.d.ts +8 -0
  231. package/dist/utils/isSupportedFileFormatTransform.js +26 -0
  232. package/dist/utils/isVariable.d.ts +2 -0
  233. package/dist/utils/isVariable.js +22 -0
  234. package/dist/utils/minify.d.ts +2 -0
  235. package/dist/utils/minify.js +10 -0
  236. package/dist/utils/stableStringify.d.ts +1 -0
  237. package/dist/utils/stableStringify.js +40 -0
  238. package/package.json +3 -3
  239. package/dist/core-7RJsqw6c.mjs.map +0 -1
  240. package/dist/core-CST4J4WU.cjs.map +0 -1
@@ -0,0 +1,112 @@
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 { _checkJobStatus } from './checkJobStatus';
49
+ /**
50
+ * @internal
51
+ * Polls job statuses until all jobs are finished or the timeout is reached.
52
+ * @param enqueueResult - The result from enqueueFiles.
53
+ * @param options - Polling configuration.
54
+ * @param config - API credentials and configuration.
55
+ * @returns The final status of all jobs.
56
+ */
57
+ export default function _awaitJobs(enqueueResult, options, config) {
58
+ return __awaiter(this, void 0, void 0, function () {
59
+ var pollingInterval, DEFAULT_TIMEOUT_MS, timeout, jobIds, startTime, finalStatuses, pendingJobIds, statuses, _i, statuses_1, job;
60
+ var _a;
61
+ return __generator(this, function (_b) {
62
+ switch (_b.label) {
63
+ case 0:
64
+ pollingInterval = ((_a = options === null || options === void 0 ? void 0 : options.pollingIntervalSeconds) !== null && _a !== void 0 ? _a : 5) * 1000;
65
+ DEFAULT_TIMEOUT_MS = 10 * 60 * 1000;
66
+ timeout = (options === null || options === void 0 ? void 0 : options.timeoutSeconds) !== undefined
67
+ ? options.timeoutSeconds * 1000
68
+ : DEFAULT_TIMEOUT_MS;
69
+ jobIds = Object.keys(enqueueResult.jobData);
70
+ if (jobIds.length === 0) {
71
+ return [2 /*return*/, { complete: true, jobs: [] }];
72
+ }
73
+ startTime = Date.now();
74
+ finalStatuses = new Map(jobIds.map(function (id) { return [id, { jobId: id, status: 'unknown' }]; }));
75
+ pendingJobIds = new Set(jobIds);
76
+ _b.label = 1;
77
+ case 1:
78
+ if (!(pendingJobIds.size > 0)) return [3 /*break*/, 4];
79
+ return [4 /*yield*/, _checkJobStatus(Array.from(pendingJobIds), config)];
80
+ case 2:
81
+ statuses = _b.sent();
82
+ for (_i = 0, statuses_1 = statuses; _i < statuses_1.length; _i++) {
83
+ job = statuses_1[_i];
84
+ if (job.status === 'completed' ||
85
+ job.status === 'failed' ||
86
+ job.status === 'unknown') {
87
+ finalStatuses.set(job.jobId, __assign({ jobId: job.jobId, status: job.status }, (job.error ? { error: job.error } : {})));
88
+ pendingJobIds.delete(job.jobId);
89
+ }
90
+ else {
91
+ finalStatuses.set(job.jobId, {
92
+ jobId: job.jobId,
93
+ status: job.status,
94
+ });
95
+ }
96
+ }
97
+ if (pendingJobIds.size === 0)
98
+ return [3 /*break*/, 4];
99
+ if (Date.now() - startTime >= timeout)
100
+ return [3 /*break*/, 4];
101
+ return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, pollingInterval); })];
102
+ case 3:
103
+ _b.sent();
104
+ return [3 /*break*/, 1];
105
+ case 4: return [2 /*return*/, {
106
+ complete: pendingJobIds.size === 0,
107
+ jobs: Array.from(finalStatuses.values()),
108
+ }];
109
+ }
110
+ });
111
+ });
112
+ }
@@ -0,0 +1,8 @@
1
+ export type JobStatus = 'queued' | 'processing' | 'completed' | 'failed' | 'unknown';
2
+ export type CheckJobStatusResult = {
3
+ jobId: string;
4
+ status: JobStatus;
5
+ error?: {
6
+ message: string;
7
+ };
8
+ }[];
@@ -0,0 +1,55 @@
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 job statuses for a project.
41
+ * @param jobIds - Job IDs.
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 function _checkJobStatus(jobIds, config, timeoutMs) {
47
+ return __awaiter(this, void 0, void 0, function () {
48
+ return __generator(this, function (_a) {
49
+ return [2 /*return*/, apiRequest(config, '/v2/project/jobs/info', {
50
+ body: { jobIds: jobIds },
51
+ timeout: timeoutMs,
52
+ })];
53
+ });
54
+ });
55
+ }
@@ -0,0 +1,10 @@
1
+ export type CreateBranchQuery = {
2
+ branchName: string;
3
+ defaultBranch: boolean;
4
+ };
5
+ export type CreateBranchResult = {
6
+ branch: {
7
+ id: string;
8
+ name: string;
9
+ };
10
+ };
@@ -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
+ * Creates a new branch in the API.
41
+ * @param query - Object mapping the branch name and default branch flag
42
+ * @param config - The configuration for the API call.
43
+ * @returns The created branch information.
44
+ */
45
+ export default function _createBranch(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/create', {
49
+ body: query,
50
+ })];
51
+ });
52
+ });
53
+ }
@@ -0,0 +1,19 @@
1
+ export type CreateTagFileReference = {
2
+ fileId: string;
3
+ versionId: string;
4
+ branchId: string;
5
+ };
6
+ export type CreateTagOptions = {
7
+ tagId: string;
8
+ files: CreateTagFileReference[];
9
+ message?: string;
10
+ };
11
+ export type CreateTagResult = {
12
+ tag: {
13
+ id: string;
14
+ tagId: string;
15
+ message: string | null;
16
+ createdAt: string;
17
+ updatedAt: string;
18
+ };
19
+ };
@@ -0,0 +1,67 @@
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 apiRequest from './utils/apiRequest';
49
+ /**
50
+ * @internal
51
+ * Creates or upserts a file tag in the General Translation API.
52
+ * @param options - The tag creation options.
53
+ * @param config - The configuration for the API call.
54
+ * @returns The created or updated tag.
55
+ */
56
+ export default function _createTag(options, config) {
57
+ return __awaiter(this, void 0, void 0, function () {
58
+ return __generator(this, function (_a) {
59
+ switch (_a.label) {
60
+ case 0: return [4 /*yield*/, apiRequest(config, '/v2/project/tags/create', {
61
+ body: __assign({ tagId: options.tagId, files: options.files }, (options.message && { message: options.message })),
62
+ })];
63
+ case 1: return [2 /*return*/, _a.sent()];
64
+ }
65
+ });
66
+ });
67
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,77 @@
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 apiRequest from './utils/apiRequest';
49
+ import { decode } from '../utils/base64';
50
+ import { processBatches } from './utils/batch';
51
+ /**
52
+ * @internal
53
+ * Downloads multiple translation files in batches.
54
+ * @param files - Array of files to download
55
+ * @param options - The options for the API call.
56
+ * @param config - The configuration for the request.
57
+ * @returns Promise resolving to a BatchList with all downloaded files
58
+ */
59
+ export default function _downloadFileBatch(requests, options, config) {
60
+ return __awaiter(this, void 0, void 0, function () {
61
+ var _this = this;
62
+ return __generator(this, function (_a) {
63
+ return [2 /*return*/, processBatches(requests, function (batch) { return __awaiter(_this, void 0, void 0, function () {
64
+ var result, files;
65
+ return __generator(this, function (_a) {
66
+ switch (_a.label) {
67
+ case 0: return [4 /*yield*/, apiRequest(config, '/v2/project/files/download', { body: batch, timeout: options.timeout })];
68
+ case 1:
69
+ result = _a.sent();
70
+ files = result.files.map(function (file) { return (__assign(__assign({}, file), { data: decode(file.data) })); });
71
+ return [2 /*return*/, files];
72
+ }
73
+ });
74
+ }); }, { batchSize: 100 })];
75
+ });
76
+ });
77
+ }
@@ -0,0 +1,8 @@
1
+ export type EnqueueOptions = {
2
+ sourceLocale?: string;
3
+ targetLocales: string[];
4
+ requireApproval?: boolean;
5
+ modelProvider?: string;
6
+ force?: boolean;
7
+ timeout?: number;
8
+ };
@@ -0,0 +1,96 @@
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
+ import { validateFileFormatTransforms } from './utils/validateFileFormatTransform';
40
+ /**
41
+ * @internal
42
+ * Enqueues files for translation in the General Translation API.
43
+ * @param files - References of files to translate (file content already uploaded)
44
+ * @param options - The options for the API call.
45
+ * @param config - The configuration for the API call.
46
+ * @returns The result of the API call.
47
+ */
48
+ export default function _enqueueFiles(files, options, config) {
49
+ return __awaiter(this, void 0, void 0, function () {
50
+ var result, jobs;
51
+ var _this = this;
52
+ return __generator(this, function (_a) {
53
+ switch (_a.label) {
54
+ case 0:
55
+ validateFileFormatTransforms(files);
56
+ return [4 /*yield*/, processBatches(files, function (batch) { return __awaiter(_this, void 0, void 0, function () {
57
+ var body, apiResult;
58
+ return __generator(this, function (_a) {
59
+ switch (_a.label) {
60
+ case 0:
61
+ body = {
62
+ files: batch.map(function (f) { return ({
63
+ branchId: f.branchId,
64
+ fileId: f.fileId,
65
+ versionId: f.versionId,
66
+ fileName: f.fileName,
67
+ transformFormat: f.transformFormat,
68
+ }); }),
69
+ targetLocales: options.targetLocales,
70
+ sourceLocale: options.sourceLocale,
71
+ requireApproval: options.requireApproval,
72
+ modelProvider: options.modelProvider,
73
+ force: options.force,
74
+ };
75
+ return [4 /*yield*/, apiRequest(config, '/v2/project/translations/enqueue', { body: body, timeout: options.timeout })];
76
+ case 1:
77
+ apiResult = _a.sent();
78
+ return [2 /*return*/, Array.from(Object.entries(apiResult.jobData))];
79
+ }
80
+ });
81
+ }); }, { batchSize: 100 })];
82
+ case 1:
83
+ result = _a.sent();
84
+ jobs = Object.fromEntries(result.data.map(function (_a) {
85
+ var jobId = _a[0], jobData = _a[1];
86
+ return [jobId, jobData];
87
+ }));
88
+ return [2 /*return*/, {
89
+ jobData: jobs,
90
+ locales: options.targetLocales,
91
+ message: "Successfully enqueued ".concat(result.count, " file translation jobs in ").concat(result.batchCount, " batch(es)"),
92
+ }];
93
+ }
94
+ });
95
+ });
96
+ }
@@ -0,0 +1,8 @@
1
+ export type OrphanedFile = {
2
+ fileId: string;
3
+ versionId: string;
4
+ fileName: string;
5
+ };
6
+ export type GetOrphanedFilesResult = {
7
+ orphanedFiles: OrphanedFile[];
8
+ };
@@ -0,0 +1,97 @@
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 { createBatches } from './utils/batch';
39
+ /**
40
+ * @internal
41
+ * Gets orphaned files for a branch - files that exist on the branch
42
+ * but whose fileIds are not in the provided list.
43
+ * Used for move detection.
44
+ * @param branchId - The branch to check for orphaned files
45
+ * @param fileIds - List of current file IDs (files that are NOT orphaned)
46
+ * @param options - The options for the API call
47
+ * @param config - The configuration for the API call
48
+ * @returns The orphaned files
49
+ */
50
+ export default function _getOrphanedFiles(branchId_1, fileIds_1) {
51
+ return __awaiter(this, arguments, void 0, function (branchId, fileIds, options, config) {
52
+ var makeRequest, batches, batchResults, orphanedFileMap, _i, _a, orphan, _loop_1, i;
53
+ if (options === void 0) { options = {}; }
54
+ return __generator(this, function (_b) {
55
+ switch (_b.label) {
56
+ case 0:
57
+ makeRequest = function (batchFileIds) {
58
+ return apiRequest(config, '/v2/project/files/orphaned', {
59
+ body: { branchId: branchId, fileIds: batchFileIds },
60
+ timeout: options.timeout,
61
+ });
62
+ };
63
+ // If no fileIds, make a single request
64
+ if (fileIds.length === 0) {
65
+ return [2 /*return*/, makeRequest([])];
66
+ }
67
+ batches = createBatches(fileIds, 100);
68
+ return [4 /*yield*/, Promise.all(batches.map(function (batch) { return makeRequest(batch); }))];
69
+ case 1:
70
+ batchResults = _b.sent();
71
+ if (batchResults.length === 1) {
72
+ return [2 /*return*/, batchResults[0]];
73
+ }
74
+ orphanedFileMap = new Map();
75
+ for (_i = 0, _a = batchResults[0].orphanedFiles; _i < _a.length; _i++) {
76
+ orphan = _a[_i];
77
+ orphanedFileMap.set(orphan.fileId, orphan);
78
+ }
79
+ _loop_1 = function (i) {
80
+ var batchOrphanIds = new Set(batchResults[i].orphanedFiles.map(function (f) { return f.fileId; }));
81
+ Array.from(orphanedFileMap.keys()).forEach(function (fileId) {
82
+ if (!batchOrphanIds.has(fileId)) {
83
+ orphanedFileMap.delete(fileId);
84
+ }
85
+ });
86
+ };
87
+ // Intersect with each subsequent batch.
88
+ for (i = 1; i < batchResults.length; i++) {
89
+ _loop_1(i);
90
+ }
91
+ return [2 /*return*/, {
92
+ orphanedFiles: Array.from(orphanedFileMap.values()),
93
+ }];
94
+ }
95
+ });
96
+ });
97
+ }
@@ -0,0 +1,25 @@
1
+ export type MoveMapping = {
2
+ oldFileId: string;
3
+ newFileId: string;
4
+ newFileName: string;
5
+ };
6
+ export type MoveResult = {
7
+ oldFileId: string;
8
+ newFileId: string;
9
+ success: boolean;
10
+ newSourceFileId?: string;
11
+ clonedTranslationsCount?: number;
12
+ error?: string;
13
+ };
14
+ export type ProcessMovesResponse = {
15
+ results: MoveResult[];
16
+ summary: {
17
+ total: number;
18
+ succeeded: number;
19
+ failed: number;
20
+ };
21
+ };
22
+ export type ProcessMovesOptions = {
23
+ timeout?: number;
24
+ branchId?: string;
25
+ };