generaltranslation 9.4.2 → 9.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (153) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/README.md +2 -1
  3. package/dist/{ApiError-BcjcnTAr.cjs → ApiError-BCjEo_CM.cjs} +1 -1
  4. package/dist/{ApiError-BcjcnTAr.cjs.map → ApiError-BCjEo_CM.cjs.map} +1 -1
  5. package/dist/{ApiError-CUKcz3YS.mjs → ApiError-DxWKM0Xt.mjs} +1 -1
  6. package/dist/{ApiError-CUKcz3YS.mjs.map → ApiError-DxWKM0Xt.mjs.map} +1 -1
  7. package/dist/adapter/createGtApi.d.ts +196 -27
  8. package/dist/adapter/createGtApi.js +561 -117
  9. package/dist/adapter/modelProvider.d.ts +4 -0
  10. package/dist/adapter/modelProvider.js +6 -0
  11. package/dist/derive-Cv5_y8Tf.mjs +656 -0
  12. package/dist/derive-Cv5_y8Tf.mjs.map +1 -0
  13. package/dist/{derive-DBCCXTmL.d.cts → derive-J2NQLqZm.d.cts} +1 -1
  14. package/dist/derive-t_E3ftJN.cjs +733 -0
  15. package/dist/derive-t_E3ftJN.cjs.map +1 -0
  16. package/dist/diagnostics-CqAHg_Vc.d.cts +34 -0
  17. package/dist/diagnostics-DKA2SkZB.mjs +45 -0
  18. package/dist/diagnostics-DKA2SkZB.mjs.map +1 -0
  19. package/dist/{unwrapApiResult-BzGfPw75.mjs → diagnostics-DKtiPUvo.cjs} +12 -31
  20. package/dist/diagnostics-DKtiPUvo.cjs.map +1 -0
  21. package/dist/diagnostics-DYtVjOm5.d.mts +34 -0
  22. package/dist/diagnostics.cjs +4 -0
  23. package/dist/diagnostics.d.cts +2 -0
  24. package/dist/diagnostics.d.mts +2 -0
  25. package/dist/diagnostics.d.ts +1 -0
  26. package/dist/diagnostics.js +1 -0
  27. package/dist/diagnostics.mjs +2 -0
  28. package/dist/errors.cjs +1 -1
  29. package/dist/errors.mjs +1 -1
  30. package/dist/file-B37WkCqM.cjs.map +1 -1
  31. package/dist/file-Dga6cyM8.mjs.map +1 -1
  32. package/dist/{id-X2zyx5Jk.mjs → id-B2wA7-S-.mjs} +19 -3
  33. package/dist/id-B2wA7-S-.mjs.map +1 -0
  34. package/dist/{id-pdr3R1xs.cjs → id-DJ_59q21.cjs} +25 -3
  35. package/dist/id-DJ_59q21.cjs.map +1 -0
  36. package/dist/id.cjs +1 -1
  37. package/dist/id.d.cts +1 -1
  38. package/dist/id.d.mts +1 -1
  39. package/dist/id.mjs +1 -1
  40. package/dist/index.cjs +94 -753
  41. package/dist/index.cjs.map +1 -1
  42. package/dist/index.d.cts +14 -33
  43. package/dist/index.d.mts +13 -32
  44. package/dist/index.d.ts +20 -16
  45. package/dist/index.js +110 -98
  46. package/dist/index.mjs +88 -746
  47. package/dist/index.mjs.map +1 -1
  48. package/dist/internal.cjs +16 -186
  49. package/dist/internal.cjs.map +1 -1
  50. package/dist/internal.d.cts +200 -62
  51. package/dist/internal.d.mts +199 -61
  52. package/dist/internal.d.ts +3 -1
  53. package/dist/internal.js +2 -1
  54. package/dist/internal.mjs +6 -178
  55. package/dist/internal.mjs.map +1 -1
  56. package/dist/logging/errors.d.ts +0 -1
  57. package/dist/logging/errors.js +0 -6
  58. package/dist/logging/logger.js +6 -4
  59. package/dist/openapi.json +2344 -845
  60. package/dist/runtime.cjs +580 -2
  61. package/dist/runtime.cjs.map +1 -0
  62. package/dist/runtime.d.cts +12 -6
  63. package/dist/runtime.d.mts +12 -6
  64. package/dist/runtime.d.ts +10 -4
  65. package/dist/runtime.js +10 -65
  66. package/dist/runtime.mjs +579 -1
  67. package/dist/runtime.mjs.map +1 -0
  68. package/dist/runtimeTranslate-CVw143pQ.mjs +506 -0
  69. package/dist/runtimeTranslate-CVw143pQ.mjs.map +1 -0
  70. package/dist/runtimeTranslate-DJioRjb6.cjs +601 -0
  71. package/dist/runtimeTranslate-DJioRjb6.cjs.map +1 -0
  72. package/dist/translate/awaitJobs.d.ts +2 -2
  73. package/dist/translate/awaitJobs.js +1 -156
  74. package/dist/translate/checkJobStatus.d.ts +2 -1
  75. package/dist/translate/checkJobStatus.js +1 -55
  76. package/dist/translate/createBranch.d.ts +2 -6
  77. package/dist/translate/createBranch.js +1 -53
  78. package/dist/translate/enqueueFiles.js +1 -95
  79. package/dist/translate/getProjectInfo.d.ts +2 -6
  80. package/dist/translate/getProjectInfo.js +1 -54
  81. package/dist/translate/processFileMoves.d.ts +3 -13
  82. package/dist/translate/processFileMoves.js +1 -90
  83. package/dist/translate/publishFiles.d.ts +3 -15
  84. package/dist/translate/publishFiles.js +1 -56
  85. package/dist/translate/queryBranchData.js +1 -53
  86. package/dist/translate/queryFileData.d.ts +3 -41
  87. package/dist/translate/queryFileData.js +1 -71
  88. package/dist/translate/runtimeTranslate.d.ts +6 -0
  89. package/dist/translate/runtimeTranslate.js +297 -0
  90. package/dist/translate/setupProject.d.ts +2 -6
  91. package/dist/translate/setupProject.js +1 -63
  92. package/dist/translate/submitUserEditDiffs.js +1 -68
  93. package/dist/translate/utils/fetchWithTimeout.js +19 -12
  94. package/dist/{types-bCr8pV1Z.d.cts → types-Si4UstLL.d.mts} +41 -165
  95. package/dist/types-dir/__tests__/runtimeTranslate.type-test.js +18 -0
  96. package/dist/types-dir/api/branch.d.ts +3 -9
  97. package/dist/types-dir/api/checkFileTranslations.d.ts +2 -22
  98. package/dist/types-dir/api/downloadFileBatch.d.ts +2 -7
  99. package/dist/types-dir/api/entry.d.ts +3 -8
  100. package/dist/types-dir/api/file.d.ts +2 -1
  101. package/dist/types-dir/api/json.d.ts +1 -4
  102. package/dist/types-dir/api/project.d.ts +2 -7
  103. package/dist/types-dir/api/uploadAssets.d.ts +3 -10
  104. package/dist/types-dir/api/uploadAssets.js +0 -4
  105. package/dist/types-dir/config.d.ts +1 -0
  106. package/dist/{types-Dp1drjxq.d.mts → types-yByDbKnV.d.cts} +41 -165
  107. package/dist/types.d.cts +2 -2
  108. package/dist/types.d.mts +2 -2
  109. package/dist/types.d.ts +26 -7
  110. package/package.json +15 -2
  111. package/dist/derive-2CDqwrvS.cjs +0 -303
  112. package/dist/derive-2CDqwrvS.cjs.map +0 -1
  113. package/dist/derive-CTzR56T_.mjs +0 -233
  114. package/dist/derive-CTzR56T_.mjs.map +0 -1
  115. package/dist/id-X2zyx5Jk.mjs.map +0 -1
  116. package/dist/id-pdr3R1xs.cjs.map +0 -1
  117. package/dist/isVariable-8-Wy5FnX.mjs +0 -20
  118. package/dist/isVariable-8-Wy5FnX.mjs.map +0 -1
  119. package/dist/isVariable-I3nllgeI.cjs +0 -25
  120. package/dist/isVariable-I3nllgeI.cjs.map +0 -1
  121. package/dist/projects/getProjectData.js +0 -87
  122. package/dist/runtime-Bcp4F2ME.mjs +0 -974
  123. package/dist/runtime-Bcp4F2ME.mjs.map +0 -1
  124. package/dist/runtime-C25lwh9m.cjs +0 -1027
  125. package/dist/runtime-C25lwh9m.cjs.map +0 -1
  126. package/dist/translate/api.d.ts +0 -4
  127. package/dist/translate/api.js +0 -4
  128. package/dist/translate/createTag.d.ts +0 -19
  129. package/dist/translate/createTag.js +0 -67
  130. package/dist/translate/downloadFileBatch.d.ts +0 -1
  131. package/dist/translate/downloadFileBatch.js +0 -80
  132. package/dist/translate/getOrphanedFiles.d.ts +0 -8
  133. package/dist/translate/getOrphanedFiles.js +0 -97
  134. package/dist/translate/querySourceFile.d.ts +0 -1
  135. package/dist/translate/querySourceFile.js +0 -67
  136. package/dist/translate/translateMany.d.ts +0 -1
  137. package/dist/translate/translateMany.js +0 -124
  138. package/dist/translate/uploadFonts.d.ts +0 -1
  139. package/dist/translate/uploadFonts.js +0 -74
  140. package/dist/translate/uploadSourceFiles.d.ts +0 -1
  141. package/dist/translate/uploadSourceFiles.js +0 -90
  142. package/dist/translate/uploadTranslations.d.ts +0 -1
  143. package/dist/translate/uploadTranslations.js +0 -106
  144. package/dist/translate/utils/apiRequest.d.ts +0 -1
  145. package/dist/translate/utils/apiRequest.js +0 -167
  146. package/dist/translate/utils/generateRequestHeaders.d.ts +0 -2
  147. package/dist/translate/utils/generateRequestHeaders.js +0 -21
  148. package/dist/translate/utils/handleFetchError.d.ts +0 -1
  149. package/dist/translate/utils/handleFetchError.js +0 -12
  150. package/dist/unwrapApiResult-BzGfPw75.mjs.map +0 -1
  151. package/dist/unwrapApiResult-Dv6Mfw_K.cjs +0 -134
  152. package/dist/unwrapApiResult-Dv6Mfw_K.cjs.map +0 -1
  153. /package/dist/{projects/getProjectData.d.ts → types-dir/__tests__/runtimeTranslate.type-test.d.ts} +0 -0
