smartling-api-sdk-nodejs 3.2.3 → 3.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.example +13 -0
- package/api/base/base-api.ts +2 -1
- package/api/glossaries/dto/custom-field-value-dto.ts +6 -0
- package/api/glossaries/dto/entry-request-translation-status-dto.ts +7 -0
- package/api/glossaries/dto/glossary-entries-count-dto.ts +5 -0
- package/api/glossaries/dto/glossary-entry-dto.ts +23 -0
- package/api/glossaries/dto/glossary-import-result-dto.ts +11 -0
- package/api/glossaries/dto/glossary-import-status-dto.ts +7 -0
- package/api/glossaries/dto/glossary-uids-dto.ts +3 -0
- package/api/glossaries/dto/import-entry-changes-dto.ts +6 -0
- package/api/glossaries/dto/import-entry-translation-changes-dto.ts +6 -0
- package/api/glossaries/dto/import-warning-dto.ts +4 -0
- package/api/glossaries/dto/label-dto.ts +4 -0
- package/api/glossaries/dto/locale-workflow-dto.ts +4 -0
- package/api/glossaries/dto/operation-dto.ts +3 -0
- package/api/glossaries/dto/translation-dto.ts +20 -0
- package/api/glossaries/dto/translation-request-status-dto.ts +5 -0
- package/api/glossaries/enums/import-file-media-type.ts +5 -0
- package/api/glossaries/enums/import-status.ts +6 -0
- package/api/glossaries/enums/index.ts +4 -0
- package/api/glossaries/enums/part-of-speech.ts +11 -0
- package/api/glossaries/enums/suggestion-status.ts +5 -0
- package/api/glossaries/index.ts +281 -0
- package/api/glossaries/params/archive-glossaries-parameters.ts +9 -0
- package/api/glossaries/params/authorize-entries-parameters.ts +37 -0
- package/api/glossaries/params/create-glossary-entry-parameters.ts +50 -0
- package/api/glossaries/params/create-glossary-parameters.ts +40 -0
- package/api/glossaries/params/create-label-parameters.ts +9 -0
- package/api/glossaries/params/entries-bulk-action-parameters.ts +149 -0
- package/api/glossaries/params/entries-bulk-labels-parameters.ts +123 -0
- package/api/glossaries/params/export-entries-parameters.ts +16 -48
- package/api/glossaries/params/initialize-import-parameters.ts +42 -0
- package/api/glossaries/params/search-glossary-counts-parameters.ts +41 -0
- package/api/glossaries/params/search-glossary-entries-parameters.ts +105 -0
- package/api/translation-memory/dto/async-action-result-dto.ts +12 -0
- package/api/translation-memory/dto/async-action-status.ts +8 -0
- package/api/translation-memory/dto/create-string-search-result-dto.ts +16 -0
- package/api/translation-memory/dto/duplicate-string-dto.ts +9 -0
- package/api/translation-memory/dto/locale-summary-dto.ts +10 -0
- package/api/translation-memory/dto/strings-export-async-action-result-dto.ts +8 -0
- package/api/translation-memory/dto/tm-dto.ts +23 -0
- package/api/translation-memory/dto/tm-locale-dto.ts +8 -0
- package/api/translation-memory/dto/tmx-import-summary-dto.ts +16 -0
- package/api/translation-memory/dto/tmx-parsing-error-dto.ts +7 -0
- package/api/translation-memory/dto/user-dto.ts +6 -0
- package/api/translation-memory/index.ts +368 -0
- package/api/translation-memory/params/bulk-export-tm-strings-parameters.ts +30 -0
- package/api/translation-memory/params/create-string-search-filter-parameters.ts +232 -0
- package/api/translation-memory/params/create-string-search-options.ts +8 -0
- package/api/translation-memory/params/create-tm-parameters.ts +28 -0
- package/api/translation-memory/params/escape-smp-unicode-parser-directive.ts +6 -0
- package/api/translation-memory/params/extended-export-metadata-type.ts +4 -0
- package/api/translation-memory/params/import-tmx-file-parameters.ts +76 -0
- package/api/translation-memory/params/keyword-search-type.ts +5 -0
- package/api/translation-memory/params/leverage-type.ts +5 -0
- package/api/translation-memory/params/search-keyword.ts +10 -0
- package/api/translation-memory/params/source-type.ts +7 -0
- package/api/translation-memory/params/string-search-tags.ts +7 -0
- package/api/translation-memory/params/translation-quality-type.ts +5 -0
- package/api/translation-memory/params/tu-translation-quality-type.ts +6 -0
- package/api/translation-memory/params/update-tm-parameters.ts +23 -0
- package/built/api/base/base-api.js +2 -1
- package/built/api/base/base-api.js.map +1 -1
- package/built/api/glossaries/dto/custom-field-value-dto.d.ts +6 -0
- package/built/api/glossaries/dto/custom-field-value-dto.js +3 -0
- package/built/api/glossaries/dto/custom-field-value-dto.js.map +1 -0
- package/built/api/glossaries/dto/entry-request-translation-status-dto.d.ts +6 -0
- package/built/api/glossaries/dto/entry-request-translation-status-dto.js +3 -0
- package/built/api/glossaries/dto/entry-request-translation-status-dto.js.map +1 -0
- package/built/api/glossaries/dto/glossary-entries-count-dto.d.ts +5 -0
- package/built/api/glossaries/dto/glossary-entries-count-dto.js +3 -0
- package/built/api/glossaries/dto/glossary-entries-count-dto.js.map +1 -0
- package/built/api/glossaries/dto/glossary-entry-dto.d.ts +22 -0
- package/built/api/glossaries/dto/glossary-entry-dto.js +3 -0
- package/built/api/glossaries/dto/glossary-entry-dto.js.map +1 -0
- package/built/api/glossaries/dto/glossary-import-result-dto.d.ts +10 -0
- package/built/api/glossaries/dto/glossary-import-result-dto.js +3 -0
- package/built/api/glossaries/dto/glossary-import-result-dto.js.map +1 -0
- package/built/api/glossaries/dto/glossary-import-status-dto.d.ts +6 -0
- package/built/api/glossaries/dto/glossary-import-status-dto.js +3 -0
- package/built/api/glossaries/dto/glossary-import-status-dto.js.map +1 -0
- package/built/api/glossaries/dto/glossary-uids-dto.d.ts +3 -0
- package/built/api/glossaries/dto/glossary-uids-dto.js +3 -0
- package/built/api/glossaries/dto/glossary-uids-dto.js.map +1 -0
- package/built/api/glossaries/dto/import-entry-changes-dto.d.ts +6 -0
- package/built/api/glossaries/dto/import-entry-changes-dto.js +3 -0
- package/built/api/glossaries/dto/import-entry-changes-dto.js.map +1 -0
- package/built/api/glossaries/dto/import-entry-translation-changes-dto.d.ts +6 -0
- package/built/api/glossaries/dto/import-entry-translation-changes-dto.js +3 -0
- package/built/api/glossaries/dto/import-entry-translation-changes-dto.js.map +1 -0
- package/built/api/glossaries/dto/import-warning-dto.d.ts +4 -0
- package/built/api/glossaries/dto/import-warning-dto.js +3 -0
- package/built/api/glossaries/dto/import-warning-dto.js.map +1 -0
- package/built/api/glossaries/dto/label-dto.d.ts +4 -0
- package/built/api/glossaries/dto/label-dto.js +3 -0
- package/built/api/glossaries/dto/label-dto.js.map +1 -0
- package/built/api/glossaries/dto/locale-workflow-dto.d.ts +4 -0
- package/built/api/glossaries/dto/locale-workflow-dto.js +3 -0
- package/built/api/glossaries/dto/locale-workflow-dto.js.map +1 -0
- package/built/api/glossaries/dto/operation-dto.d.ts +3 -0
- package/built/api/glossaries/dto/operation-dto.js +3 -0
- package/built/api/glossaries/dto/operation-dto.js.map +1 -0
- package/built/api/glossaries/dto/translation-dto.d.ts +19 -0
- package/built/api/glossaries/dto/translation-dto.js +3 -0
- package/built/api/glossaries/dto/translation-dto.js.map +1 -0
- package/built/api/glossaries/dto/translation-request-status-dto.d.ts +5 -0
- package/built/api/glossaries/dto/translation-request-status-dto.js +3 -0
- package/built/api/glossaries/dto/translation-request-status-dto.js.map +1 -0
- package/built/api/glossaries/enums/import-file-media-type.d.ts +5 -0
- package/built/api/glossaries/enums/import-file-media-type.js +10 -0
- package/built/api/glossaries/enums/import-file-media-type.js.map +1 -0
- package/built/api/glossaries/enums/import-status.d.ts +6 -0
- package/built/api/glossaries/enums/import-status.js +11 -0
- package/built/api/glossaries/enums/import-status.js.map +1 -0
- package/built/api/glossaries/enums/index.d.ts +4 -0
- package/built/api/glossaries/enums/index.js +9 -1
- package/built/api/glossaries/enums/index.js.map +1 -1
- package/built/api/glossaries/enums/part-of-speech.d.ts +11 -0
- package/built/api/glossaries/enums/part-of-speech.js +16 -0
- package/built/api/glossaries/enums/part-of-speech.js.map +1 -0
- package/built/api/glossaries/enums/suggestion-status.d.ts +5 -0
- package/built/api/glossaries/enums/suggestion-status.js +10 -0
- package/built/api/glossaries/enums/suggestion-status.js.map +1 -0
- package/built/api/glossaries/index.d.ts +39 -0
- package/built/api/glossaries/index.js +127 -0
- package/built/api/glossaries/index.js.map +1 -1
- package/built/api/glossaries/params/archive-glossaries-parameters.d.ts +4 -0
- package/built/api/glossaries/params/archive-glossaries-parameters.js +12 -0
- package/built/api/glossaries/params/archive-glossaries-parameters.js.map +1 -0
- package/built/api/glossaries/params/authorize-entries-parameters.d.ts +10 -0
- package/built/api/glossaries/params/authorize-entries-parameters.js +28 -0
- package/built/api/glossaries/params/authorize-entries-parameters.js.map +1 -0
- package/built/api/glossaries/params/create-glossary-entry-parameters.d.ts +13 -0
- package/built/api/glossaries/params/create-glossary-entry-parameters.js +36 -0
- package/built/api/glossaries/params/create-glossary-entry-parameters.js.map +1 -0
- package/built/api/glossaries/params/create-glossary-parameters.d.ts +10 -0
- package/built/api/glossaries/params/create-glossary-parameters.js +32 -0
- package/built/api/glossaries/params/create-glossary-parameters.js.map +1 -0
- package/built/api/glossaries/params/create-label-parameters.d.ts +4 -0
- package/built/api/glossaries/params/create-label-parameters.js +12 -0
- package/built/api/glossaries/params/create-label-parameters.js.map +1 -0
- package/built/api/glossaries/params/entries-bulk-action-parameters.d.ts +28 -0
- package/built/api/glossaries/params/entries-bulk-action-parameters.js +112 -0
- package/built/api/glossaries/params/entries-bulk-action-parameters.js.map +1 -0
- package/built/api/glossaries/params/entries-bulk-labels-parameters.d.ts +29 -0
- package/built/api/glossaries/params/entries-bulk-labels-parameters.js +84 -0
- package/built/api/glossaries/params/entries-bulk-labels-parameters.js.map +1 -0
- package/built/api/glossaries/params/export-entries-parameters.js +16 -48
- package/built/api/glossaries/params/export-entries-parameters.js.map +1 -1
- package/built/api/glossaries/params/initialize-import-parameters.d.ts +12 -0
- package/built/api/glossaries/params/initialize-import-parameters.js +60 -0
- package/built/api/glossaries/params/initialize-import-parameters.js.map +1 -0
- package/built/api/glossaries/params/search-glossary-counts-parameters.d.ts +11 -0
- package/built/api/glossaries/params/search-glossary-counts-parameters.js +32 -0
- package/built/api/glossaries/params/search-glossary-counts-parameters.js.map +1 -0
- package/built/api/glossaries/params/search-glossary-entries-parameters.d.ts +25 -0
- package/built/api/glossaries/params/search-glossary-entries-parameters.js +72 -0
- package/built/api/glossaries/params/search-glossary-entries-parameters.js.map +1 -0
- package/built/api/translation-memory/dto/async-action-result-dto.d.ts +10 -0
- package/built/api/translation-memory/dto/async-action-result-dto.js +3 -0
- package/built/api/translation-memory/dto/async-action-result-dto.js.map +1 -0
- package/built/api/translation-memory/dto/async-action-status.d.ts +8 -0
- package/built/api/translation-memory/dto/async-action-status.js +13 -0
- package/built/api/translation-memory/dto/async-action-status.js.map +1 -0
- package/built/api/translation-memory/dto/create-string-search-result-dto.d.ts +11 -0
- package/built/api/translation-memory/dto/create-string-search-result-dto.js +3 -0
- package/built/api/translation-memory/dto/create-string-search-result-dto.js.map +1 -0
- package/built/api/translation-memory/dto/duplicate-string-dto.d.ts +8 -0
- package/built/api/translation-memory/dto/duplicate-string-dto.js +3 -0
- package/built/api/translation-memory/dto/duplicate-string-dto.js.map +1 -0
- package/built/api/translation-memory/dto/locale-summary-dto.d.ts +8 -0
- package/built/api/translation-memory/dto/locale-summary-dto.js +3 -0
- package/built/api/translation-memory/dto/locale-summary-dto.js.map +1 -0
- package/built/api/translation-memory/dto/strings-export-async-action-result-dto.d.ts +6 -0
- package/built/api/translation-memory/dto/strings-export-async-action-result-dto.js +3 -0
- package/built/api/translation-memory/dto/strings-export-async-action-result-dto.js.map +1 -0
- package/built/api/translation-memory/dto/tm-dto.d.ts +19 -0
- package/built/api/translation-memory/dto/tm-dto.js +3 -0
- package/built/api/translation-memory/dto/tm-dto.js.map +1 -0
- package/built/api/translation-memory/dto/tm-locale-dto.d.ts +7 -0
- package/built/api/translation-memory/dto/tm-locale-dto.js +3 -0
- package/built/api/translation-memory/dto/tm-locale-dto.js.map +1 -0
- package/built/api/translation-memory/dto/tmx-import-summary-dto.d.ts +11 -0
- package/built/api/translation-memory/dto/tmx-import-summary-dto.js +3 -0
- package/built/api/translation-memory/dto/tmx-import-summary-dto.js.map +1 -0
- package/built/api/translation-memory/dto/tmx-parsing-error-dto.d.ts +6 -0
- package/built/api/translation-memory/dto/tmx-parsing-error-dto.js +3 -0
- package/built/api/translation-memory/dto/tmx-parsing-error-dto.js.map +1 -0
- package/built/api/translation-memory/dto/user-dto.d.ts +5 -0
- package/built/api/translation-memory/dto/user-dto.js +3 -0
- package/built/api/translation-memory/dto/user-dto.js.map +1 -0
- package/built/api/translation-memory/index.d.ts +27 -0
- package/built/api/translation-memory/index.js +250 -0
- package/built/api/translation-memory/index.js.map +1 -0
- package/built/api/translation-memory/params/bulk-export-tm-strings-parameters.d.ts +8 -0
- package/built/api/translation-memory/params/bulk-export-tm-strings-parameters.js +24 -0
- package/built/api/translation-memory/params/bulk-export-tm-strings-parameters.js.map +1 -0
- package/built/api/translation-memory/params/create-string-search-filter-parameters.d.ts +43 -0
- package/built/api/translation-memory/params/create-string-search-filter-parameters.js +151 -0
- package/built/api/translation-memory/params/create-string-search-filter-parameters.js.map +1 -0
- package/built/api/translation-memory/params/create-string-search-options.d.ts +7 -0
- package/built/api/translation-memory/params/create-string-search-options.js +3 -0
- package/built/api/translation-memory/params/create-string-search-options.js.map +1 -0
- package/built/api/translation-memory/params/create-tm-parameters.d.ts +8 -0
- package/built/api/translation-memory/params/create-tm-parameters.js +24 -0
- package/built/api/translation-memory/params/create-tm-parameters.js.map +1 -0
- package/built/api/translation-memory/params/escape-smp-unicode-parser-directive.d.ts +4 -0
- package/built/api/translation-memory/params/escape-smp-unicode-parser-directive.js +9 -0
- package/built/api/translation-memory/params/escape-smp-unicode-parser-directive.js.map +1 -0
- package/built/api/translation-memory/params/extended-export-metadata-type.d.ts +4 -0
- package/built/api/translation-memory/params/extended-export-metadata-type.js +9 -0
- package/built/api/translation-memory/params/extended-export-metadata-type.js.map +1 -0
- package/built/api/translation-memory/params/import-tmx-file-parameters.d.ts +17 -0
- package/built/api/translation-memory/params/import-tmx-file-parameters.js +80 -0
- package/built/api/translation-memory/params/import-tmx-file-parameters.js.map +1 -0
- package/built/api/translation-memory/params/keyword-search-type.d.ts +5 -0
- package/built/api/translation-memory/params/keyword-search-type.js +10 -0
- package/built/api/translation-memory/params/keyword-search-type.js.map +1 -0
- package/built/api/translation-memory/params/leverage-type.d.ts +5 -0
- package/built/api/translation-memory/params/leverage-type.js +10 -0
- package/built/api/translation-memory/params/leverage-type.js.map +1 -0
- package/built/api/translation-memory/params/search-keyword.d.ts +8 -0
- package/built/api/translation-memory/params/search-keyword.js +3 -0
- package/built/api/translation-memory/params/search-keyword.js.map +1 -0
- package/built/api/translation-memory/params/source-type.d.ts +7 -0
- package/built/api/translation-memory/params/source-type.js +12 -0
- package/built/api/translation-memory/params/source-type.js.map +1 -0
- package/built/api/translation-memory/params/string-search-tags.d.ts +6 -0
- package/built/api/translation-memory/params/string-search-tags.js +3 -0
- package/built/api/translation-memory/params/string-search-tags.js.map +1 -0
- package/built/api/translation-memory/params/translation-quality-type.d.ts +5 -0
- package/built/api/translation-memory/params/translation-quality-type.js +10 -0
- package/built/api/translation-memory/params/translation-quality-type.js.map +1 -0
- package/built/api/translation-memory/params/tu-translation-quality-type.d.ts +6 -0
- package/built/api/translation-memory/params/tu-translation-quality-type.js +11 -0
- package/built/api/translation-memory/params/tu-translation-quality-type.js.map +1 -0
- package/built/api/translation-memory/params/update-tm-parameters.d.ts +6 -0
- package/built/api/translation-memory/params/update-tm-parameters.js +20 -0
- package/built/api/translation-memory/params/update-tm-parameters.js.map +1 -0
- package/built/index.d.ts +56 -0
- package/built/index.js +56 -0
- package/built/index.js.map +1 -1
- package/built/package.json +5 -3
- package/built/test/glossaries.spec.js +404 -0
- package/built/test/glossaries.spec.js.map +1 -1
- package/built/test/integration/glossaries.spec.d.ts +1 -0
- package/built/test/integration/glossaries.spec.js +222 -0
- package/built/test/integration/glossaries.spec.js.map +1 -0
- package/built/test/integration/translation-memory.spec.d.ts +1 -0
- package/built/test/integration/translation-memory.spec.js +138 -0
- package/built/test/integration/translation-memory.spec.js.map +1 -0
- package/built/test/translation-memory.spec.d.ts +1 -0
- package/built/test/translation-memory.spec.js +712 -0
- package/built/test/translation-memory.spec.js.map +1 -0
- package/index.ts +56 -0
- package/package.json +5 -3
- package/test/data/sample.tmx +12 -0
- package/test/glossaries.spec.ts +559 -0
- package/test/integration/glossaries.spec.ts +358 -0
- package/test/integration/translation-memory.spec.ts +182 -0
- package/test/translation-memory.spec.ts +868 -0
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
import dotenv from "dotenv";
|
|
2
|
+
import assert from "assert";
|
|
3
|
+
import { SmartlingApiClientBuilder } from "../../api/builder/index";
|
|
4
|
+
import { SmartlingGlossariesApi } from "../../api/glossaries/index";
|
|
5
|
+
import { CreateGlossaryParameters } from "../../api/glossaries/params/create-glossary-parameters";
|
|
6
|
+
import { ArchiveGlossariesParameters } from "../../api/glossaries/params/archive-glossaries-parameters";
|
|
7
|
+
import { SearchGlossaryCountsParameters } from "../../api/glossaries/params/search-glossary-counts-parameters";
|
|
8
|
+
import { SearchGlossariesParameters } from "../../api/glossaries/params/search-glossaries-parameters";
|
|
9
|
+
import { CreateGlossaryEntryParameters } from "../../api/glossaries/params/create-glossary-entry-parameters";
|
|
10
|
+
import { SearchGlossaryEntriesParameters } from "../../api/glossaries/params/search-glossary-entries-parameters";
|
|
11
|
+
import { EntriesBulkActionParameters } from "../../api/glossaries/params/entries-bulk-action-parameters";
|
|
12
|
+
import { EntriesBulkLabelsParameters } from "../../api/glossaries/params/entries-bulk-labels-parameters";
|
|
13
|
+
import { CreateLabelParameters } from "../../api/glossaries/params/create-label-parameters";
|
|
14
|
+
import { InitializeImportParameters } from "../../api/glossaries/params/initialize-import-parameters";
|
|
15
|
+
import { ExportEntriesParameters } from "../../api/glossaries/params/export-entries-parameters";
|
|
16
|
+
import { ImportFileMediaType } from "../../api/glossaries/enums/import-file-media-type";
|
|
17
|
+
import { ExportFormat } from "../../api/glossaries/enums/export-format";
|
|
18
|
+
|
|
19
|
+
dotenv.config();
|
|
20
|
+
|
|
21
|
+
const baseSmartlingApiUrl = process.env.SMARTLING_API_BASE_URL || "https://api.smartling.com";
|
|
22
|
+
const accountUid = process.env.SMARTLING_ACCOUNT_UID as string;
|
|
23
|
+
const userId = process.env.SMARTLING_USER_ID as string;
|
|
24
|
+
const userSecret = process.env.SMARTLING_USER_SECRET as string;
|
|
25
|
+
const hasCredentials = Boolean(accountUid && userId && userSecret);
|
|
26
|
+
const logResponsesEnabled = process.env.SMARTLING_LOG_RESPONSES === "true";
|
|
27
|
+
|
|
28
|
+
function logResponse(label: string, response: unknown): void {
|
|
29
|
+
if (!logResponsesEnabled) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// eslint-disable-next-line no-console
|
|
34
|
+
console.log(`\n--- ${label} ---\n${JSON.stringify(response, null, 2)}`);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
describe("SmartlingGlossariesApi integration tests.", function integrationSuite() {
|
|
38
|
+
this.timeout(60000);
|
|
39
|
+
|
|
40
|
+
let api: SmartlingGlossariesApi;
|
|
41
|
+
let glossaryUid: string;
|
|
42
|
+
let entryUid: string;
|
|
43
|
+
let labelUid: string;
|
|
44
|
+
|
|
45
|
+
before(function skipWithoutCredentials() {
|
|
46
|
+
if (!hasCredentials) {
|
|
47
|
+
// eslint-disable-next-line no-console
|
|
48
|
+
console.log("Skipping Glossaries integration tests: set SMARTLING_ACCOUNT_UID, SMARTLING_USER_ID, SMARTLING_USER_SECRET in .env");
|
|
49
|
+
this.skip();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
api = new SmartlingApiClientBuilder()
|
|
53
|
+
.setBaseSmartlingApiUrl(baseSmartlingApiUrl)
|
|
54
|
+
.authWithUserIdAndUserSecret(userId, userSecret)
|
|
55
|
+
.build(SmartlingGlossariesApi);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
before(async () => {
|
|
59
|
+
const created = await api.createGlossary(
|
|
60
|
+
accountUid,
|
|
61
|
+
new CreateGlossaryParameters()
|
|
62
|
+
.setGlossaryName(`Integration test glossary ${Date.now()}`)
|
|
63
|
+
.setLocaleIds(["en-US", "fr-FR"])
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
logResponse("createGlossary", created);
|
|
67
|
+
({ glossaryUid } = created);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
after(async () => {
|
|
71
|
+
if (glossaryUid) {
|
|
72
|
+
const archived = await api.archiveGlossaries(
|
|
73
|
+
accountUid,
|
|
74
|
+
new ArchiveGlossariesParameters().setGlossaryUids([glossaryUid])
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
logResponse("archiveGlossaries (cleanup)", archived);
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it("gets the created glossary", async () => {
|
|
82
|
+
const glossary = await api.getGlossary(accountUid, glossaryUid);
|
|
83
|
+
|
|
84
|
+
logResponse("getGlossary", glossary);
|
|
85
|
+
assert.equal(glossary.glossaryUid, glossaryUid);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it("updates the glossary", async () => {
|
|
89
|
+
const updatedName = `Integration test glossary ${Date.now()} (updated)`;
|
|
90
|
+
const updated = await api.updateGlossary(
|
|
91
|
+
accountUid,
|
|
92
|
+
glossaryUid,
|
|
93
|
+
new CreateGlossaryParameters()
|
|
94
|
+
.setGlossaryName(updatedName)
|
|
95
|
+
.setLocaleIds(["en-US", "fr-FR"])
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
logResponse("updateGlossary", updated);
|
|
99
|
+
assert.equal(updated.glossaryUid, glossaryUid);
|
|
100
|
+
assert.equal(updated.glossaryName, updatedName);
|
|
101
|
+
assert.equal(updated.localeIds.length, 2);
|
|
102
|
+
assert.ok(updated.localeIds.includes("en-US"));
|
|
103
|
+
assert.ok(updated.localeIds.includes("fr-FR"));
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it("archives and restores the glossary", async () => {
|
|
107
|
+
const archived = await api.archiveGlossaries(
|
|
108
|
+
accountUid,
|
|
109
|
+
new ArchiveGlossariesParameters().setGlossaryUids([glossaryUid])
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
logResponse("archiveGlossaries", archived);
|
|
113
|
+
assert.ok(archived.glossaryUids.includes(glossaryUid));
|
|
114
|
+
|
|
115
|
+
const restored = await api.restoreGlossaries(
|
|
116
|
+
accountUid,
|
|
117
|
+
new ArchiveGlossariesParameters().setGlossaryUids([glossaryUid])
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
logResponse("restoreGlossaries", restored);
|
|
121
|
+
assert.ok(restored.glossaryUids.includes(glossaryUid));
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
it("searches glossaries", async () => {
|
|
125
|
+
const result = await api.searchGlossaries(
|
|
126
|
+
accountUid,
|
|
127
|
+
new SearchGlossariesParameters().setGlossaryUids([glossaryUid])
|
|
128
|
+
);
|
|
129
|
+
|
|
130
|
+
logResponse("searchGlossaries", result);
|
|
131
|
+
assert.equal(result.items.length, 1);
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
it("searches glossaries with entries counts", async () => {
|
|
135
|
+
const result = await api.searchGlossariesWithEntriesCounts(
|
|
136
|
+
accountUid,
|
|
137
|
+
new SearchGlossaryCountsParameters().setGlossaryUids([glossaryUid])
|
|
138
|
+
);
|
|
139
|
+
|
|
140
|
+
logResponse("searchGlossariesWithEntriesCounts", result);
|
|
141
|
+
assert.equal(result.items.length, 1);
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
it("creates a glossary entry", async () => {
|
|
145
|
+
const entry = await api.createGlossaryEntry(
|
|
146
|
+
accountUid,
|
|
147
|
+
glossaryUid,
|
|
148
|
+
new CreateGlossaryEntryParameters()
|
|
149
|
+
.setDefinition("Integration test term")
|
|
150
|
+
.setTranslations([{ localeId: "fr-FR", term: "Terme de test" }])
|
|
151
|
+
);
|
|
152
|
+
|
|
153
|
+
logResponse("createGlossaryEntry", entry);
|
|
154
|
+
({ entryUid } = entry);
|
|
155
|
+
assert.ok(entryUid);
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
it("reads the created glossary entry", async () => {
|
|
159
|
+
const entry = await api.readGlossaryEntry(accountUid, glossaryUid, entryUid);
|
|
160
|
+
|
|
161
|
+
logResponse("readGlossaryEntry", entry);
|
|
162
|
+
assert.equal(entry.entryUid, entryUid);
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
it("updates the glossary entry", async () => {
|
|
166
|
+
const updatedDefinition = "Integration test term (updated)";
|
|
167
|
+
const updatedTerm = "Terme de test (modifie)";
|
|
168
|
+
const entry = await api.updateGlossaryEntry(
|
|
169
|
+
accountUid,
|
|
170
|
+
glossaryUid,
|
|
171
|
+
entryUid,
|
|
172
|
+
new CreateGlossaryEntryParameters()
|
|
173
|
+
.setDefinition(updatedDefinition)
|
|
174
|
+
.setTranslations([{ localeId: "fr-FR", term: updatedTerm }])
|
|
175
|
+
);
|
|
176
|
+
|
|
177
|
+
logResponse("updateGlossaryEntry", entry);
|
|
178
|
+
assert.equal(entry.entryUid, entryUid);
|
|
179
|
+
assert.equal(entry.definition, updatedDefinition);
|
|
180
|
+
|
|
181
|
+
const frTranslation = entry.translations.find((translation) => translation.localeId === "fr-FR");
|
|
182
|
+
|
|
183
|
+
assert.ok(frTranslation);
|
|
184
|
+
assert.equal(frTranslation.term, updatedTerm);
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
it("searches glossary entries", async () => {
|
|
188
|
+
const result = await api.searchGlossaryEntries(
|
|
189
|
+
accountUid,
|
|
190
|
+
glossaryUid,
|
|
191
|
+
new SearchGlossaryEntriesParameters().setEntryUids([entryUid])
|
|
192
|
+
);
|
|
193
|
+
|
|
194
|
+
logResponse("searchGlossaryEntries", result);
|
|
195
|
+
assert.equal(result.items.length, 1);
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
it("creates and reads back a label", async () => {
|
|
199
|
+
const label = await api.createGlossaryLabel(
|
|
200
|
+
accountUid,
|
|
201
|
+
new CreateLabelParameters().setLabelText(`Integration label ${Date.now()}`)
|
|
202
|
+
);
|
|
203
|
+
|
|
204
|
+
logResponse("createGlossaryLabel", label);
|
|
205
|
+
({ labelUid } = label);
|
|
206
|
+
|
|
207
|
+
const updatedLabelText = `Integration label ${Date.now()} (updated)`;
|
|
208
|
+
const updatedLabel = await api.updateGlossaryLabel(
|
|
209
|
+
accountUid,
|
|
210
|
+
labelUid,
|
|
211
|
+
new CreateLabelParameters().setLabelText(updatedLabelText)
|
|
212
|
+
);
|
|
213
|
+
|
|
214
|
+
logResponse("updateGlossaryLabel", updatedLabel);
|
|
215
|
+
assert.equal(updatedLabel.labelUid, labelUid);
|
|
216
|
+
assert.equal(updatedLabel.labelText, updatedLabelText);
|
|
217
|
+
|
|
218
|
+
const allLabels = await api.readAllGlossaryLabels(accountUid);
|
|
219
|
+
|
|
220
|
+
logResponse("readAllGlossaryLabels", allLabels);
|
|
221
|
+
|
|
222
|
+
const persistedLabel = allLabels.items.find((label2) => label2.labelUid === labelUid);
|
|
223
|
+
|
|
224
|
+
assert.ok(persistedLabel);
|
|
225
|
+
assert.equal(persistedLabel.labelText, updatedLabelText);
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
it("adds and removes a label on the glossary entry", async () => {
|
|
229
|
+
const addResult = await api.addLabelsToGlossaryEntries(
|
|
230
|
+
accountUid,
|
|
231
|
+
glossaryUid,
|
|
232
|
+
new EntriesBulkLabelsParameters()
|
|
233
|
+
.setFilterEntryUids([entryUid])
|
|
234
|
+
.setLabelUids([labelUid])
|
|
235
|
+
);
|
|
236
|
+
|
|
237
|
+
logResponse("addLabelsToGlossaryEntries", addResult);
|
|
238
|
+
assert.ok(addResult.operationUid);
|
|
239
|
+
|
|
240
|
+
const removeResult = await api.removeLabelsFromGlossaryEntries(
|
|
241
|
+
accountUid,
|
|
242
|
+
glossaryUid,
|
|
243
|
+
new EntriesBulkLabelsParameters()
|
|
244
|
+
.setFilterEntryUids([entryUid])
|
|
245
|
+
.setLabelUids([labelUid])
|
|
246
|
+
);
|
|
247
|
+
|
|
248
|
+
logResponse("removeLabelsFromGlossaryEntries", removeResult);
|
|
249
|
+
assert.ok(removeResult.operationUid);
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
it("deletes the label", async () => {
|
|
253
|
+
await api.deleteGlossaryLabel(accountUid, labelUid);
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
it("archives and restores the glossary entry", async () => {
|
|
257
|
+
const archiveResult = await api.archiveGlossaryEntries(
|
|
258
|
+
accountUid,
|
|
259
|
+
glossaryUid,
|
|
260
|
+
new EntriesBulkActionParameters().setFilterEntryUids([entryUid])
|
|
261
|
+
);
|
|
262
|
+
|
|
263
|
+
logResponse("archiveGlossaryEntries", archiveResult);
|
|
264
|
+
assert.ok(archiveResult.operationUid);
|
|
265
|
+
|
|
266
|
+
const restoreResult = await api.restoreGlossaryEntries(
|
|
267
|
+
accountUid,
|
|
268
|
+
glossaryUid,
|
|
269
|
+
new EntriesBulkActionParameters().setFilterEntryUids([entryUid])
|
|
270
|
+
);
|
|
271
|
+
|
|
272
|
+
logResponse("restoreGlossaryEntries", restoreResult);
|
|
273
|
+
assert.ok(restoreResult.operationUid);
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
it("exports glossary entries", async () => {
|
|
277
|
+
const exported = await api.exportGlossaryEntries(
|
|
278
|
+
accountUid,
|
|
279
|
+
glossaryUid,
|
|
280
|
+
new ExportEntriesParameters().setFormat(ExportFormat.CSV).setLocaleIds(["fr-FR"])
|
|
281
|
+
);
|
|
282
|
+
|
|
283
|
+
logResponse("exportGlossaryEntries (length)", exported.length);
|
|
284
|
+
assert.ok(exported.length > 0);
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
it("initializes, checks, and confirms a glossary import", async () => {
|
|
288
|
+
// The real glossary CSV import format requires the exact column-header shape
|
|
289
|
+
// the export endpoint produces, not a bare "definition,fr-FR" header: every
|
|
290
|
+
// column must be present (empty string where unused), and each translation
|
|
291
|
+
// column must be named "{Column} {Locale description} [{localeId}] {localeId}"
|
|
292
|
+
// (e.g. "Term French (France) [fr-FR] fr-FR") - confirmed against the real
|
|
293
|
+
// service's GlossaryImportHeaderParser/FormattingUtils.isColumnRecognized,
|
|
294
|
+
// and against a real exportGlossaryEntries response for this exact locale.
|
|
295
|
+
const localeColumnSuffix = "French (France) [fr-FR] fr-FR";
|
|
296
|
+
const importHeader = [
|
|
297
|
+
"ID", "Definition", "Part Of Speech", "Label Names", "Created By", "Last Modified By",
|
|
298
|
+
"Created At", "Last Modified At", "Archived", "MT-suitable", "Suggestion-status",
|
|
299
|
+
`Term ${localeColumnSuffix}`,
|
|
300
|
+
`Linguistic Variations ${localeColumnSuffix}`,
|
|
301
|
+
`Notes ${localeColumnSuffix}`,
|
|
302
|
+
`Case Sensitive ${localeColumnSuffix}`,
|
|
303
|
+
`Exact Match ${localeColumnSuffix}`,
|
|
304
|
+
`Do Not Translate ${localeColumnSuffix}`,
|
|
305
|
+
`Disabled ${localeColumnSuffix}`,
|
|
306
|
+
`Last Modified By ${localeColumnSuffix}`
|
|
307
|
+
];
|
|
308
|
+
const importRow = new Array(importHeader.length).fill("");
|
|
309
|
+
|
|
310
|
+
importRow[1] = "Imported term";
|
|
311
|
+
importRow[11] = "Terme importe";
|
|
312
|
+
|
|
313
|
+
const importCsvContent = `${importHeader.map((column) => `"${column}"`).join(",")}\n`
|
|
314
|
+
+ `${importRow.map((value) => `"${value}"`).join(",")}\n`;
|
|
315
|
+
|
|
316
|
+
const importResult = await api.initializeGlossaryImport(
|
|
317
|
+
accountUid,
|
|
318
|
+
glossaryUid,
|
|
319
|
+
new InitializeImportParameters()
|
|
320
|
+
.setImportFileContent(importCsvContent)
|
|
321
|
+
.setImportFileName("integration-import.csv")
|
|
322
|
+
.setImportFileMediaType(ImportFileMediaType.CSV)
|
|
323
|
+
);
|
|
324
|
+
|
|
325
|
+
logResponse("initializeGlossaryImport", importResult);
|
|
326
|
+
assert.ok(importResult.glossaryImport.importUid);
|
|
327
|
+
assert.ok(importResult.entryChanges);
|
|
328
|
+
|
|
329
|
+
const status = await api.importStatus(
|
|
330
|
+
accountUid,
|
|
331
|
+
glossaryUid,
|
|
332
|
+
importResult.glossaryImport.importUid
|
|
333
|
+
);
|
|
334
|
+
|
|
335
|
+
logResponse("importStatus", status);
|
|
336
|
+
assert.equal(status.importUid, importResult.glossaryImport.importUid);
|
|
337
|
+
|
|
338
|
+
const confirmed = await api.confirmGlossaryImport(
|
|
339
|
+
accountUid,
|
|
340
|
+
glossaryUid,
|
|
341
|
+
importResult.glossaryImport.importUid
|
|
342
|
+
);
|
|
343
|
+
|
|
344
|
+
logResponse("confirmGlossaryImport", confirmed);
|
|
345
|
+
assert.equal(confirmed.importUid, importResult.glossaryImport.importUid);
|
|
346
|
+
});
|
|
347
|
+
|
|
348
|
+
it("removes the glossary entry", async () => {
|
|
349
|
+
const result = await api.removeGlossaryEntries(
|
|
350
|
+
accountUid,
|
|
351
|
+
glossaryUid,
|
|
352
|
+
new EntriesBulkActionParameters().setFilterEntryUids([entryUid])
|
|
353
|
+
);
|
|
354
|
+
|
|
355
|
+
logResponse("removeGlossaryEntries", result);
|
|
356
|
+
assert.ok(result.operationUid);
|
|
357
|
+
});
|
|
358
|
+
});
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import dotenv from "dotenv";
|
|
2
|
+
import assert from "assert";
|
|
3
|
+
import { SmartlingApiClientBuilder } from "../../api/builder/index";
|
|
4
|
+
import { SmartlingTranslationMemoryApi } from "../../api/translation-memory/index";
|
|
5
|
+
import { ImportTmxFileParameters } from "../../api/translation-memory/params/import-tmx-file-parameters";
|
|
6
|
+
import { CreateStringSearchFilterParameters } from "../../api/translation-memory/params/create-string-search-filter-parameters";
|
|
7
|
+
import { BulkExportTmStringsParameters } from "../../api/translation-memory/params/bulk-export-tm-strings-parameters";
|
|
8
|
+
import { CreateTmParameters } from "../../api/translation-memory/params/create-tm-parameters";
|
|
9
|
+
import { UpdateTmParameters } from "../../api/translation-memory/params/update-tm-parameters";
|
|
10
|
+
import { TranslationQualityType } from "../../api/translation-memory/params/translation-quality-type";
|
|
11
|
+
|
|
12
|
+
dotenv.config();
|
|
13
|
+
|
|
14
|
+
const baseSmartlingApiUrl = process.env.SMARTLING_API_BASE_URL || "https://api.smartling.com";
|
|
15
|
+
const accountUid = process.env.SMARTLING_ACCOUNT_UID as string;
|
|
16
|
+
const userId = process.env.SMARTLING_USER_ID as string;
|
|
17
|
+
const userSecret = process.env.SMARTLING_USER_SECRET as string;
|
|
18
|
+
const hasCredentials = Boolean(accountUid && userId && userSecret);
|
|
19
|
+
const logResponsesEnabled = process.env.SMARTLING_LOG_RESPONSES === "true";
|
|
20
|
+
|
|
21
|
+
function logResponse(label: string, response: unknown): void {
|
|
22
|
+
if (!logResponsesEnabled) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// eslint-disable-next-line no-console
|
|
27
|
+
console.log(`\n--- ${label} ---\n${JSON.stringify(response, null, 2)}`);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function delay(milliseconds: number): Promise<void> {
|
|
31
|
+
return new Promise((resolve) => {
|
|
32
|
+
setTimeout(resolve, milliseconds);
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
describe("SmartlingTranslationMemoryApi integration tests.", function integrationSuite() {
|
|
37
|
+
// The export test's two polling loops (search-indexing + export-status) can each run close
|
|
38
|
+
// to their own deadline back to back, plus real network latency on top - give enough room
|
|
39
|
+
// that Mocha's own timeout doesn't fire before those loops give up on their own.
|
|
40
|
+
this.timeout(240000);
|
|
41
|
+
|
|
42
|
+
let api: SmartlingTranslationMemoryApi;
|
|
43
|
+
let tmUid: string;
|
|
44
|
+
|
|
45
|
+
before(function skipWithoutCredentials() {
|
|
46
|
+
if (!hasCredentials) {
|
|
47
|
+
// eslint-disable-next-line no-console
|
|
48
|
+
console.log("Skipping Translation Memory integration tests: set SMARTLING_ACCOUNT_UID, SMARTLING_USER_ID, SMARTLING_USER_SECRET in .env");
|
|
49
|
+
this.skip();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
api = new SmartlingApiClientBuilder()
|
|
53
|
+
.setBaseSmartlingApiUrl(baseSmartlingApiUrl)
|
|
54
|
+
.authWithUserIdAndUserSecret(userId, userSecret)
|
|
55
|
+
.build(SmartlingTranslationMemoryApi);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
before(async () => {
|
|
59
|
+
const created = await api.createTm(
|
|
60
|
+
accountUid,
|
|
61
|
+
new CreateTmParameters()
|
|
62
|
+
.setName(`api-sdk-nodejs integration test TM ${Date.now()}`)
|
|
63
|
+
.setDescription("Created by the api-sdk-nodejs integration suite")
|
|
64
|
+
.setSourceLocaleId("en-US")
|
|
65
|
+
.setTranslationQuality(TranslationQualityType.TRANSLATION)
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
logResponse("createTm", created);
|
|
69
|
+
assert.ok(created, "createTm returned null");
|
|
70
|
+
({ tmUid } = created);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
after(async () => {
|
|
74
|
+
if (tmUid) {
|
|
75
|
+
const deleted = await api.deleteTm(accountUid, tmUid);
|
|
76
|
+
|
|
77
|
+
logResponse("deleteTm (cleanup)", deleted);
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it("Updates the TM", async () => {
|
|
82
|
+
const updatedName = `api-sdk-nodejs integration test TM (updated) ${Date.now()}`;
|
|
83
|
+
const updatedDescription = "Updated by the api-sdk-nodejs integration suite";
|
|
84
|
+
|
|
85
|
+
const updated = await api.updateTm(
|
|
86
|
+
accountUid,
|
|
87
|
+
new UpdateTmParameters()
|
|
88
|
+
.setTmUid(tmUid)
|
|
89
|
+
.setName(updatedName)
|
|
90
|
+
.setDescription(updatedDescription)
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
logResponse("updateTm", updated);
|
|
94
|
+
|
|
95
|
+
assert.ok(updated, "updateTm returned null");
|
|
96
|
+
assert.equal(updated.tmUid, tmUid);
|
|
97
|
+
assert.equal(updated.name, updatedName);
|
|
98
|
+
assert.equal(updated.description, updatedDescription);
|
|
99
|
+
assert.ok(updated.created instanceof Date);
|
|
100
|
+
assert.ok(updated.lastModified instanceof Date);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it("Imports a TMX file", async () => {
|
|
104
|
+
const result = await api.importTmxFile(
|
|
105
|
+
accountUid,
|
|
106
|
+
new ImportTmxFileParameters()
|
|
107
|
+
.setFileFromLocalFilePath("./test/data/sample.tmx")
|
|
108
|
+
.setFileUri(`integration-test-${Date.now()}.tmx`)
|
|
109
|
+
.setTmUid(tmUid)
|
|
110
|
+
.setDescription("api-sdk-nodejs integration test import")
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
logResponse("importTmxFile", result);
|
|
114
|
+
|
|
115
|
+
assert.ok(result.jobUid);
|
|
116
|
+
assert.ok(result.tmxUid);
|
|
117
|
+
assert.equal(typeof result.stringCount, "number");
|
|
118
|
+
assert.equal(typeof result.wordCount, "number");
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
it("Creates a string search, bulk-exports it, polls status, and downloads the TMX", async () => {
|
|
122
|
+
// A just-imported TMX string isn't immediately searchable: createStringSearch can
|
|
123
|
+
// briefly return stringCount: 0 right after import, so retry until it's indexed.
|
|
124
|
+
const searchFilter = new CreateStringSearchFilterParameters().setTmUids([tmUid]);
|
|
125
|
+
let searchResult = await api.createStringSearch(accountUid, searchFilter);
|
|
126
|
+
const searchDeadline = Date.now() + 30000;
|
|
127
|
+
|
|
128
|
+
while (!searchResult?.stringCount && Date.now() < searchDeadline) {
|
|
129
|
+
/* eslint-disable-next-line no-await-in-loop */
|
|
130
|
+
await delay(2000);
|
|
131
|
+
/* eslint-disable-next-line no-await-in-loop */
|
|
132
|
+
searchResult = await api.createStringSearch(accountUid, searchFilter);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
logResponse("createStringSearch", searchResult);
|
|
136
|
+
assert.ok(searchResult, "createStringSearch returned null");
|
|
137
|
+
assert.ok(searchResult.searchUid);
|
|
138
|
+
assert.ok(searchResult.stringCount);
|
|
139
|
+
|
|
140
|
+
const exportResult = await api.bulkExportTmStrings(
|
|
141
|
+
accountUid,
|
|
142
|
+
new BulkExportTmStringsParameters().setSearchUid(searchResult.searchUid)
|
|
143
|
+
);
|
|
144
|
+
|
|
145
|
+
logResponse("bulkExportTmStrings", exportResult);
|
|
146
|
+
assert.ok(exportResult, "bulkExportTmStrings returned null");
|
|
147
|
+
assert.ok(exportResult.actionUid);
|
|
148
|
+
|
|
149
|
+
// executionComplete alone isn't a success signal: a CANCELED/STOPPED action is
|
|
150
|
+
// "finished" in the sense that it won't progress further, so poll until the status
|
|
151
|
+
// reaches any terminal state, not just until executionComplete flips true.
|
|
152
|
+
const terminalStatuses = ["SUCCESS", "FAILURE", "CANCELED", "STOPPED"];
|
|
153
|
+
let status = await api.getBulkExportTmStringsStatus(accountUid, exportResult.actionUid);
|
|
154
|
+
const deadline = Date.now() + 90000;
|
|
155
|
+
|
|
156
|
+
while (
|
|
157
|
+
!(status?.executionComplete || terminalStatuses.includes(status?.actionStatus))
|
|
158
|
+
&& Date.now() < deadline
|
|
159
|
+
) {
|
|
160
|
+
/* eslint-disable-next-line no-await-in-loop */
|
|
161
|
+
await delay(2000);
|
|
162
|
+
/* eslint-disable-next-line no-await-in-loop */
|
|
163
|
+
status = await api.getBulkExportTmStringsStatus(accountUid, exportResult.actionUid);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
logResponse("getBulkExportTmStringsStatus", status);
|
|
167
|
+
assert.ok(status, "getBulkExportTmStringsStatus returned null");
|
|
168
|
+
assert.equal(status.actionStatus, "SUCCESS");
|
|
169
|
+
assert.equal(status.executionComplete, true);
|
|
170
|
+
assert.ok(status.tmxDownloadKey, "bulkExportTmStrings completed but returned no tmxDownloadKey - can't exercise downloadTmxFile");
|
|
171
|
+
|
|
172
|
+
const downloaded = await api.downloadTmxFile(accountUid, status.tmxDownloadKey);
|
|
173
|
+
|
|
174
|
+
logResponse("downloadTmxFile", {
|
|
175
|
+
fileName: downloaded.fileName,
|
|
176
|
+
contentType: downloaded.contentType,
|
|
177
|
+
byteLength: downloaded.fileContent.byteLength
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
assert.ok(downloaded.fileContent.byteLength > 0);
|
|
181
|
+
});
|
|
182
|
+
});
|