UNPKG

language-cloud-js-sdk

Version:

Language Cloud javascript sdk

862 lines (834 loc) 76.2 kB
var __defProp = Object.defineProperty; var __defProps = Object.defineProperties; var __getOwnPropDescs = Object.getOwnPropertyDescriptors; var __getOwnPropSymbols = Object.getOwnPropertySymbols; var __hasOwnProp = Object.prototype.hasOwnProperty; var __propIsEnum = Object.prototype.propertyIsEnumerable; var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; var __spreadValues = (a, b) => { for (var prop in b || (b = {})) if (__hasOwnProp.call(b, prop)) __defNormalProp(a, prop, b[prop]); if (__getOwnPropSymbols) for (var prop of __getOwnPropSymbols(b)) { if (__propIsEnum.call(b, prop)) __defNormalProp(a, prop, b[prop]); } return a; }; var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b)); var __async = (__this, __arguments, generator) => { return new Promise((resolve, reject) => { var fulfilled = (value) => { try { step(generator.next(value)); } catch (e) { reject(e); } }; var rejected = (value) => { try { step(generator.throw(value)); } catch (e) { reject(e); } }; var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected); step((generator = generator.apply(__this, __arguments)).next()); }); }; // src/core/lcClient.ts import axios2 from "axios"; // src/services/customFieldDefinitionsService.ts var CustomFieldDefinitionsService = class { constructor(client) { /** Retrieves a list of all the custom field definitions. */ this.getCustomFieldDefinitions = (params) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.get("custom-field-definitions", { params })).data; }); /** Retrieves a Custom Field by identifier. */ this.getCustomFieldDefinition = (customFieldDefinitionId, params) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.get(`custom-field-definitions/${customFieldDefinitionId}`, { params })).data; }); this.client = client; } }; // src/services/languageService.ts var LanguageService = class { constructor(client) { /** Retrieves a list of all the languages. * * The supported values for language `type` filter are: "all", "specific" or "neutral". * The "neutral" languages are the generic languages, e.g.: en -> English. * * The "specific" languages are the sub-languages, e.g.: en-150 -> English (Europe), en-us -> English (United States). */ this.getLanguages = (..._0) => __async(this, [..._0], function* (params = {}) { return (yield this.client.lcServiceInstance.get("languages", { params })).data; }); this.client = client; } }; // src/services/projectService.ts var ProjectService = class { constructor(client) { /** Retrieves a list of all the projects in the account. */ this.getProjects = (params) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.get("projects", { params })).data; }); /** Retrieves a project by identifier. */ this.getProject = (projectId, params) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.get(`projects/${projectId}`, { params })).data; }); /** Deletes a project. */ this.deleteProject = (projectId) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.delete(`projects/${projectId}`)).data; }); /** Creates a new project. * * When creating a project using a project template that supports multiple source languages, you must supply the `languageDirections`. * * Consider the {@link https://docs.rws.com/791595/815967/trados-enterprise---accelerate/file-and-project-size-limit | file and project size limit} when creating projects. * * The values from a selected project template will take precedence over the individual resources when creating a new project. */ this.createProject = (payload, params) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.post("projects", payload, { params })).data; }); /** Starts a project. Translatable files should be uploaded before starting the project. If the action is executed on an already started project, the new translatable files should be uploaded first. */ this.startProject = (projectId) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.put(`projects/${projectId}/start`, {})).data; }); /** Marks a project as "completed". */ this.completeProject = (projectId) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.put(`projects/${projectId}/complete`, {})).data; }); /** Updates the project in terms of: name, description, due date, quote, and project resources. * Observe the rules of {@link https://datatracker.ietf.org/doc/html/rfc7386 | JSON Merge Patch Semantics}. * * Project rescheduling (updating dueBy) is permitted only if: * - there is no Customer Quote Approval task in the associated flow * - at least one Customer Quote Approval was closed(in case multiple project batches) * * Update `projectPlan.taskConfigurations` are now permitted before project is started. Elements are now pre-populated at project creation time. */ this.updateProject = (projectId, payload) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.put(`projects/${projectId}`, payload)).data; }); /** Lists the tasks of a specific project. */ this.getProjectTasks = (projectId, params) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.get(`projects/${projectId}/tasks`, { params })).data; }); /** Allows updating individual custom fields on a project. */ this.updateCustomField = (projectId, customFieldKey, payload) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.put(`projects/${projectId}/custom-fields/${customFieldKey}`, payload)).data; }); /** Get the configuration settings of an existing project. */ this.getProjectConfiguration = (projectId, params) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.get(`projects/${projectId}/configuration`, { params })).data; }); /** Updates the configuration settings for an existing project. */ this.updateProjectConfiguration = (projectId, payload) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.put(`projects/${projectId}/configuration`, payload)).data; }); /** Update project pricing model only during Customer Quote Review task type. */ this.updateProjectPricingModel = (projectId, payload) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.put(`projects/${projectId}/pricing-model`, payload)).data; }); /** Cancels a project file. */ this.cancelProjectFile = (projectId, fileId) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.put(`projects/${projectId}/files/${fileId}/cancel`, {})).data; }); this.client = client; } }; // src/services/projectTemplateService.ts var ProjectTemplateService = class { constructor(client) { /** Retrieves a project template by identifier. */ this.getProjectTemplate = (projectTemplateId, params) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.get(`project-templates/${projectTemplateId}`, { params })).data; }); /** Retrieves a list of all the project templates in an account. */ this.getProjectTemplates = (params) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.get(`project-templates`, { params })).data; }); /** Deletes a project template by id. */ this.deleteProjectTemplate = (projectTemplateId) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.delete(`project-templates/${projectTemplateId}`)).data; }); /** Creates a new project template. */ this.createProjectTemplate = (payload, params) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.post(`project-templates`, payload, { params })).data; }); /** Updates a project template by id. */ this.updateProjectTemplate = (projectTemplateId, payload) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.put(`project-templates/${projectTemplateId}`, payload)).data; }); this.client = client; } }; // src/utils/constants.ts var AUTH_URL = "https://sdl-prod.eu.auth0.com/oauth/token"; var PROJECT_SERVICE_BASE_URL = "https://lc-api.sdl.com/public-api/v1/"; var GRANT_TYPE = "client_credentials"; var AUDIENCE = "https://api.sdl.com"; var X_LC_CALLER_APP = "LC_SDK/v1.0.7"; var PUBLIC_API_URL = "https://api.cloud.trados.com/public-api/v1/"; var AppMessages = { CREDENTIALS_MISSING: "credentials missing", TOKEN_NOT_FOUND: "token not found", INPUT_MISSING: "Input contains null or undefined values.", INVALID_INPUT: "Invalid input: Expected a non-null object as input." }; // src/services/sourceFileService.ts var SourceFileService = class { constructor(client) { /** Retrieves the source files in a project. */ this.getSourceFiles = (projectId, params) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.get(`projects/${projectId}/source-files`, { params })).data; }); /** Retrieves a source file from the project. */ this.getSourceFile = (projectId, sourceFileId, params) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.get(`projects/${projectId}/source-files/${sourceFileId}`, { params })).data; }); /** * Adds a source file to the project. Files can be uploaded before starting a project or after the project has started. When adding a `translatable` file after the project started, a new start project request should be performed. * * Consider the {@link https://docs.rws.com/791595/815967/trados-enterprise---accelerate/file-and-project-size-limit | file and project size limit} when uploading files. * * `Note:` The maximum character size of the sum between the `name` and the `path` fields must not exceed 255. Otherwise the request cannot be validated. */ // TODO: Need to check how can we set the SourceFileAddRequestPayload interface to FormData this.addSourceFile = (projectId, payload) => __async(this, null, function* () { const headers = __spreadValues({}, this.client.getHeaders()); headers["Content-Type"] = "multipart/form-data"; return (yield this.client.lcServiceInstance.post(`projects/${projectId}/source-files`, payload, { headers })).data; }); /** * Adds multiple source files to the project. Files must be uploaded before attaching them to a project. When a file is attached after the project was started, a new start project request should be performed. * * `Note:` The maximum character size of the sum between the `name` and the `path` fields must not exceed 255. Otherwise the request cannot be validated. */ this.attachSourceFiles = (projectId, payload, params) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.post(`projects/${projectId}/source-files/attach-files`, payload, { params })).data; }); /** Updates multiple source files. If any of the files fails to be updated, an error will be returned for each file. */ this.updateSourceFiles = (projectId, payload) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.put(`projects/${projectId}/source-files`, payload)).data; }); /** Updates a source file. */ this.updateSourceFile = (projectId, sourceFileId, payload) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.put(`projects/${projectId}/source-files/${sourceFileId}`, payload)).data; }); /** Retrieves all the versions of a source file. */ this.listSourceFileVersions = (projectId, sourceFileId, params) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.get(`projects/${projectId}/source-files/${sourceFileId}/versions`, { params })).data; }); /** Downloads a source file version. */ this.downloadSourceFileVersion = (projectId, sourceFileId, fileVersionId, config) => __async(this, null, function* () { const endpoint = `projects/${projectId}/source-files/${sourceFileId}/versions/${fileVersionId}/download`; return (yield this.client.lcServiceInstance.get(endpoint, __spreadValues({}, config))).data; }); /** Retrieves the properties for a source file. */ this.getSourceFileProperties = (taskId, sourceFileId) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.get(`tasks/${taskId}/source-files/${sourceFileId}`)).data; }); /** Updates the properties of the source file. */ this.updateSourceFileProperties = (taskId, sourceFileId, payload) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.put(`tasks/${taskId}/source-files/${sourceFileId}`, payload)).data; }); this.client = client; } }; // src/services/targetFileService.ts var TargetFileService = class { constructor(client) { /** Retrieves the target files for a project. */ this.getTargetFiles = (projectId, params) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.get(`projects/${projectId}/target-files`, { params })).data; }); /** Retrieves a target file from a project. */ this.getTargetFile = (projectId, targetFileId, params) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.get(`projects/${projectId}/target-files/${targetFileId}`, { params })).data; }); this.getTargetFileVersion = (projectId, targetFileId, fileVersionId, params) => __async(this, null, function* () { const endpoint = `projects/${projectId}/target-files/${targetFileId}/versions/${fileVersionId}`; return (yield this.client.lcServiceInstance.get(endpoint, { params })).data; }); /** Updates a target file. */ this.updateTargetFile = (projectId, targetFileId, payload) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.put(`projects/${projectId}/target-files/${targetFileId}`, payload)).data; }); /** Updates multiple target files. If any of the files fails to be updated, an error will be returned for each file. */ this.updateTargetFiles = (projectId, payload) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.put(`projects/${projectId}/target-files`, payload)).data; }); /** Retrieves the versions of a target file. */ this.getTargetFileVersions = (projectId, targetFileId, params) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.get(`projects/${projectId}/target-files/${targetFileId}/versions`, { params })).data; }); /** * Generates an asynchronous export operation. Use the {@link https://eu.cloud.trados.com/lc/api-docs/77e028c970065-poll-target-file-version-export | Get Target File Version Export} endpoint to poll until the export is completed. Used only for {@link https://developers.rws.com/languagecloud-api-docs/articles/BCM.NET_client_API.html | BCM} file versions. * * This operation triggers a conversion of the BCM target file version in a native or SDLXLIFF format, based on the value of the `format` query parameter used. * * Consider the {@link https://docs.rws.com/en-US/trados-enterprise---accelerate-791595/file-and-project-size-limit-815967 | file and project size limit} when uploading files. */ this.exportTargetFileVersion = (projectId, targetFileId, fileVersionId, params) => __async(this, null, function* () { const endpoint = `projects/${projectId}/target-files/${targetFileId}/versions/${fileVersionId}/exports`; return (yield this.client.lcServiceInstance.post(endpoint, null, { params })).data; }); /** * Polls a target file version via an export operation. The new version can be downloaded once the status is "completed". */ this.pollTargetFileVersionExport = (projectId, targetFileId, fileVersionId, exportId) => __async(this, null, function* () { const endpoint = `projects/${projectId}/target-files/${targetFileId}/versions/${fileVersionId}/exports/${exportId}`; return (yield this.client.lcServiceInstance.get(endpoint)).data; }); /** * Downloads a completed target file version via an export operation. */ this.downloadExportedTargetFileVersion = (projectId, targetFileId, fileVersionId, exportId) => __async(this, null, function* () { const endpoint = `projects/${projectId}/target-files/${targetFileId}/versions/${fileVersionId}/exports/${exportId}/download`; return (yield this.client.lcServiceInstance.get(endpoint)).data; }); /** * Downloads the file version (native or BCM). * * If the `fileVersionId` path parameter represents a native file version, the native file will be downloaded. If the `fileVersionId` is an identifier of a version in {@link https://developers.rws.com/languagecloud-api-docs/articles/BCM.NET_client_API.html | BCM format}, the BCM file will be downloaded. */ this.downloadTargetFileVersion = (projectId, targetFileId, fileVersionId, config) => __async(this, null, function* () { const endpoint = `projects/${projectId}/target-files/${targetFileId}/versions/${fileVersionId}/download`; return (yield this.client.lcServiceInstance.get(endpoint, __spreadValues({}, config))).data; }); /** * Generates an asynchronous import operation. Use {@link https://eu.cloud.trados.com/lc/api-docs/0aa2d4b06ffa2-poll-target-file-version-import | Poll Target File Version Import endpoint} to poll until the import is completed. Only `sdlxliff` files can be imported. * * Import should be used when a file is downloaded as an `sdlxliff`, processed and then, replaced. The import operation triggers internally the update of the {@link https://developers.rws.com/languagecloud-api-docs/articles/BCM.NET_client_API.html | BCM} file associated with the imported file. It should mostly be used for offline work. * * Consider the {@link https://docs.rws.com/en-US/trados-enterprise---accelerate-791595/file-and-project-size-limit-815967 | file and project size limit} when uploading files. */ // TODO: Need to check how can we set the interface to FormData this.importTargetFileVersion = (projectId, targetFileId, payload) => __async(this, null, function* () { const endpoint = `projects/${projectId}/target-files/${targetFileId}/versions/imports`; const headers = __spreadValues({}, this.client.getHeaders()); headers["Content-Type"] = "multipart/form-data"; return (yield this.client.lcServiceInstance.post(endpoint, payload, { headers })).data; }); /** * Polls a target file version via an import operation. The new version can be seen on the file versions once the status is "completed". */ this.pollTargetFileVersionImport = (projectId, targetFileId, importId) => __async(this, null, function* () { const endpoint = `projects/${projectId}/target-files/${targetFileId}/versions/imports/${importId}`; return (yield this.client.lcServiceInstance.get(endpoint)).data; }); /** * Adds a new version of the target file. Only the `native` and `bcm` file formats are accepted. For the `sdlxliff` files, you should use the {@link https://eu.cloud.trados.com/lc/api-docs/7bf672dff71ae-import-target-file-version | Import Target File endpoint }. More information about file formats can be found on the {@link https://eu.cloud.trados.com/lc/api-docs/file-formats | File formats } page. Additional details on BCM files can be found {@link https://developers.rws.com/languagecloud-api-docs/articles/BCM.NET_client_API.html | here}. * * The version is added on the task represented by `taskId`. To be able to execute the add operation the task should be assigned and accepted by user. If the task is automatic, it is possible to add a target file version only if the status is `inProgress`. * * The added file versions need to respect the output file type declared by the task type of the enclosing task. On the {@link https://docs.rws.com/791595/885137/trados-enterprise/rules-for-sequencing-tasks-correctly | Rules for sequencing tasks correctly } page from the official RWS Documentation Center, you can find out what output file type is supported by each task. * * For adding a target file version using an extension task, the configuration of the task type must declare the `scope`'s value as "file". * * The multipart parameters in the body should respect and strictly follow the order specified in our documentation. * * Consider the {@link https://docs.rws.com/en-US/trados-enterprise---accelerate-791595/file-and-project-size-limit-815967 | file and project size limit } when uploading files. */ // TODO: Need to check how can we set the interface to FormData this.addTargetFileVersion = (taskId, targetFileId, payload, params) => __async(this, null, function* () { const endpoint = `tasks/${taskId}/target-files/${targetFileId}/versions`; return (yield this.client.lcServiceInstance.post(endpoint, payload, { params })).data; }); this.client = client; } }; // src/services/accountService.ts var AccountService = class { constructor(client) { /** Retrieves a list of all accounts accessible to the authenticated user. */ this.getAccounts = () => __async(this, null, function* () { return (yield this.client.lcServiceInstance.get("accounts")).data; }); this.client = client; } }; // src/services/userService.ts var UserService = class { constructor(client) { /** Retrieves the authenticated user. */ this.getMyUser = (params) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.get("users/me", { params })).data; }); /** Retrieves a list of all users in an account.*/ this.listUsers = (params) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.get("users")).data; }); /** Retrieves a user by identifier. */ this.getUser = (userId) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.get(`users/${userId}`)).data; }); this.client = client; } }; // src/services/fileProcessingConfigService.ts var FileProcessingConfigService = class { constructor(client) { /** Retrieves a list of all the file processing configurations in an account. */ this.listFileProcessingConfigurations = (params) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.get("file-processing-configurations", { params })).data; }); /** Retrieves a file processing configuration by identifier. */ this.getFileProcessingConfiguration = (fileProcessingConfigurationId) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.get(`file-processing-configurations/${fileProcessingConfigurationId}`)).data; }); /** Retrieves a file type setting by identifier. */ this.getFileTypeSetting = (fileProcessingConfigurationId, fileTypeSettingId, params) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.get( `file-processing-configurations/${fileProcessingConfigurationId}/file-type-settings/${fileTypeSettingId}`, { params } )).data; }); /** Retrieves a list of all the file type settings in a file processing configuration. */ this.listFileTypeSettings = (fileProcessingConfigurationId, params) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.get(`file-processing-configurations/${fileProcessingConfigurationId}/file-type-settings`, { params })).data; }); this.client = client; } }; // src/services/folderService.ts var FolderService = class { constructor(client) { /** Retrieves a list of all the folders in an account. Max 500. */ this.getFolders = (params) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.get("folders", { params })).data; }); /** Retrieves a folder by identifier. */ this.getFolder = (folderId, params) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.get(`folders/${folderId}`, { params })).data; }); /** Retrieves the Root folder in the account. */ this.getRootFolder = (params) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.get("folders/root", { params })).data; }); this.client = client; } }; // src/services/groupService.ts var GroupService = class { constructor(client) { /** Retrieves a list of all the groups in an account. */ this.getGroups = (params) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.get("groups", { params })).data; }); /** Retrieves a group by identifier. */ this.getGroup = (groupId, params) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.get(`groups/${groupId}`, { params })).data; }); this.client = client; } }; // src/services/fileService.ts var FileService = class { constructor(client) { /** * Uploads an archive with source files in a .zip format, to be extracted and used at project creation. * * Consider the {@link https://docs.rws.com/en-US/trados-enterprise---accelerate-791595/file-and-project-size-limit-815967 | file and project size limit} when uploading files. */ this.uploadZipFile = (formData) => __async(this, null, function* () { const headers = __spreadValues({}, this.client.getHeaders()); headers["Content-Type"] = "multipart/form-data"; return (yield this.client.lcServiceInstance.post("files", formData, { headers })).data; }); /** * Monitors the unzipping operation for a previously uploaded archive and gets details on the extracted files. */ this.pollUploadZipFile = (fileId) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.get(`files/${fileId}`)).data; }); this.client = client; } }; // src/services/languageProcessingService.ts var LanguageProcessingService = class { constructor(client) { /** Returns a list of Language Processing Rules. */ this.getLanguageProcessingRules = (params) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.get("language-processing-rules", { params })).data; }); /** Returns a Language Processing Rule by identifier. */ this.getLanguageProcessingRule = (languageProcessingRuleId, params) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.get(`language-processing-rules/${languageProcessingRuleId}`, { params })).data; }); this.client = client; } }; // src/services/machineTranslationService.ts var MachineTranslationService = class { constructor(client) { /** Retrieves a list of machine translations that can be used in a translation engine. */ this.getMachineTranslations = (params) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.get("machine-translation", { params })).data; }); this.client = client; } }; // src/services/pricingModelService.ts var PricingModelService = class { constructor(client) { /** Retrieves a list of all the pricing models in an account. * * Sorting is supported for the following fields: `name`, `description`, `currencyCode` and `location`. */ this.getPricingModels = (params) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.get("pricing-models", { params })).data; }); /** Retrieves a pricing model by identifier. */ this.getPricingModel = (pricingModelId, params) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.get(`pricing-models/${pricingModelId}`, { params })).data; }); this.client = client; } }; // src/services/projectGroupService.ts var ProjectGroupService = class { constructor(client) { /** Retrieves a list of all the project groups in an account. */ this.getProjectGroups = (params) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.get("project-groups", { params })).data; }); /** Retrieves a project group by identifier. */ this.getProjectGroup = (projectGroupId, params) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.get(`project-groups/${projectGroupId}`, { params })).data; }); /** Creates a new project group. */ this.createProjectGroup = (payload, params) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.post("project-groups", payload, { params })).data; }); /** Updates the project group. */ this.updateProjectGroup = (projectGroupId, payload) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.put(`project-groups/${projectGroupId}`, payload)).data; }); /** Deletes a project group. */ this.deleteProjectGroup = (projectGroupId) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.delete(`project-groups/${projectGroupId}`)).data; }); /** * Adds projects to the project group. * * The projects are not added instantly. To check the status use the {@link https://eu.cloud.trados.com/lc/api-docs/f865d82347954-get-project-group | Get Project Group} endpoint. */ this.addProjectToGroup = (projectGroupId, payload, params) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.post(`project-groups/${projectGroupId}/projects`, payload, { params })).data; }); /** * Removes projects from the project group. * * The projects are not removed instantly. To check the status use the {@link https://eu.cloud.trados.com/lc/api-docs/f865d82347954-get-project-group | Get Project Group} endpoint. */ this.removeProjectFromGroup = (projectGroupId, payload) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.delete(`project-groups/${projectGroupId}/projects`, { data: payload })).data; }); this.client = client; } }; // src/services/perfectMatchMappingService.ts var PerfectMatchMappingService = class { constructor(client) { /** * For more details on the PerfectMatch feature please consult the {@link https://docs.rws.com/en-US/trados-enterprise---accelerate-791595/perfectmatch-general-information-1155478 | official documentation}. * * After creating a mapping, target files from the `matchingProjects` are automatically matched to the source files in the new project. This is a long-running background operation, and its `status` can be tracked by polling the {@link https://eu.cloud.trados.com/lc/api-docs/gypb1u4fb5r8v-get-perfect-match-mapping | Get PerfectMatch Mapping} endpoint. */ this.createPerfectMatchMapping = (payload, params) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.post("perfect-match-mappings", payload, { params })).data; }); /** Retrieves the details of a PerfectMatch mapping. */ this.getPerfectMatchMapping = (mappingId, params) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.get(`perfect-match-mappings/${mappingId}`, { params })).data; }); /** Adds a new PerfectMatch batch mapping. * * When new source files are introduced to a mid-project, a new batch must be added to the current mapping to leverage PerfectMatch. This action triggers a background operation that identifies matching candidates for the newly added files. */ this.addPerfectMatchBatchMapping = (mappingId, payload, params) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.post(`perfect-match-mappings/${mappingId}/batch-mappings`, payload, { params })).data; }); /** Updates a PerfectMatch batch mapping. * * Pay special attention to how {@link https://eu.cloud.trados.com/lc/api-docs/updating-data-with-put | updating works}. */ this.updatePerfectMatchBatchMapping = (mappingId, batchMappingId, payload) => __async(this, null, function* () { const url = `perfect-match-mappings/${mappingId}/batch-mappings/${batchMappingId}`; return (yield this.client.lcServiceInstance.put(url, payload)).data; }); /** Updates a PerfectMatch file mapping with an existing target file from a PerfectMatch candidate. Only valid candidates can be used to request an update. * * Use the {@link https://eu.cloud.trados.com/lc/api-docs/fbia0pjkxv11t-get-perfect-match-candidates | Candidates} endpoint to retrieve a list of valid `fileId` and `projectId` to provide as matching data. */ this.updateFileMappingWithProjectFile = (mappingId, batchMappingId, fileMappingId, payload) => __async(this, null, function* () { const url = `perfect-match-mappings/${mappingId}/batch-mappings/${batchMappingId}/file-mappings/${fileMappingId}/project-file`; return (yield this.client.lcServiceInstance.put(url, payload)).data; }); /** Updates a PerfectMatch file mapping with a manually uploaded file. */ this.updateFileMappingWithManuallyUploadedFile = (mappingId, batchMappingId, fileMappingId, payload) => __async(this, null, function* () { const url = `perfect-match-mappings/${mappingId}/batch-mappings/${batchMappingId}/file-mappings/${fileMappingId}/file`; return (yield this.client.lcServiceInstance.post(url, payload)).data; }); /** Deletes a PerfectMatch file mapping for a specific file and target language. */ this.deletePerfectMatchFileMappingForaFile = (mappingId, batchMappingId, fileMappingId, targetLanguage) => __async(this, null, function* () { const url = `perfect-match-mappings/${mappingId}/batch-mappings/${batchMappingId}/file-mappings/${fileMappingId}/target-languages/${targetLanguage}`; return (yield this.client.lcServiceInstance.delete(url)).data; }); /** Retrieves a list of file candidates that can be selected for PerfectMatch. */ this.getPerfectMatchCandidates = (mappingId, batchMappingId, fileMappingId, targetLanguage, params) => __async(this, null, function* () { const url = `perfect-match-mappings/${mappingId}/batch-mappings/${batchMappingId}/file-mappings/${fileMappingId}/target-languages/${targetLanguage}/candidates`; return (yield this.client.lcServiceInstance.get(url, { params })).data; }); this.client = client; } }; // src/services/scheduleTemplateService.ts var ScheduleTemplateService = class { constructor(client) { /** Retrieves a list of all schedule templates in an account. */ this.listScheduleTemplates = () => __async(this, null, function* () { return (yield this.client.lcServiceInstance.get("schedule-templates")).data; }); /** Retrieves a schedule template by identifier. */ this.getScheduleTemplate = (scheduleTemplateId) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.get(`schedule-templates/${scheduleTemplateId}`)).data; }); /** Creates a new schedule template. */ this.createScheduleTemplate = (payload) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.post("schedule-templates", payload)).data; }); /** Updates a schedule template by id. */ this.updateScheduleTemplate = (scheduleTemplateId, payload) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.put(`schedule-templates/${scheduleTemplateId}`, payload)).data; }); /** Deletes a schedule template by id. */ this.deleteScheduleTemplate = (scheduleTemplateId) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.delete(`schedule-templates/${scheduleTemplateId}`)).data; }); this.client = client; } }; // src/services/rateLimitService.ts var RateLimitService = class { constructor(client) { /** Retrieves a list of all rate limits applicable for an account. */ this.listRateLimits = () => __async(this, null, function* () { return (yield this.client.lcServiceInstance.get("rate-limits")).data; }); this.client = client; } }; // src/services/publicKeyService.ts var PublicKeyService = class { constructor(client) { /** Retrieves a list of all public keys in an account. */ this.listPublicKeys = () => __async(this, null, function* () { return (yield this.client.lcServiceInstance.get(".well-known/jwks.json")).data; }); /** Retrieves a public key by identifier. */ this.getPublicKey = (kid) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.get(`.well-known/jwks.json/${kid}`)).data; }); this.client = client; } }; // src/services/quoteReportService.ts var QuoteReportService = class { constructor(client) { /** Generates an asynchronous quote export operation for the project in either PDF or Excel format. Use the polling endpoint to check when the export is completed. * Built-in quotes are only available in the same languages as the user interface. See this page for more information. * Customers who use non-default quote templates are responsible for the implementation of a suitable localization approach. */ this.exportQuoteReport = (projectId, params) => __async(this, null, function* () { const response = yield this.client.lcServiceInstance.post(`projects/${projectId}/quote-report/export`, null, { params }); return response.data; }); /** Polls a quote report via an export operation. The quote report can be downloaded once the status is "completed". * The recommended polling interval is 20 seconds. If polling does not return a success status in 20 minutes, it should be abandoned and a new export should be retried. * If the exportId query parameter is not provided, the polling action will return the status for the last generated export. */ this.pollQuoteReportStatus = (projectId, params) => __async(this, null, function* () { const response = yield this.client.lcServiceInstance.get(`projects/${projectId}/quote-report/export`, { params }); return response.data; }); /** Downloads a quote report generated by the asynchronous Export Quote Report operation. If the exportId query parameter is not provided, the last generated export quote will be downloaded.. */ this.downloadExportedQuoteReport = (projectId, params, config) => __async(this, null, function* () { const response = yield this.client.lcServiceInstance.get(`projects/${projectId}/quote-report/download`, __spreadProps(__spreadValues({}, config), { params })); return response.data; }); this.client = client; } }; // src/services/termbaseService.ts var TermbaseService = class { constructor(client) { /** List termbases. */ this.getTermbases = (params) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.get(`termbases`, { params })).data; }); /** Retrieves a termbase by identifier. */ this.getTermbase = (termbaseId, params) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.get(`termbases/${termbaseId}`, { params })).data; }); /** Creates a new termbase. The termbase can be created with a termbase template by providing the templateId or by providing a custom termbaseStructure. If only a `termbaseTemplateId` was provided, the termbase will be created using data from the template. If only a `termbaseStructure` was provided, the termbase will be created using data from the structure. If both, `termbaseTemplateId` and `termbaseStructure` are added in the request, the `termbaseStructure` takes precedence. */ this.createTermbase = (payload, params) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.post(`termbases`, payload, { params })).data; }); /** Updates the termbase. The termbase can be updated with a termbase template by providing the termbaseTemplateId or by providing a custom termbaseStructure. * * If only a `termbaseTemplateId` was provided, the termbase will be updated using data from the template. If only a `termbaseStructure` was provided, the termbase will be updated using data from the structure. If both, `termbaseTemplateId` and `termbaseStructure` are added in the request, the `termbaseStructure` takes precedence. */ this.updateTermbase = (termbaseId, payload) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.put(`termbases/${termbaseId}`, payload)).data; }); /** Deletes a termbase by identifier. */ this.deleteTermbase = (termbaseId) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.delete(`termbases/${termbaseId}`)).data; }); /** Retrieves a list of all the entries in a termbase. */ this.getTermbaseEntries = (termbaseId, params) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.get(`termbases/${termbaseId}/entries`, { params })).data; }); /** Retrieves a termbase entry by identifier. */ this.getTermbaseEntry = (termbaseId, entryId, params) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.get(`termbases/${termbaseId}/entries/${entryId}`, { params })).data; }); /** Creates a new termbase entry. For more information about how to use `fieldValueLinks` see {@link https://eu.cloud.trados.com/lc/api-docs/termbase-entries#creating-a-termbase-entry | Create termbase entry}. */ this.createTermbaseEntry = (termbaseId, payload, params) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.post(`termbases/${termbaseId}/entries`, payload, { params })).data; }); /** Updates a termbase entry by identifier. The request body will overwrite the existing data. */ this.updateTermbaseEntry = (termbaseId, entryId, payload) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.put(`termbases/${termbaseId}/entries/${entryId}`, payload)).data; }); /** Deletes all the entries in the termbase. */ this.deleteTermbaseEntries = (termbaseId) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.delete(`termbases/${termbaseId}/entries`)).data; }); /** Deletes a termbase entry. */ this.deleteTermbaseEntry = (termbaseId, entryId) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.delete(`termbases/${termbaseId}/entries/${entryId}`)).data; }); /** Retrieves a list of all the terms of the termbase. Search types: * * - normal: Use normal search to look for terms that match the text exactly as entered. * - linguistic: Use linguistic search to look for terms that are similar to the search term. Linguistic search is based on stemming and other language-dependent aspects. * - fuzzy: Use fuzzy search to look for terms that are similar to the search term. Fuzzy search is more fault-tolerant than linguistic search. */ this.getTermbaseTerms = (termbaseId, sourceLanguageCode, params) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.get(`termbases/${termbaseId}/terms/${sourceLanguageCode}`, { params })).data; }); this.client = client; } }; // src/services/taskService.ts var TaskService = class { constructor(client) { /** Retrieves a task by identifier */ this.getTask = (taskId, params) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.get(`tasks/${taskId}`, { params })).data; }); /** Retrieves the tasks assigned to the authenticated user */ this.listTasksAssignedToMe = (params) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.get("tasks/assigned", { params })).data; }); /** Accepts a task. The authenticated user becomes the owner of the accepted task and can start work on it. */ this.acceptTask = (taskId) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.put(`tasks/${taskId}/accept`, {})).data; }); /** Rejects a task. The authenticated user will be removed from the task's list of available assignee users. */ this.rejectTask = (taskId) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.put(`tasks/${taskId}/reject`, {})).data; }); /** Completes a task. The task is required to be in "inProgress" state and will be marked as "completed". */ this.completeTask = (taskId, payload) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.put(`tasks/${taskId}/complete`, payload)).data; }); /** Releases the task from its owner so that other task assignees will be able to accept it. */ this.releaseTask = (taskId) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.put(`tasks/${taskId}/release`, {})).data; }); /** The current owner of task is removed so that other assignees can accept it. The task is not reassigned automatically. */ this.reclaimTask = (taskId) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.put(`tasks/${taskId}/reclaim`, {})).data; }); /** Assigns a task. The task assignees will be updated. */ this.assignTask = (taskId, payload) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.put(`tasks/${taskId}/assign`, payload)).data; }); this.client = client; } }; // src/services/TermbaseExportService.ts var TermbaseExportService = class { constructor(client) { /** Generates an asynchronous export operation. * * Use the {@link https://eu.cloud.trados.com/lc/api-docs/063ba53a41601-poll-termbase-export | Poll Export Termbase} endpoint to poll until the export status is `done`. */ this.exportTermbase = (_0, ..._1) => __async(this, [_0, ..._1], function* (termbaseId, payload = {}) { return (yield this.client.lcServiceInstance.post(`termbases/${termbaseId}/exports`, payload)).data; }); /** Polls a termbase via an export operation. The exported termbase can be downloaded once the status is `done`. */ this.pollTermbaseExport = (termbaseId, exportId) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.get(`termbases/${termbaseId}/exports/${exportId}`)).data; }); /** Downloads the exported termbase when the poll operation status is `done`. */ this.downloadExportedTermbase = (termbaseId, exportId) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.get(`termbases/${termbaseId}/exports/${exportId}/download`)).data; }); /** Downloads the termbase definition. */ this.exportTermbaseTemplate = (termbaseId) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.get(`termbases/${termbaseId}/export-template`)).data; }); this.client = client; } }; // src/services/TermbaseImportService.ts var TermbaseImportService = class { constructor(client) { /** Gets the import history for a termbase. */ this.getTermbaseImportHistory = (termbaseId, params) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.get(`termbases/${termbaseId}/imports`, { params })).data; }); /** Generates an asynchronous import operation. * * Use the Poll Import Termbase endpoint to poll until the import status is `done`. */ this.importTermbase = (termbaseId, payload) => __async(this, null, function* () { const headers = __spreadValues({}, this.client.getHeaders()); headers["Content-Type"] = "multipart/form-data"; return (yield this.client.lcServiceInstance.post(`termbases/${termbaseId}/imports`, payload, { headers })).data; }); /** Polls a termbase import operation. */ this.pollTermbaseImport = (termbaseId, importId) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.get(`termbases/${termbaseId}/imports/${importId}`)).data; }); /** Downloads the termbase import logs. */ this.downloadTermbaseImportLogs = (termbaseId, importId) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.get(`termbases/${termbaseId}/imports/${importId}/logs`)).data; }); this.client = client; } }; // src/services/TermbaseTemplateService.ts var TermbaseTemplateService = class { constructor(client) { /** List termbase templates. */ this.getTermbaseTemplates = (params) => __async(this, null, function* () { return (yield this.client.lcServiceInstance.get(`termbase-templates`, { params })).data; }); /** Get a termbase template by identifier.