package/dist/index.js CHANGED
@@ -62,6 +62,17 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
62
62
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
63
63
  }
64
64
  };
65
+ var __rest = (this && this.__rest) || function (s, e) {
66
+ var t = {};
67
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
68
+ t[p] = s[p];
69
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
70
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
71
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
72
+ t[p[i]] = s[p[i]];
73
+ }
74
+ return t;
75
+ };
65
76
  var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
66
77
  if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
67
78
  if (ar || !(i in from)) {
@@ -72,28 +83,12 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
72
83
  return to.concat(ar || Array.prototype.slice.call(from));
73
84
  };
74
85
  import { libraryDefaultLocale } from './settings/settings';
86
+ import { defaultBaseUrl } from './settings/settingsUrls';
75
87
  import { noSourceLocaleProvidedError, noTargetLocaleProvidedError, } from './logging/errors';
76
88
  import { gtInstanceLogger } from './logging/logger';
77
- import { _setupProject, } from './translate/setupProject';
78
- import { _enqueueFiles, } from './translate/enqueueFiles';
79
- import { _createTag, } from './translate/createTag';
80
- import { _downloadFileBatch } from './translate/downloadFileBatch';
81
- import { _submitUserEditDiffs, } from './translate/submitUserEditDiffs';
82
- import { _uploadSourceFiles } from './translate/uploadSourceFiles';
83
- import { _uploadFonts } from './translate/uploadFonts';
84
- import { _uploadTranslations } from './translate/uploadTranslations';
85
- import { _querySourceFile } from './translate/querySourceFile';
86
- import { _getProjectData } from './projects/getProjectData';
87
- import { _checkJobStatus, } from './translate/checkJobStatus';
88
- import { _awaitJobIds, } from './translate/awaitJobs';
89
- import { _queryFileData } from './translate/queryFileData';
90
- import { _getProjectInfo } from './translate/getProjectInfo';
91
- import { _queryBranchData } from './translate/queryBranchData';
92
- import { _createBranch } from './translate/createBranch';
93
- import { _processFileMoves, } from './translate/processFileMoves';
94
- import { _getOrphanedFiles, } from './translate/getOrphanedFiles';
95
- import { _publishFiles, } from './translate/publishFiles';
89
+ import { createGtApiAdapter } from './adapter/createGtApi';
96
90
  import { GTRuntime } from './runtime';
