@language-weaver/lw-sdk-js 1.0.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/lib/CloudLanguageWeaverClient.d.ts +61 -0
- package/lib/CloudLanguageWeaverClient.js +514 -0
- package/lib/CloudLanguageWeaverClient.js.map +1 -0
- package/lib/EdgeLanguageWeaverClient.d.ts +60 -0
- package/lib/EdgeLanguageWeaverClient.js +580 -0
- package/lib/EdgeLanguageWeaverClient.js.map +1 -0
- package/lib/LanguageWeaverClient.d.ts +15 -0
- package/lib/LanguageWeaverClient.js +3 -0
- package/lib/LanguageWeaverClient.js.map +1 -0
- package/lib/SdkFactory.d.ts +9 -0
- package/lib/SdkFactory.js +56 -0
- package/lib/SdkFactory.js.map +1 -0
- package/lib/auth/LanguageWeaverAuthentication.d.ts +12 -0
- package/lib/auth/LanguageWeaverAuthentication.js +25 -0
- package/lib/auth/LanguageWeaverAuthentication.js.map +1 -0
- package/lib/auth/domain/SelfInformation.d.ts +8 -0
- package/lib/auth/domain/SelfInformation.js +29 -0
- package/lib/auth/domain/SelfInformation.js.map +1 -0
- package/lib/auth/domain/Token.d.ts +15 -0
- package/lib/auth/domain/Token.js +53 -0
- package/lib/auth/domain/Token.js.map +1 -0
- package/lib/auth/domain/UserSelfInformation.d.ts +38 -0
- package/lib/auth/domain/UserSelfInformation.js +129 -0
- package/lib/auth/domain/UserSelfInformation.js.map +1 -0
- package/lib/common/api/ErrorResponse.d.ts +9 -0
- package/lib/common/api/ErrorResponse.js +31 -0
- package/lib/common/api/ErrorResponse.js.map +1 -0
- package/lib/common/configurations/ClientConfiguration.d.ts +14 -0
- package/lib/common/configurations/ClientConfiguration.js +46 -0
- package/lib/common/configurations/ClientConfiguration.js.map +1 -0
- package/lib/common/configurations/CredentialsConfiguration.d.ts +9 -0
- package/lib/common/configurations/CredentialsConfiguration.js +35 -0
- package/lib/common/configurations/CredentialsConfiguration.js.map +1 -0
- package/lib/common/configurations/RetryConfiguration.d.ts +8 -0
- package/lib/common/configurations/RetryConfiguration.js +31 -0
- package/lib/common/configurations/RetryConfiguration.js.map +1 -0
- package/lib/common/configurations/TokenConfiguration.d.ts +10 -0
- package/lib/common/configurations/TokenConfiguration.js +29 -0
- package/lib/common/configurations/TokenConfiguration.js.map +1 -0
- package/lib/common/constants/EdgeFinalSubStatuses.d.ts +5 -0
- package/lib/common/constants/EdgeFinalSubStatuses.js +9 -0
- package/lib/common/constants/EdgeFinalSubStatuses.js.map +1 -0
- package/lib/common/constants/EdgeStatuses.d.ts +3 -0
- package/lib/common/constants/EdgeStatuses.js +7 -0
- package/lib/common/constants/EdgeStatuses.js.map +1 -0
- package/lib/common/constants/FileExtensions.d.ts +2 -0
- package/lib/common/constants/FileExtensions.js +52 -0
- package/lib/common/constants/FileExtensions.js.map +1 -0
- package/lib/common/constants/FormatToMimeType.d.ts +1 -0
- package/lib/common/constants/FormatToMimeType.js +33 -0
- package/lib/common/constants/FormatToMimeType.js.map +1 -0
- package/lib/common/constants/TranslationConstants.d.ts +62 -0
- package/lib/common/constants/TranslationConstants.js +69 -0
- package/lib/common/constants/TranslationConstants.js.map +1 -0
- package/lib/common/constants/languages/Iso639Mapping.d.ts +1 -0
- package/lib/common/constants/languages/Iso639Mapping.js +95 -0
- package/lib/common/constants/languages/Iso639Mapping.js.map +1 -0
- package/lib/common/exceptions/EdgeTranslationException.d.ts +3 -0
- package/lib/common/exceptions/EdgeTranslationException.js +17 -0
- package/lib/common/exceptions/EdgeTranslationException.js.map +1 -0
- package/lib/common/exceptions/TranslationException.d.ts +4 -0
- package/lib/common/exceptions/TranslationException.js +17 -0
- package/lib/common/exceptions/TranslationException.js.map +1 -0
- package/lib/common/requests/RestClient.d.ts +34 -0
- package/lib/common/requests/RestClient.js +331 -0
- package/lib/common/requests/RestClient.js.map +1 -0
- package/lib/common/requests/TraceRequestInfo.d.ts +9 -0
- package/lib/common/requests/TraceRequestInfo.js +20 -0
- package/lib/common/requests/TraceRequestInfo.js.map +1 -0
- package/lib/common/utils/HttpUtils.d.ts +5 -0
- package/lib/common/utils/HttpUtils.js +26 -0
- package/lib/common/utils/HttpUtils.js.map +1 -0
- package/lib/common/utils/Utils.d.ts +34 -0
- package/lib/common/utils/Utils.js +319 -0
- package/lib/common/utils/Utils.js.map +1 -0
- package/lib/index.d.ts +51 -0
- package/lib/index.js +99 -0
- package/lib/index.js.map +1 -0
- package/lib/translation/common/Format.d.ts +39 -0
- package/lib/translation/common/Format.js +52 -0
- package/lib/translation/common/Format.js.map +1 -0
- package/lib/translation/common/Product.d.ts +4 -0
- package/lib/translation/common/Product.js +9 -0
- package/lib/translation/common/Product.js.map +1 -0
- package/lib/translation/common/Regions.d.ts +4 -0
- package/lib/translation/common/Regions.js +9 -0
- package/lib/translation/common/Regions.js.map +1 -0
- package/lib/translation/common/Statuses.d.ts +6 -0
- package/lib/translation/common/Statuses.js +10 -0
- package/lib/translation/common/Statuses.js.map +1 -0
- package/lib/translation/translate/request/TranslateBatchFileRequest.d.ts +21 -0
- package/lib/translation/translate/request/TranslateBatchFileRequest.js +84 -0
- package/lib/translation/translate/request/TranslateBatchFileRequest.js.map +1 -0
- package/lib/translation/translate/request/TranslateFileRequest.d.ts +12 -0
- package/lib/translation/translate/request/TranslateFileRequest.js +68 -0
- package/lib/translation/translate/request/TranslateFileRequest.js.map +1 -0
- package/lib/translation/translate/request/TranslateRequest.d.ts +19 -0
- package/lib/translation/translate/request/TranslateRequest.js +67 -0
- package/lib/translation/translate/request/TranslateRequest.js.map +1 -0
- package/lib/translation/translate/request/TranslateTextRequest.d.ts +7 -0
- package/lib/translation/translate/request/TranslateTextRequest.js +46 -0
- package/lib/translation/translate/request/TranslateTextRequest.js.map +1 -0
- package/lib/translation/translate/request/cloud/CloudTranslateBatchFileRequest.d.ts +3 -0
- package/lib/translation/translate/request/cloud/CloudTranslateBatchFileRequest.js +30 -0
- package/lib/translation/translate/request/cloud/CloudTranslateBatchFileRequest.js.map +1 -0
- package/lib/translation/translate/request/cloud/CloudTranslateFileRequest.d.ts +3 -0
- package/lib/translation/translate/request/cloud/CloudTranslateFileRequest.js +30 -0
- package/lib/translation/translate/request/cloud/CloudTranslateFileRequest.js.map +1 -0
- package/lib/translation/translate/request/cloud/CloudTranslateTextRequest.d.ts +3 -0
- package/lib/translation/translate/request/cloud/CloudTranslateTextRequest.js +30 -0
- package/lib/translation/translate/request/cloud/CloudTranslateTextRequest.js.map +1 -0
- package/lib/translation/translate/request/edge/EdgeTranslateBatchFileRequest.d.ts +16 -0
- package/lib/translation/translate/request/edge/EdgeTranslateBatchFileRequest.js +70 -0
- package/lib/translation/translate/request/edge/EdgeTranslateBatchFileRequest.js.map +1 -0
- package/lib/translation/translate/request/edge/EdgeTranslateFileRequest.d.ts +16 -0
- package/lib/translation/translate/request/edge/EdgeTranslateFileRequest.js +70 -0
- package/lib/translation/translate/request/edge/EdgeTranslateFileRequest.js.map +1 -0
- package/lib/translation/translate/request/edge/EdgeTranslateTextRequest.d.ts +16 -0
- package/lib/translation/translate/request/edge/EdgeTranslateTextRequest.js +70 -0
- package/lib/translation/translate/request/edge/EdgeTranslateTextRequest.js.map +1 -0
- package/lib/translation/translate/response/AsyncTranslationResponse.d.ts +20 -0
- package/lib/translation/translate/response/AsyncTranslationResponse.js +69 -0
- package/lib/translation/translate/response/AsyncTranslationResponse.js.map +1 -0
- package/lib/translation/translate/response/DictionaryResponse.d.ts +11 -0
- package/lib/translation/translate/response/DictionaryResponse.js +39 -0
- package/lib/translation/translate/response/DictionaryResponse.js.map +1 -0
- package/lib/translation/translate/response/LanguagePair.d.ts +14 -0
- package/lib/translation/translate/response/LanguagePair.js +49 -0
- package/lib/translation/translate/response/LanguagePair.js.map +1 -0
- package/lib/translation/translate/response/StatusTranslationResponse.d.ts +19 -0
- package/lib/translation/translate/response/StatusTranslationResponse.js +59 -0
- package/lib/translation/translate/response/StatusTranslationResponse.js.map +1 -0
- package/lib/translation/translate/response/TranslationStatistics.d.ts +20 -0
- package/lib/translation/translate/response/TranslationStatistics.js +69 -0
- package/lib/translation/translate/response/TranslationStatistics.js.map +1 -0
- package/lib/translation/translate/response/cloud/CloudDictionaryResponse.d.ts +32 -0
- package/lib/translation/translate/response/cloud/CloudDictionaryResponse.js +110 -0
- package/lib/translation/translate/response/cloud/CloudDictionaryResponse.js.map +1 -0
- package/lib/translation/translate/response/cloud/CloudLanguagePair.d.ts +17 -0
- package/lib/translation/translate/response/cloud/CloudLanguagePair.js +59 -0
- package/lib/translation/translate/response/cloud/CloudLanguagePair.js.map +1 -0
- package/lib/translation/translate/response/edge/EdgeAsyncTranslationResponse.d.ts +5 -0
- package/lib/translation/translate/response/edge/EdgeAsyncTranslationResponse.js +19 -0
- package/lib/translation/translate/response/edge/EdgeAsyncTranslationResponse.js.map +1 -0
- package/lib/translation/translate/response/edge/EdgeDictionaryResponse.d.ts +11 -0
- package/lib/translation/translate/response/edge/EdgeDictionaryResponse.js +39 -0
- package/lib/translation/translate/response/edge/EdgeDictionaryResponse.js.map +1 -0
- package/lib/translation/translate/response/edge/EdgeLanguagePair.d.ts +9 -0
- package/lib/translation/translate/response/edge/EdgeLanguagePair.js +50 -0
- package/lib/translation/translate/response/edge/EdgeLanguagePair.js.map +1 -0
- package/lib/translation/translate/response/edge/EdgeStatusTranslationResponse.d.ts +26 -0
- package/lib/translation/translate/response/edge/EdgeStatusTranslationResponse.js +79 -0
- package/lib/translation/translate/response/edge/EdgeStatusTranslationResponse.js.map +1 -0
- package/lib/translation/translate/response/edge/MemberPair.d.ts +29 -0
- package/lib/translation/translate/response/edge/MemberPair.js +99 -0
- package/lib/translation/translate/response/edge/MemberPair.js.map +1 -0
- package/lib/translation/translate/response/edge/Profile.d.ts +26 -0
- package/lib/translation/translate/response/edge/Profile.js +89 -0
- package/lib/translation/translate/response/edge/Profile.js.map +1 -0
- package/lib/translation/translate/response/edge/Result.d.ts +32 -0
- package/lib/translation/translate/response/edge/Result.js +109 -0
- package/lib/translation/translate/response/edge/Result.js.map +1 -0
- package/lib/translation/translate/response/edge/Timestamps.d.ts +11 -0
- package/lib/translation/translate/response/edge/Timestamps.js +39 -0
- package/lib/translation/translate/response/edge/Timestamps.js.map +1 -0
- package/lib/translation/translate/result/DictionariesResult.d.ts +6 -0
- package/lib/translation/translate/result/DictionariesResult.js +19 -0
- package/lib/translation/translate/result/DictionariesResult.js.map +1 -0
- package/lib/translation/translate/result/LanguagePairsResult.d.ts +6 -0
- package/lib/translation/translate/result/LanguagePairsResult.js +19 -0
- package/lib/translation/translate/result/LanguagePairsResult.js.map +1 -0
- package/lib/translation/translate/result/TranslateTextResult.d.ts +5 -0
- package/lib/translation/translate/result/TranslateTextResult.js +19 -0
- package/lib/translation/translate/result/TranslateTextResult.js.map +1 -0
- package/lib/translation/translate/result/TranslationBatchFileResult.d.ts +6 -0
- package/lib/translation/translate/result/TranslationBatchFileResult.js +19 -0
- package/lib/translation/translate/result/TranslationBatchFileResult.js.map +1 -0
- package/lib/translation/translate/result/TranslationFileResult.d.ts +11 -0
- package/lib/translation/translate/result/TranslationFileResult.js +39 -0
- package/lib/translation/translate/result/TranslationFileResult.js.map +1 -0
- package/lib/translation/translate/result/cloud/CloudDictionariesResult.d.ts +18 -0
- package/lib/translation/translate/result/cloud/CloudDictionariesResult.js +59 -0
- package/lib/translation/translate/result/cloud/CloudDictionariesResult.js.map +1 -0
- package/lib/translation/translate/result/cloud/CloudLanguagePairsResult.d.ts +9 -0
- package/lib/translation/translate/result/cloud/CloudLanguagePairsResult.js +29 -0
- package/lib/translation/translate/result/cloud/CloudLanguagePairsResult.js.map +1 -0
- package/lib/translation/translate/result/cloud/CloudTranslationBatchFileResult.d.ts +3 -0
- package/lib/translation/translate/result/cloud/CloudTranslationBatchFileResult.js +30 -0
- package/lib/translation/translate/result/cloud/CloudTranslationBatchFileResult.js.map +1 -0
- package/lib/translation/translate/result/cloud/CloudTranslationFileResult.d.ts +26 -0
- package/lib/translation/translate/result/cloud/CloudTranslationFileResult.js +100 -0
- package/lib/translation/translate/result/cloud/CloudTranslationFileResult.js.map +1 -0
- package/lib/translation/translate/result/cloud/CloudTranslationTextResult.d.ts +28 -0
- package/lib/translation/translate/result/cloud/CloudTranslationTextResult.js +89 -0
- package/lib/translation/translate/result/cloud/CloudTranslationTextResult.js.map +1 -0
- package/lib/translation/translate/result/edge/EdgeDictionariesResult.d.ts +18 -0
- package/lib/translation/translate/result/edge/EdgeDictionariesResult.js +59 -0
- package/lib/translation/translate/result/edge/EdgeDictionariesResult.js.map +1 -0
- package/lib/translation/translate/result/edge/EdgeLanguagePairsResult.d.ts +6 -0
- package/lib/translation/translate/result/edge/EdgeLanguagePairsResult.js +20 -0
- package/lib/translation/translate/result/edge/EdgeLanguagePairsResult.js.map +1 -0
- package/lib/translation/translate/result/edge/EdgeTranslationBatchFileResult.d.ts +3 -0
- package/lib/translation/translate/result/edge/EdgeTranslationBatchFileResult.js +30 -0
- package/lib/translation/translate/result/edge/EdgeTranslationBatchFileResult.js.map +1 -0
- package/lib/translation/translate/result/edge/EdgeTranslationFileResult.d.ts +9 -0
- package/lib/translation/translate/result/edge/EdgeTranslationFileResult.js +50 -0
- package/lib/translation/translate/result/edge/EdgeTranslationFileResult.js.map +1 -0
- package/lib/translation/translate/result/edge/EdgeTranslationTextResult.d.ts +6 -0
- package/lib/translation/translate/result/edge/EdgeTranslationTextResult.js +40 -0
- package/lib/translation/translate/result/edge/EdgeTranslationTextResult.js.map +1 -0
- package/lib/translation/translate/utils/TranslateFileUtil.d.ts +8 -0
- package/lib/translation/translate/utils/TranslateFileUtil.js +266 -0
- package/lib/translation/translate/utils/TranslateFileUtil.js.map +1 -0
- package/lib/version.d.ts +1 -0
- package/lib/version.js +5 -0
- package/lib/version.js.map +1 -0
- package/package.json +45 -0
- package/readme.md +17 -0
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
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;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
exports.getInputFilesFromBatchFileRequest = exports.getFileNameFromHeaders = exports.getOutputExtension = exports.validateOutputFileExtension = exports.validateInputDataForFileTranslation = exports.validateInputDataForBatchFileTranslation = void 0;
|
|
43
|
+
var uuid_1 = require("uuid");
|
|
44
|
+
var Utils_1 = __importDefault(require("../../../common/utils/Utils"));
|
|
45
|
+
var TranslationConstants_1 = require("../../../common/constants/TranslationConstants");
|
|
46
|
+
var validateInputDataForBatchFileTranslation = function (translateBatchFileRequest) { return __awaiter(void 0, void 0, void 0, function () {
|
|
47
|
+
return __generator(this, function (_a) {
|
|
48
|
+
switch (_a.label) {
|
|
49
|
+
case 0:
|
|
50
|
+
if (!translateBatchFileRequest.input) {
|
|
51
|
+
return [2 /*return*/, Utils_1.default.isBrowser() ? TranslationConstants_1.MISSING_REQUIRED_INPUT_FILES_ERROR : TranslationConstants_1.MISSING_REQUIRED_INPUT_DIRECTORY_ERROR];
|
|
52
|
+
}
|
|
53
|
+
if (!Utils_1.default.isBrowser()) return [3 /*break*/, 1];
|
|
54
|
+
return [2 /*return*/, validateInputFilesInBrowser(translateBatchFileRequest.input)];
|
|
55
|
+
case 1: return [4 /*yield*/, validateInputAndOutputDirectoriesInNode(translateBatchFileRequest)];
|
|
56
|
+
case 2: return [2 /*return*/, _a.sent()];
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
}); };
|
|
60
|
+
exports.validateInputDataForBatchFileTranslation = validateInputDataForBatchFileTranslation;
|
|
61
|
+
var validateInputDataForFileTranslation = function (translateFileRequest) {
|
|
62
|
+
if (!translateFileRequest.input) {
|
|
63
|
+
return TranslationConstants_1.MISSING_REQUIRED_INPUT_FILE_ERROR;
|
|
64
|
+
}
|
|
65
|
+
if (Utils_1.default.isBrowser()) {
|
|
66
|
+
return validateInputFileInBrowser(translateFileRequest.input);
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
return validateInputAndOutputFilesAndDirInNode(translateFileRequest);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
exports.validateInputDataForFileTranslation = validateInputDataForFileTranslation;
|
|
73
|
+
var isArrayOfFiles = function (array) {
|
|
74
|
+
return Array.isArray(array) && array.length > 0 && array.every(function (entry) { return entry instanceof File; });
|
|
75
|
+
};
|
|
76
|
+
var validateInputFilesInBrowser = function (input) {
|
|
77
|
+
if (input && typeof input !== 'string' && isArrayOfFiles(input)) {
|
|
78
|
+
var largeFile = input.find(function (file) { return Utils_1.default.getFileSize(file) > TranslationConstants_1.MAX_FILE_SIZE_LIMIT; });
|
|
79
|
+
return largeFile ? getFileSizeExceededError(largeFile) : null;
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
return TranslationConstants_1.REQUIRED_INPUT_FILES_OF_TYPE_OBJECT_ERROR;
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
var validateInputAndOutputDirectoriesInNode = function (translateBatchFileRequest) { return __awaiter(void 0, void 0, void 0, function () {
|
|
86
|
+
var error, outputError;
|
|
87
|
+
return __generator(this, function (_a) {
|
|
88
|
+
switch (_a.label) {
|
|
89
|
+
case 0:
|
|
90
|
+
if (!(typeof translateBatchFileRequest.input === 'string')) return [3 /*break*/, 2];
|
|
91
|
+
return [4 /*yield*/, validateInputDirectoryForNode(translateBatchFileRequest.input)];
|
|
92
|
+
case 1:
|
|
93
|
+
error = _a.sent();
|
|
94
|
+
if (error) {
|
|
95
|
+
return [2 /*return*/, error];
|
|
96
|
+
}
|
|
97
|
+
return [3 /*break*/, 3];
|
|
98
|
+
case 2: return [2 /*return*/, TranslationConstants_1.REQUIRED_INPUT_DIRECTORY_OF_TYPE_STRING_ERROR];
|
|
99
|
+
case 3:
|
|
100
|
+
outputError = validateOutputDirectory(translateBatchFileRequest.outputDir || '');
|
|
101
|
+
if (outputError) {
|
|
102
|
+
return [2 /*return*/, outputError];
|
|
103
|
+
}
|
|
104
|
+
return [2 /*return*/];
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
}); };
|
|
108
|
+
var validateInputDirectoryForNode = function (input) { return __awaiter(void 0, void 0, void 0, function () {
|
|
109
|
+
var inputDirValidationError, fs, path, absolutePath, files, largeFile, e_1;
|
|
110
|
+
return __generator(this, function (_a) {
|
|
111
|
+
switch (_a.label) {
|
|
112
|
+
case 0:
|
|
113
|
+
inputDirValidationError = Utils_1.default.validateDirectoryPath(input);
|
|
114
|
+
if (inputDirValidationError) {
|
|
115
|
+
return [2 /*return*/, inputDirValidationError];
|
|
116
|
+
}
|
|
117
|
+
fs = require('fs');
|
|
118
|
+
path = require('path');
|
|
119
|
+
absolutePath = Utils_1.default.getAbsolutePath(input);
|
|
120
|
+
_a.label = 1;
|
|
121
|
+
case 1:
|
|
122
|
+
_a.trys.push([1, 3, , 4]);
|
|
123
|
+
return [4 /*yield*/, fs.promises.readdir(absolutePath)];
|
|
124
|
+
case 2:
|
|
125
|
+
files = _a.sent();
|
|
126
|
+
if (!files || !files.length) {
|
|
127
|
+
return [2 /*return*/, TranslationConstants_1.MISSING_REQUIRED_INPUT_FILES_ERROR];
|
|
128
|
+
}
|
|
129
|
+
largeFile = files.find(function (file) { return Utils_1.default.getFileSize(path.join(absolutePath, file)) > TranslationConstants_1.MAX_FILE_SIZE_LIMIT; });
|
|
130
|
+
return [2 /*return*/, largeFile ? getFileSizeExceededError(largeFile) : null];
|
|
131
|
+
case 3:
|
|
132
|
+
e_1 = _a.sent();
|
|
133
|
+
return [2 /*return*/, TranslationConstants_1.READ_FILES_FROM_DIRECTORY_FAILED_ERROR];
|
|
134
|
+
case 4: return [2 /*return*/];
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
}); };
|
|
138
|
+
var validateInputFileInBrowser = function (inputFile) {
|
|
139
|
+
if (inputFile instanceof File) {
|
|
140
|
+
var fileSize = Utils_1.default.getFileSize(inputFile);
|
|
141
|
+
return fileSize > TranslationConstants_1.MAX_FILE_SIZE_LIMIT ? getFileSizeExceededError(inputFile) : null;
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
return TranslationConstants_1.REQUIRED_INPUT_FILE_OF_TYPE_OBJECT_ERROR;
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
var validateInputAndOutputFilesAndDirInNode = function (translateFileRequest) {
|
|
148
|
+
if (typeof translateFileRequest.input === 'string') {
|
|
149
|
+
var inputError = validateInputFileInNode(translateFileRequest.input);
|
|
150
|
+
if (inputError) {
|
|
151
|
+
return inputError;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
return TranslationConstants_1.REQUIRED_INPUT_FILE_OF_TYPE_STRING_ERROR;
|
|
156
|
+
}
|
|
157
|
+
var outputDirError = validateOutputDirectory(translateFileRequest.outputDir || '');
|
|
158
|
+
if (outputDirError) {
|
|
159
|
+
return outputDirError;
|
|
160
|
+
}
|
|
161
|
+
var outputFileError = validateOutputFile(translateFileRequest);
|
|
162
|
+
if (outputFileError) {
|
|
163
|
+
return outputFileError;
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
var validateInputFileInNode = function (inputFile) {
|
|
167
|
+
var inputFileValidationError = Utils_1.default.validateFilePath(inputFile);
|
|
168
|
+
if (inputFileValidationError) {
|
|
169
|
+
return inputFileValidationError;
|
|
170
|
+
}
|
|
171
|
+
var fileSize = Utils_1.default.getFileSize(inputFile);
|
|
172
|
+
if (fileSize > TranslationConstants_1.MAX_FILE_SIZE_LIMIT) {
|
|
173
|
+
return getFileSizeExceededError(inputFile);
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
var validateOutputDirectory = function (outputBatch) {
|
|
177
|
+
if (outputBatch) {
|
|
178
|
+
return Utils_1.default.validateDirectoryPath(outputBatch);
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
return TranslationConstants_1.MISSING_REQUIRED_OUTPUT_DIRECTORY_ERROR;
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
var validateOutputFileExtension = function (translateFileRequest) {
|
|
185
|
+
if (translateFileRequest.input) {
|
|
186
|
+
var inputExtension = Utils_1.default.getExtension(translateFileRequest.input);
|
|
187
|
+
var requiredOutputExtension = (0, exports.getOutputExtension)(inputExtension);
|
|
188
|
+
var actualOutputExtension = Utils_1.default.getExtension(translateFileRequest.outputFile || '');
|
|
189
|
+
return requiredOutputExtension !== actualOutputExtension
|
|
190
|
+
? "Invalid output extension ".concat(actualOutputExtension, " for input extension ").concat(inputExtension, ". Valid output extension: ").concat(requiredOutputExtension, ".")
|
|
191
|
+
: '';
|
|
192
|
+
}
|
|
193
|
+
else {
|
|
194
|
+
return TranslationConstants_1.MISSING_REQUIRED_INPUT_FILE_ERROR;
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
exports.validateOutputFileExtension = validateOutputFileExtension;
|
|
198
|
+
var validateOutputFile = function (translateFileRequest) {
|
|
199
|
+
if (translateFileRequest.outputFile) {
|
|
200
|
+
return (0, exports.validateOutputFileExtension)(translateFileRequest);
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
var getOutputExtension = function (inputExtension) {
|
|
204
|
+
var extension = Object.keys(extensionsMap).find(function (ext) { return ext === inputExtension.toUpperCase(); });
|
|
205
|
+
return extension ? extensionsMap[extension] : inputExtension;
|
|
206
|
+
};
|
|
207
|
+
exports.getOutputExtension = getOutputExtension;
|
|
208
|
+
var getFileNameFromHeaders = function (response, request) {
|
|
209
|
+
var contentDispositionKey = response &&
|
|
210
|
+
response.headers &&
|
|
211
|
+
Object.keys(response.headers).find(function (headerName) { return headerName.toLowerCase() === 'content-disposition'; });
|
|
212
|
+
if (contentDispositionKey) {
|
|
213
|
+
var contentDispositionHeader = response.headers[contentDispositionKey];
|
|
214
|
+
return contentDispositionHeader.split('filename=')[1].split(';')[0].replace(/[",']/g, '');
|
|
215
|
+
}
|
|
216
|
+
else {
|
|
217
|
+
var fileBasename = Utils_1.default.getFileBasename(request.input || '');
|
|
218
|
+
var fileExtension = Utils_1.default.getExtension(request.input || '');
|
|
219
|
+
return fileBasename + '-' + (0, uuid_1.v4)() + '.' + (0, exports.getOutputExtension)(fileExtension);
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
exports.getFileNameFromHeaders = getFileNameFromHeaders;
|
|
223
|
+
var getInputFilesFromBatchFileRequest = function (request) { return __awaiter(void 0, void 0, void 0, function () {
|
|
224
|
+
var files, fs;
|
|
225
|
+
return __generator(this, function (_a) {
|
|
226
|
+
switch (_a.label) {
|
|
227
|
+
case 0:
|
|
228
|
+
if (!Utils_1.default.isBrowser()) return [3 /*break*/, 1];
|
|
229
|
+
files = request.input;
|
|
230
|
+
return [3 /*break*/, 3];
|
|
231
|
+
case 1:
|
|
232
|
+
if (!(typeof request.input === 'string')) return [3 /*break*/, 3];
|
|
233
|
+
fs = require('fs');
|
|
234
|
+
return [4 /*yield*/, fs.promises.readdir(request.input)];
|
|
235
|
+
case 2:
|
|
236
|
+
files = _a.sent();
|
|
237
|
+
files = files.map(function (filename) {
|
|
238
|
+
// @ts-ignore input is string here
|
|
239
|
+
return Utils_1.default.getFullPath(request.input, filename);
|
|
240
|
+
});
|
|
241
|
+
_a.label = 3;
|
|
242
|
+
case 3: return [2 /*return*/, files];
|
|
243
|
+
}
|
|
244
|
+
});
|
|
245
|
+
}); };
|
|
246
|
+
exports.getInputFilesFromBatchFileRequest = getInputFilesFromBatchFileRequest;
|
|
247
|
+
var getFileSizeExceededError = function (inputFile) {
|
|
248
|
+
return "Input file ".concat(Utils_1.default.getFilename(inputFile), " exceeds maximum permitted size of ").concat(TranslationConstants_1.MAX_FILE_SIZE_LIMIT, " bytes");
|
|
249
|
+
};
|
|
250
|
+
/*
|
|
251
|
+
Some types of files have a different output file extension.
|
|
252
|
+
Mapping of input files with special extensions:
|
|
253
|
+
- key: input file extension
|
|
254
|
+
- value: output file extension
|
|
255
|
+
*/
|
|
256
|
+
var extensionsMap = {
|
|
257
|
+
PDF: 'docx',
|
|
258
|
+
GIF: 'txt',
|
|
259
|
+
JPG: 'txt',
|
|
260
|
+
JPEG: 'txt',
|
|
261
|
+
PNG: 'txt',
|
|
262
|
+
EML: 'txt',
|
|
263
|
+
MSG: 'txt',
|
|
264
|
+
UNK: '',
|
|
265
|
+
};
|
|
266
|
+
//# sourceMappingURL=TranslateFileUtil.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TranslateFileUtil.js","sourceRoot":"","sources":["../../../../src/translation/translate/utils/TranslateFileUtil.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6BAAoC;AAGpC,sEAAgD;AAChD,uFAWwD;AAGjD,IAAM,wCAAwC,GAAG,UACpD,yBAAoD;;;;gBAEpD,IAAI,CAAC,yBAAyB,CAAC,KAAK,EAAE;oBAClC,sBAAO,eAAK,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,yDAAkC,CAAC,CAAC,CAAC,6DAAsC,EAAC;iBAC1G;qBAEG,eAAK,CAAC,SAAS,EAAE,EAAjB,wBAAiB;gBACjB,sBAAO,2BAA2B,CAAC,yBAAyB,CAAC,KAAK,CAAC,EAAC;oBAE7D,qBAAM,uCAAuC,CAAC,yBAAyB,CAAC,EAAA;oBAA/E,sBAAO,SAAwE,EAAC;;;KAEvF,CAAC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,OAAO,CAAC,KAAK,EAAE,QAAQ,CAAC;gBAA1C,CAA0C,CAC7C,CAAC;;oBAGN,sBAAO,KAAK,EAAC;;;KAChB,CAAC;AAjBW,QAAA,iCAAiC,qCAiB5C;AAEF,IAAM,wBAAwB,GAAG,UAAC,SAAwB;IACtD,OAAO,qBAAc,eAAK,CAAC,WAAW,CAAC,SAAS,CAAC,gDAAsC,0CAAmB,WAAQ,CAAC;AACvH,CAAC,CAAC;AAEF;;;;;GAKG;AACH,IAAM,aAAa,GAA2B;IAC1C,GAAG,EAAE,MAAM;IACX,GAAG,EAAE,KAAK;IACV,GAAG,EAAE,KAAK;IACV,IAAI,EAAE,KAAK;IACX,GAAG,EAAE,KAAK;IACV,GAAG,EAAE,KAAK;IACV,GAAG,EAAE,KAAK;IACV,GAAG,EAAE,EAAE;CACV,CAAC"}
|
package/lib/version.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const VERSION = "1.0.0";
|
package/lib/version.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":";;;AAAa,QAAA,OAAO,GAAG,OAAO,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@language-weaver/lw-sdk-js",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "lib/index.js",
|
|
6
|
+
"types": "lib/index.d.ts",
|
|
7
|
+
"license": "Apache-2.0",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"prebuild": "node -p \"'export const VERSION = ' + JSON.stringify(require('./package.json').version) + ';'\" > src/version.ts",
|
|
10
|
+
"test": "jest --config jest.config.js --runInBand --coverage",
|
|
11
|
+
"build": "tsc",
|
|
12
|
+
"format": "prettier --write \"src/**/*.ts\"",
|
|
13
|
+
"lint": "tslint -p tsconfig.json",
|
|
14
|
+
"prepare": "npm run build",
|
|
15
|
+
"prepublishOnly": "npm test && npm run lint",
|
|
16
|
+
"preversion": "npm run lint",
|
|
17
|
+
"version": "npm run format && npm run prebuild"
|
|
18
|
+
},
|
|
19
|
+
"author": "",
|
|
20
|
+
"browser": {
|
|
21
|
+
"fs": false,
|
|
22
|
+
"path": false
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"axios": "^0.27.2",
|
|
26
|
+
"fs": "^0.0.1-security",
|
|
27
|
+
"jwt-decode": "^3.1.2",
|
|
28
|
+
"uuid": "^8.3.2"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@types/jest": "^28.1.4",
|
|
32
|
+
"@types/uuid": "^8.3.4",
|
|
33
|
+
"dotenv": "^16.0.2",
|
|
34
|
+
"form-data": "^4.0.0",
|
|
35
|
+
"jest": "^28.1.2",
|
|
36
|
+
"jest-environment-jsdom": "^28.1.3",
|
|
37
|
+
"prettier": "^2.7.1",
|
|
38
|
+
"ts-jest": "^28.0.5",
|
|
39
|
+
"tslint": "^6.1.3",
|
|
40
|
+
"tslint-config-prettier": "^1.18.0",
|
|
41
|
+
"typescript": "^4.7.4",
|
|
42
|
+
"webpack": "^5.73.0",
|
|
43
|
+
"webpack-cli": "^4.10.0"
|
|
44
|
+
}
|
|
45
|
+
}
|
package/readme.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# lw-sdk-js
|
|
2
|
+
## Getting started
|
|
3
|
+
### Installation:
|
|
4
|
+
```
|
|
5
|
+
npm install lw-sdk-js
|
|
6
|
+
```
|
|
7
|
+
### Usage:
|
|
8
|
+
```
|
|
9
|
+
import SdkFactory from 'lw-sdk-js'; // ES6
|
|
10
|
+
const SdkFactory = require('lw-sdk-js'); // ES5
|
|
11
|
+
```
|
|
12
|
+
## Getting help
|
|
13
|
+
Please make sure to check out our resources:
|
|
14
|
+
- [Developer Guide](https://developers.languageweaver.com/developer-tools/sdk/index.html)
|
|
15
|
+
- [Code Examples](https://github.com/RWS/languageweaver-sdk-samples)
|
|
16
|
+
## License
|
|
17
|
+
This SDK is distributed under the [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0).
|