UNPKG

@crowdin/crowdin-api-client

Version:
203 lines (202 loc) 8.07 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.TranslationMemory = void 0; const core_1 = require("../core"); /** * Translation Memory (TM) is a vault of translations that were previously made in other projects. * Those translations can be reused to speed up the translation process. * Every translation made in the project is automatically added to the project Translation Memory. * * Use API to create, upload, download, or remove specific TM. * Translation Memory export and import are asynchronous operations and shall be completed with sequence of API methods. */ class TranslationMemory extends core_1.CrowdinApi { listTm(options, deprecatedLimit, deprecatedOffset) { if ((0, core_1.isOptionalNumber)(options, '0' in arguments)) { options = { groupId: options, limit: deprecatedLimit, offset: deprecatedOffset }; } let url = `${this.url}/tms`; url = this.addQueryParam(url, 'groupId', options.groupId); url = this.addQueryParam(url, 'userId', options.userId); url = this.addQueryParam(url, 'orderBy', options.orderBy); return this.getList(url, options.limit, options.offset); } /** * @param request request body * @see https://developer.crowdin.com/api/v2/#operation/api.tms.post */ addTm(request) { const url = `${this.url}/tms`; return this.post(url, request, this.defaultConfig()); } /** * @param tmId tm identifier * @see https://developer.crowdin.com/api/v2/#operation/api.tms.get */ getTm(tmId) { const url = `${this.url}/tms/${tmId}`; return this.get(url, this.defaultConfig()); } /** * @param tmId tm identifier * @see https://developer.crowdin.com/api/v2/#operation/api.tms.delete */ deleteTm(tmId) { const url = `${this.url}/tms/${tmId}`; return this.delete(url, this.defaultConfig()); } /** * @param tmId tm identifier * @param request request body * @see https://developer.crowdin.com/api/v2/#operation/api.tms.patch */ editTm(tmId, request) { const url = `${this.url}/tms/${tmId}`; return this.patch(url, request, this.defaultConfig()); } /** * @param tmId tm identifier * @param options optional paramerers for the request * @see https://developer.crowdin.com/api/v2/#operation/api.tms.segments.getMany */ listTmSegments(tmId, options) { let url = `${this.url}/tms/${tmId}/segments`; url = this.addQueryParam(url, 'croql', options === null || options === void 0 ? void 0 : options.croql); url = this.addQueryParam(url, 'orderBy', options === null || options === void 0 ? void 0 : options.orderBy); return this.getList(url, options === null || options === void 0 ? void 0 : options.limit, options === null || options === void 0 ? void 0 : options.offset); } /** * @param tmId tm identifier * @param request request body * @see https://developer.crowdin.com/api/v2/#operation/api.tms.segments.post */ addTmSegment(tmId, request) { const url = `${this.url}/tms/${tmId}/segments`; return this.post(url, request, this.defaultConfig()); } /** * @param tmId tm identifier * @see https://developer.crowdin.com/api/v2/#operation/api.tms.segments.clear */ clearTm(tmId) { const url = `${this.url}/tms/${tmId}/segments`; return this.delete(url, this.defaultConfig()); } /** * @param tmId tm identifier * @param request request body * @see https://developer.crowdin.com/api/v2/#operation/api.tms.exports.post */ exportTm(tmId, request = {}) { const url = `${this.url}/tms/${tmId}/exports`; return this.post(url, request, this.defaultConfig()); } /** * @param tmId tm identifier * @param exportId export identifier * @see https://developer.crowdin.com/api/v2/#operation/api.tms.exports.get */ checkExportStatus(tmId, exportId) { const url = `${this.url}/tms/${tmId}/exports/${exportId}`; return this.get(url, this.defaultConfig()); } /** * @param tmId tm identifier * @param exportId export identifier * @see https://developer.crowdin.com/api/v2/#operation/api.tms.exports.download.download */ downloadTm(tmId, exportId) { const url = `${this.url}/tms/${tmId}/exports/${exportId}/download`; return this.get(url, this.defaultConfig()); } /** * @param projectId project identifier * @param request request body * @see https://developer.crowdin.com/api/v2/#operation/api.projects.tms.concordance.post */ concordanceSearch(projectId, request) { const url = `${this.url}/projects/${projectId}/tms/concordance`; return this.post(url, request, this.defaultConfig()); } /** * @param tmId tm identifier * @param request request body * @see https://developer.crowdin.com/api/v2/#operation/api.tms.imports.post */ importTm(tmId, request) { const url = `${this.url}/tms/${tmId}/imports`; return this.post(url, request, this.defaultConfig()); } /** * @param tmId tm identifier * @param importId import identifier * @see https://developer.crowdin.com/api/v2/#operation/api.tms.imports.get */ checkImportStatus(tmId, importId) { const url = `${this.url}/tms/${tmId}/imports/${importId}`; return this.get(url, this.defaultConfig()); } /** * @param tmId tm identifier * @param segmentId segment identifier * @see https://developer.crowdin.com/api/v2/#operation/api.tms.segments.get */ getTmSegment(tmId, segmentId) { const url = `${this.url}/tms/${tmId}/segments/${segmentId}`; return this.get(url, this.defaultConfig()); } /** * @param tmId tm identifier * @param segmentId segment identifier * @see https://developer.crowdin.com/api/v2/#operation/api.tms.segments.delete */ deleteTmSegment(tmId, segmentId) { const url = `${this.url}/tms/${tmId}/segments/${segmentId}`; return this.delete(url, this.defaultConfig()); } /** * @param tmId tm identifier * @param segmentId segment identifier * @param request request body * @see https://developer.crowdin.com/api/v2/#operation/api.tms.segments.patch */ editTmSegment(tmId, segmentId, request) { const url = `${this.url}/tms/${tmId}/segments/${segmentId}`; return this.patch(url, request, this.defaultConfig()); } /** * @deprecated * @param tmId tm identifier * @param segmentId segment identifier * @param recordId record identifier * @see https://developer.crowdin.com/api/v2/#operation/api.tms.segments.records.delete */ deleteTmSegmentRecord(tmId, segmentId, recordId) { const url = `${this.url}/tms/${tmId}/segments/${segmentId}/records/${recordId}`; return this.delete(url, this.defaultConfig()); } /** * @deprecated * @param tmId tm identifier * @param segmentId segment identifier * @param recordId record identifier * @param request request body * @see https://developer.crowdin.com/api/v2/#operation/api.tms.segments.records.patch */ editTmSegmentRecord(tmId, segmentId, recordId, request) { const url = `${this.url}/tms/${tmId}/segments/${segmentId}/records/${recordId}`; return this.patch(url, request, this.defaultConfig()); } /** * @deprecated * @param tmId tm identifier * @param segmentId segment identifier * @param request request body * @see https://developer.crowdin.com/api/v2/#operation/api.tms.segments.records.post */ addTmSegmentRecords(tmId, segmentId, request) { const url = `${this.url}/tms/${tmId}/segments/${segmentId}/records`; return this.post(url, request, this.defaultConfig()); } } exports.TranslationMemory = TranslationMemory;