91
+ import { validateAuth } from './translate/runtimeTranslate';
97
92
  export { GTRuntime } from './runtime';
98
93
  export { decodeVars } from './derive/decodeVars';
99
94
  export { declareVar } from './derive/declareVar';
@@ -127,6 +122,27 @@ var GT = /** @class */ (function (_super) {
127
122
  function GT() {
128
123
  return _super !== null && _super.apply(this, arguments) || this;
129
124
  }
125
+ GT.prototype.setConfig = function (params) {
126
+ // GTRuntime writes credentials before it validates locales, so drop the
127
+ // cache even when validation throws.
128
+ try {
129
+ _super.prototype.setConfig.call(this, params);
130
+ }
131
+ finally {
132
+ this._apiAdapter = undefined;
133
+ }
134
+ };
135
+ GT.prototype._getApiAdapter = function () {
136
+ var _a;
137
+ (_a = this._apiAdapter) !== null && _a !== void 0 ? _a : (this._apiAdapter = createGtApiAdapter({
138
+ apiKey: this.apiKey || this.devApiKey,
139
+ userTokenProvider: this.userTokenProvider,
140
+ baseUrl: this.baseUrl || defaultBaseUrl,
141
+ projectId: this.projectId,
142
+ customMapping: this.customMapping,
143
+ }));
144
+ return this._apiAdapter;
145
+ };
130
146
  // -------------- Branch Methods -------------- //
131
147
  /**
132
148
  * Queries branch information from the API.
@@ -139,8 +155,8 @@ var GT = /** @class */ (function (_super) {
139
155
  return __generator(this, function (_a) {
140
156
  switch (_a.label) {
141
157
  case 0:
142
- this._validateAuth('queryBranchData');
143
- return [4 /*yield*/, _queryBranchData(query, this._getTranslationConfig())];
158
+ validateAuth('queryBranchData', this._getTranslationConfig());
159
+ return [4 /*yield*/, this._getApiAdapter().queryBranchData(query)];
144
160
  case 1: return [2 /*return*/, _a.sent()];
145
161
  }
146
162
  });
@@ -157,8 +173,8 @@ var GT = /** @class */ (function (_super) {
157
173
  return __generator(this, function (_a) {
158
174
  switch (_a.label) {
159
175
  case 0:
160
- this._validateAuth('createBranch');
161
- return [4 /*yield*/, _createBranch(query, this._getTranslationConfig())];
176
+ validateAuth('createBranch', this._getTranslationConfig());
177
+ return [4 /*yield*/, this._getApiAdapter().createBranch(query)];
162
178
  case 1: return [2 /*return*/, _a.sent()];
163
179
  }
164
180
  });
@@ -183,8 +199,8 @@ var GT = /** @class */ (function (_super) {
183
199
  return __generator(this, function (_a) {
184
200
  switch (_a.label) {
185
201
  case 0:
186
- this._validateAuth('processFileMoves');
187
- return [4 /*yield*/, _processFileMoves(moves, options, this._getTranslationConfig())];
202
+ validateAuth('processFileMoves', this._getTranslationConfig());
203
+ return [4 /*yield*/, this._getApiAdapter().processFileMoves(moves, options)];
188
204
  case 1: return [2 /*return*/, _a.sent()];
189
205
  }
190
206
  });
@@ -209,8 +225,8 @@ var GT = /** @class */ (function (_super) {
209
225
  return __generator(this, function (_a) {
210
226
  switch (_a.label) {
211
227
  case 0:
212
- this._validateAuth('getOrphanedFiles');
213
- return [4 /*yield*/, _getOrphanedFiles(branchId, fileIds, options, this._getTranslationConfig())];
228
+ validateAuth('getOrphanedFiles', this._getTranslationConfig());
229
+ return [4 /*yield*/, this._getApiAdapter().getOrphanedFiles(branchId, fileIds, options)];
214
230
  case 1: return [2 /*return*/, _a.sent()];
215
231
  }
216
232
  });
@@ -236,11 +252,11 @@ var GT = /** @class */ (function (_super) {
236
252
  return __generator(this, function (_b) {
237
253
  switch (_b.label) {
238
254
  case 0:
239
- this._validateAuth('setupProject');
255
+ validateAuth('setupProject', this._getTranslationConfig());
240
256
  options = __assign(__assign({}, options), { locales: (_a = options === null || options === void 0 ? void 0 : options.locales) === null || _a === void 0 ? void 0 : _a.map(function (locale) {
241
257
  return _this.resolveServiceLocale(locale);
242
258
  }) });
243
- return [4 /*yield*/, _setupProject(files, this._getTranslationConfig(), options)];
259
+ return [4 /*yield*/, this._getApiAdapter().setupProject(files, options)];
244
260
  case 1: return [2 /*return*/, _b.sent()];
245
261
  }
246
262
  });
@@ -267,8 +283,8 @@ var GT = /** @class */ (function (_super) {
267
283
  return __generator(this, function (_a) {
268
284
  switch (_a.label) {
269
285
  case 0:
270
- this._validateAuth('checkJobStatus');
271
- return [4 /*yield*/, _checkJobStatus(jobIds, this._getTranslationConfig(), timeoutMs)];
286
+ validateAuth('checkJobStatus', this._getTranslationConfig());
287
+ return [4 /*yield*/, this._getApiAdapter().checkJobStatus(jobIds, timeoutMs)];
272
288
  case 1: return [2 /*return*/, _a.sent()];
273
289
  }
274
290
  });
@@ -287,9 +303,9 @@ var GT = /** @class */ (function (_super) {
287
303
  return __generator(this, function (_a) {
288
304
  switch (_a.label) {
289
305
  case 0:
290
- this._validateAuth('awaitJobs');
306
+ validateAuth('awaitJobs', this._getTranslationConfig());
291
307
  jobIds = Array.isArray(jobs) ? jobs : Object.keys(jobs.jobData);
292
- return [4 /*yield*/, _awaitJobIds(jobIds, options, this._getTranslationConfig())];
308
+ return [4 /*yield*/, this._getApiAdapter().awaitJobs(jobIds, options)];
293
309
  case 1: return [2 /*return*/, _a.sent()];
294
310
  }
295
311
  });
@@ -317,7 +333,7 @@ var GT = /** @class */ (function (_super) {
317
333
  switch (_c.label) {
318
334
  case 0:
319
335
  // Validation
320
- this._validateAuth('enqueueFiles');
336
+ validateAuth('enqueueFiles', this._getTranslationConfig());
321
337
  mergedOptions = __assign(__assign({}, options), { sourceLocale: (_a = options.sourceLocale) !== null && _a !== void 0 ? _a : this.sourceLocale, targetLocales: (_b = options.targetLocales) !== null && _b !== void 0 ? _b : [this.targetLocale] });
322
338
  // Require source locale
323
339
  if (!mergedOptions.sourceLocale) {
@@ -337,7 +353,7 @@ var GT = /** @class */ (function (_super) {
337
353
  mergedOptions = __assign(__assign({}, mergedOptions), { sourceLocale: this.resolveServiceLocale(mergedOptions.sourceLocale), targetLocales: mergedOptions.targetLocales.map(function (locale) {
338
354
  return _this.resolveServiceLocale(locale);
339
355
  }) });
340
- return [4 /*yield*/, _enqueueFiles(files, mergedOptions, this._getTranslationConfig())];
356
+ return [4 /*yield*/, this._getApiAdapter().enqueueFiles(files, mergedOptions)];
341
357
  case 1:
342
358
  result = _c.sent();
343
359
  return [2 /*return*/, __assign(__assign({}, result), { locales: targetLocaleIdentities })];
@@ -357,8 +373,8 @@ var GT = /** @class */ (function (_super) {
357
373
  return __generator(this, function (_a) {
358
374
  switch (_a.label) {
359
375
  case 0:
360
- this._validateAuth('createTag');
361
- return [4 /*yield*/, _createTag(options, this._getTranslationConfig())];
376
+ validateAuth('createTag', this._getTranslationConfig());
377
+ return [4 /*yield*/, this._getApiAdapter().createTag(options)];
362
378
  case 1: return [2 /*return*/, _a.sent()];
363
379
  }
364
380
  });
@@ -377,8 +393,8 @@ var GT = /** @class */ (function (_super) {
377
393
  return __generator(this, function (_a) {
378
394
  switch (_a.label) {
379
395
  case 0:
380
- this._validateAuth('publishFiles');
381
- return [4 /*yield*/, _publishFiles(files, this._getTranslationConfig())];
396
+ validateAuth('publishFiles', this._getTranslationConfig());
397
+ return [4 /*yield*/, this._getApiAdapter().publishFiles(files)];
382
398
  case 1:
383
399
  result = _a.sent();
384
400
  return [2 /*return*/, {
@@ -403,9 +419,9 @@ var GT = /** @class */ (function (_super) {
403
419
  return __generator(this, function (_a) {
404
420
  switch (_a.label) {
405
421
  case 0:
406
- this._validateAuth('submitUserEditDiffs');
422
+ validateAuth('submitUserEditDiffs', this._getTranslationConfig());
407
423
  normalized = __assign(__assign({}, payload), { diffs: (payload.diffs || []).map(function (d) { return (__assign(__assign({}, d), { locale: _this.resolveServiceLocale(d.locale) })); }) });
408
- return [4 /*yield*/, _submitUserEditDiffs(normalized, this._getTranslationConfig())];
424
+ return [4 /*yield*/, this._getApiAdapter().submitUserEditDiffs(normalized)];
409
425
  case 1:
410
426
  _a.sent();
411
427
  return [2 /*return*/];
@@ -447,8 +463,8 @@ var GT = /** @class */ (function (_super) {
447
463
  return __generator(this, function (_a) {
448
464
  switch (_a.label) {
449
465
  case 0:
450
- this._validateAuth('getProjectInfo');
451
- return [4 /*yield*/, _getProjectInfo(options, this._getTranslationConfig())];
466
+ validateAuth('getProjectInfo', this._getTranslationConfig());
467
+ return [4 /*yield*/, this._getApiAdapter().getProjectInfo(undefined, options.timeout)];
452
468
  case 1:
453
469
  result = _a.sent();
454
470
  return [2 /*return*/, __assign(__assign({}, result), { defaultLocale: this.resolveServiceResponseLocale(result.defaultLocale), currentLocales: result.currentLocales.map(function (locale) {
@@ -468,13 +484,13 @@ var GT = /** @class */ (function (_super) {
468
484
  switch (_d.label) {
469
485
  case 0:
470
486
  // Validation
471
- this._validateAuth('queryFileData');
487
+ validateAuth('queryFileData', this._getTranslationConfig());
472
488
  // Replace target locales with canonical locales
473
489
  data.translatedFiles = (_a = data.translatedFiles) === null || _a === void 0 ? void 0 : _a.map(function (item) { return (__assign(__assign({}, item), { locale: _this.resolveServiceLocale(item.locale) })); });
474
- return [4 /*yield*/, _queryFileData(data, options, this._getTranslationConfig())];
490
+ return [4 /*yield*/, this._getApiAdapter().queryFileData(data, options.timeout)];
475
491
  case 1:
476
492
  result = _d.sent();
477
- // Resolve canonical locales
493
+ // Restore configured identities from service language codes.
478
494
  result.translatedFiles = (_b = result.translatedFiles) === null || _b === void 0 ? void 0 : _b.map(function (item) { return (__assign(__assign({}, item), (item.locale && {
479
495
  locale: _this.resolveServiceResponseLocale(item.locale),
480
496
  }))); });
@@ -511,8 +527,8 @@ var GT = /** @class */ (function (_super) {
511
527
  switch (_a.label) {
512
528
  case 0:
513
529
  // Validation
514
- this._validateAuth('querySourceFile');
515
- return [4 /*yield*/, _querySourceFile(data, options, this._getTranslationConfig())];
530
+ validateAuth('querySourceFile', this._getTranslationConfig());
531
+ return [4 /*yield*/, this._getApiAdapter().querySourceFile({ fileId: data.fileId }, { branchId: data.branchId, versionId: data.versionId }, options.timeout)];
516
532
  case 1:
517
533
  result = _a.sent();
518
534
  // Restore configured identities from service language codes.
@@ -533,6 +549,9 @@ var GT = /** @class */ (function (_super) {
533
549
  /**
534
550
  * Get project data for a given project ID.
535
551
  *
552
+ * @deprecated Use `getProjectInfo()` on a `GT` instance configured with the
553
+ * target `projectId`; it reads the same resource and also returns
554
+ * `autoApprove`. This method will be removed in the next major version.
536
555
  * @param {string} projectId - The ID of the project to get the data for.
537
556
  * @returns {Promise<ProjectData>} The project data.
538
557
  *
@@ -544,23 +563,21 @@ var GT = /** @class */ (function (_super) {
544
563
  */
545
564
  GT.prototype.getProjectData = function (projectId_1) {
546
565
  return __awaiter(this, arguments, void 0, function (projectId, options) {
547
- var result;
566
+ var _a, _autoApprove, project;
548
567
  var _this = this;
549
568
  if (options === void 0) { options = {}; }
550
- return __generator(this, function (_a) {
551
- switch (_a.label) {
569
+ return __generator(this, function (_b) {
570
+ switch (_b.label) {
552
571
  case 0:
553
572
  // Validation
554
- this._validateAuth('getProjectData');
555
- return [4 /*yield*/, _getProjectData(projectId, options, this._getTranslationConfig())];
573
+ validateAuth('getProjectData', this._getTranslationConfig());
574
+ return [4 /*yield*/, this._getApiAdapter().getProjectInfo(projectId, options.timeout)];
556
575
  case 1:
557
- result = _a.sent();
576
+ _a = _b.sent(), _autoApprove = _a.autoApprove, project = __rest(_a, ["autoApprove"]);
558
577
  // Restore configured identities from service language codes.
559
- result.currentLocales = result.currentLocales.map(function (item) {
560
- return _this.resolveServiceResponseLocale(item);
561
- });
562
- result.defaultLocale = this.resolveServiceResponseLocale(result.defaultLocale);
563
- return [2 /*return*/, result];
578
+ return [2 /*return*/, __assign(__assign({}, project), { defaultLocale: this.resolveServiceResponseLocale(project.defaultLocale), currentLocales: project.currentLocales.map(function (item) {
579
+ return _this.resolveServiceResponseLocale(item);
580
+ }) })];
564
581
  }
565
582
  });
566
583
  });
@@ -589,27 +606,21 @@ var GT = /** @class */ (function (_super) {
589
606
  GT.prototype.downloadFile = function (file_1) {
590
607
  return __awaiter(this, arguments, void 0, function (file, options) {
591
608
  var result;
592
- var _a, _b, _c;
609
+ var _a, _b;
593
610
  if (options === void 0) { options = {}; }
594
- return __generator(this, function (_d) {
595
- switch (_d.label) {
611
+ return __generator(this, function (_c) {
612
+ switch (_c.label) {
596
613
  case 0:
597
614
  // Validation
598
- this._validateAuth('downloadTranslatedFile');
599
- return [4 /*yield*/, _downloadFileBatch([
600
- {
601
- fileId: file.fileId,
602
- branchId: file.branchId,
603
- locale: file.locale
615
+ validateAuth('downloadTranslatedFile', this._getTranslationConfig());
616
+ return [4 /*yield*/, this._getApiAdapter().downloadFileBatch([
617
+ __assign(__assign({}, file), { locale: file.locale
604
618
  ? this.resolveServiceLocale(file.locale)
605
- : undefined,
606
- versionId: file.versionId,
607
- useLatestAvailableVersion: file.useLatestAvailableVersion,
608
- },
609
- ], options, this._getTranslationConfig())];
619
+ : undefined }),
620
+ ], options)];
610
621
  case 1:
611
- result = _d.sent();
612
- return [2 /*return*/, (_c = (_b = (_a = result.data) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.data) !== null && _c !== void 0 ? _c : ''];
622
+ result = _c.sent();
623
+ return [2 /*return*/, (_b = (_a = result.files[0]) === null || _a === void 0 ? void 0 : _a.data) !== null && _b !== void 0 ? _b : ''];
613
624
  }
614
625
  });
615
626
  });
@@ -639,7 +650,7 @@ var GT = /** @class */ (function (_super) {
639
650
  switch (_a.label) {
640
651
  case 0:
641
652
  // Validation
642
- this._validateAuth('downloadFileBatch');
653
+ validateAuth('downloadFileBatch', this._getTranslationConfig());
643
654
  requestedFiles = new Map();
644
655
  requests = requests.map(function (request) {
645
656
  var _a;
@@ -654,15 +665,17 @@ var GT = /** @class */ (function (_super) {
654
665
  }
655
666
  return __assign(__assign({}, request), { locale: locale });
656
667
  });
657
- return [4 /*yield*/, _downloadFileBatch(requests, options, this._getTranslationConfig())];
668
+ return [4 /*yield*/, this._getApiAdapter().downloadFileBatch(requests, options)];
658
669
  case 1:
659
670
  result = _a.sent();
660
671
  return [2 /*return*/, {
661
- files: result.data.map(function (file) {
672
+ files: result.files.map(function (file) {
662
673
  var _a;
663
674
  if (!file.locale)
664
675
  return file;
665
- var serviceLocale = _this.standardizeLocale(file.locale);
676
+ // The adapter may already have restored an alias; canonicalize before
677
+ // matching against the service codes the requests were keyed by.
678
+ var serviceLocale = _this.resolveServiceLocale(file.locale);
666
679
  var matchingRequests = ((_a = requestedFiles.get(JSON.stringify([file.fileId, serviceLocale]))) !== null && _a !== void 0 ? _a : []).filter(function (request) {
667
680
  return (!request.branchId || request.branchId === file.branchId) &&
668
681
  (!request.versionId || request.versionId === file.versionId);
@@ -691,24 +704,25 @@ var GT = /** @class */ (function (_super) {
691
704
  */
692
705
  GT.prototype.uploadSourceFiles = function (files, options) {
693
706
  return __awaiter(this, void 0, void 0, function () {
694
- var mergedOptions, result;
707
+ var mergedOptions, result, uploadedFiles;
695
708
  var _this = this;
696
709
  var _a, _b;
697
710
  return __generator(this, function (_c) {
698
711
  switch (_c.label) {
699
712
  case 0:
700
713
  // Validation
701
- this._validateAuth('uploadSourceFiles');
714
+ validateAuth('uploadSourceFiles', this._getTranslationConfig());
702
715
  mergedOptions = __assign(__assign({}, options), { sourceLocale: this.resolveServiceLocale((_b = (_a = options.sourceLocale) !== null && _a !== void 0 ? _a : this.sourceLocale) !== null && _b !== void 0 ? _b : libraryDefaultLocale) });
703
716
  // resolve canonical locales
704
717
  files = files.map(function (f) { return (__assign(__assign({}, f), { source: __assign(__assign({}, f.source), { locale: _this.resolveServiceLocale(f.source.locale) }) })); });
705
- return [4 /*yield*/, _uploadSourceFiles(files, mergedOptions, this._getTranslationConfig())];
718
+ return [4 /*yield*/, this._getApiAdapter().uploadSourceFiles(files, mergedOptions)];
706
719
  case 1:
707
720
  result = _c.sent();
721
+ uploadedFiles = result.uploadedFiles;
708
722
  return [2 /*return*/, {
709
- uploadedFiles: result.data,
710
- count: result.count,
711
- message: "Successfully uploaded ".concat(result.count, " files in ").concat(result.batchCount, " batch(es)"),
723
+ uploadedFiles: uploadedFiles,
724
+ count: uploadedFiles.length,
725
+ message: "Successfully uploaded ".concat(uploadedFiles.length, " files in ").concat(Math.ceil(files.length / 100), " batch(es)"),
712
726
  }];
713
727
  }
714
728
  });
@@ -720,20 +734,17 @@ var GT = /** @class */ (function (_super) {
720
734
  * re-running only stores new fonts.
721
735
  * @param {AssetUpload[]} fonts - Fonts to upload (`content` base64-encoded).
722
736
  * @param {UploadAssetsOptions} options - Optional settings (e.g. timeout).
723
- * @returns {Promise<UploadAssetsResponse>} The stored/deduped assets.
737
+ * @returns {Promise<UploadAssetsResponse>} The stored assets.
724
738
  */
725
739
  GT.prototype.uploadFonts = function (fonts_1) {
726
740
  return __awaiter(this, arguments, void 0, function (fonts, options) {
727
- var result;
728
741
  if (options === void 0) { options = {}; }
729
742
  return __generator(this, function (_a) {
730
743
  switch (_a.label) {
731
744
  case 0:
732
- this._validateAuth('uploadFonts');
733
- return [4 /*yield*/, _uploadFonts(fonts, options, this._getTranslationConfig())];
734
- case 1:
735
- result = _a.sent();
736
- return [2 /*return*/, { assets: result.data, count: result.count }];
745
+ validateAuth('uploadFonts', this._getTranslationConfig());
746
+ return [4 /*yield*/, this._getApiAdapter().uploadFonts(fonts, options)];
747
+ case 1: return [2 /*return*/, _a.sent()];
737
748
  }
738
749
  });
739
750
  });
@@ -754,14 +765,14 @@ var GT = /** @class */ (function (_super) {
754
765
  */
755
766
  GT.prototype.uploadTranslations = function (files, options) {
756
767
  return __awaiter(this, void 0, void 0, function () {
757
- var mergedOptions, error, targetFiles, result;
768
+ var mergedOptions, error, targetFiles, result, uploadedFiles;
758
769
  var _this = this;
759
770
  var _a;
760
771
  return __generator(this, function (_b) {
761
772
  switch (_b.label) {
762
773
  case 0:
763
774
  // Validation
764
- this._validateAuth('uploadTranslations');
775
+ validateAuth('uploadTranslations', this._getTranslationConfig());
765
776
  mergedOptions = __assign(__assign({}, options), { sourceLocale: (_a = options.sourceLocale) !== null && _a !== void 0 ? _a : this.sourceLocale });
766
777
  // Require source locale
767
778
  if (!mergedOptions.sourceLocale) {
@@ -771,13 +782,14 @@ var GT = /** @class */ (function (_super) {
771
782
  }
772
783
  mergedOptions.sourceLocale = this.resolveServiceLocale(mergedOptions.sourceLocale);
773
784
  targetFiles = files.map(function (f) { return (__assign(__assign({}, f), { source: __assign(__assign({}, f.source), { locale: _this.resolveServiceLocale(f.source.locale) }), translations: f.translations.map(function (t) { return (__assign(__assign({}, t), { locale: _this.resolveServiceLocale(t.locale) })); }) })); });
774
- return [4 /*yield*/, _uploadTranslations(targetFiles, mergedOptions, this._getTranslationConfig())];
785
+ return [4 /*yield*/, this._getApiAdapter().uploadTranslations(targetFiles, mergedOptions)];
775
786
  case 1:
776
787
  result = _b.sent();
788
+ uploadedFiles = result.uploadedFiles;
777
789
  return [2 /*return*/, {
778
- uploadedFiles: result.data,
779
- count: result.count,
780
- message: "Successfully uploaded ".concat(result.count, " files in ").concat(result.batchCount, " batch(es)"),
790
+ uploadedFiles: uploadedFiles,
791
+ count: uploadedFiles.length,
792
+ message: "Successfully uploaded ".concat(uploadedFiles.length, " files in ").concat(Math.ceil(files.length / 100), " batch(es)"),
781
793
  }];
782
794
  }
783
795
  });