language-cloud-js-sdk
Version:
Language Cloud javascript sdk
1 lines • 134 kB
Source Map (JSON)
{"version":3,"sources":["../src/core/lcClient.ts","../src/services/customFieldDefinitionsService.ts","../src/services/languageService.ts","../src/services/projectService.ts","../src/services/projectTemplateService.ts","../src/utils/constants.ts","../src/services/sourceFileService.ts","../src/services/targetFileService.ts","../src/services/accountService.ts","../src/services/userService.ts","../src/services/fileProcessingConfigService.ts","../src/services/folderService.ts","../src/services/groupService.ts","../src/services/fileService.ts","../src/services/languageProcessingService.ts","../src/services/machineTranslationService.ts","../src/services/pricingModelService.ts","../src/services/projectGroupService.ts","../src/services/perfectMatchMappingService.ts","../src/services/scheduleTemplateService.ts","../src/services/rateLimitService.ts","../src/services/publicKeyService.ts","../src/services/quoteReportService.ts","../src/services/termbaseService.ts","../src/services/taskService.ts","../src/services/TermbaseExportService.ts","../src/services/TermbaseImportService.ts","../src/services/TermbaseTemplateService.ts","../src/services/tqaProfileService.ts","../src/services/workflowService.ts","../src/services/translationEngineService.ts","../src/services/translationMemoryService.ts","../src/services/translationMemoryExportService.ts","../src/services/translationMemoryImportService.ts","../src/public-apis/lcRegion.ts","../src/utils/jsonConverters.ts","../src/lcSDK.ts"],"sourcesContent":["import axios, { AxiosInstance } from 'axios';\r\nimport { IAuthResponse, ILcClientInstanceConfig } from '../models/lcClientModels';\r\nimport { CustomFieldDefinitionsService } from '../services/customFieldDefinitionsService';\r\nimport { LanguageService } from '../services/languageService';\r\nimport { ProjectService } from '../services/projectService';\r\nimport { ProjectTemplateService } from '../services/projectTemplateService';\r\nimport {\r\n AUDIENCE,\r\n AUTH_URL,\r\n AppMessages,\r\n GRANT_TYPE,\r\n PROJECT_SERVICE_BASE_URL,\r\n X_LC_CALLER_APP,\r\n} from '../utils/constants';\r\nimport { SourceFileService } from '../services/sourceFileService';\r\nimport { TargetFileService } from '../services/targetFileService';\r\nimport { AccountService } from '../services/accountService';\r\nimport { UserService } from '../services/userService';\r\nimport { FileProcessingConfigService } from '../services/fileProcessingConfigService';\r\nimport { FolderService } from '../services/folderService';\r\nimport { GroupService } from '../services/groupService';\r\nimport { FileService } from '../services/fileService';\r\nimport { LanguageProcessingService } from '../services/languageProcessingService';\r\nimport { MachineTranslationService } from '../services/machineTranslationService';\r\nimport { PricingModelService } from '../services/pricingModelService';\r\nimport { ProjectGroupService } from '../services/projectGroupService';\r\nimport { PerfectMatchMappingService } from '../services/perfectMatchMappingService';\r\nimport { ScheduleTemplateService } from '../services/scheduleTemplateService';\r\nimport { RateLimitService } from '../services/rateLimitService';\r\nimport { PublicKeyService } from '../services/publicKeyService';\r\nimport { QuoteReportService } from '../services/quoteReportService';\r\nimport { TermbaseService } from '../services/termbaseService';\r\nimport { TaskService } from '../services/taskService';\r\nimport { TermbaseExportService } from '../services/TermbaseExportService';\r\nimport { TermbaseImportService } from '../services/TermbaseImportService';\r\nimport { TermbaseTemplateService } from '../services/TermbaseTemplateService';\r\nimport { TQAProfileService } from '../services/tqaProfileService';\r\nimport { WorkflowService } from '../services/workflowService';\r\nimport { TranslationEngineService } from '../services/translationEngineService';\r\nimport { TranslationMemoryService } from '../services/translationMemoryService';\r\nimport { TranslationMemoryExportService } from '../services/translationMemoryExportService';\r\nimport { TranslationMemoryImportService } from '../services/translationMemoryImportService';\r\nimport { getRegions } from '../public-apis/lcRegion';\r\nimport { Region } from '../models/regionModel';\r\n\r\nclass LanguageCloudClient {\r\n private readonly clientId?: string;\r\n private readonly clientSecret?: string;\r\n private readonly accountId: string;\r\n public baseURL: string = PROJECT_SERVICE_BASE_URL;\r\n private readonly xLcCallerApp: string;\r\n public lcServiceInstance: AxiosInstance;\r\n\r\n tokenDetails: (IAuthResponse & { timeStamp: number; baseURL: string }) | null = null;\r\n\r\n /**\r\n * Creates an instance of the LanguageCloudClient\r\n * @param {ILcClientInstanceConfig} instanceConfig\r\n * @property {string} instanceConfig.client_id - client id\r\n * @property {string} instanceConfig.client_secret - client secret\r\n * @property {string} instanceConfig.account_id - account id\r\n * @property {string} [instanceConfig.base_url] - base url for the language cloud service\r\n * @property {string} [instanceConfig.x_lc_caller_app] - caller app name\r\n */\r\n constructor(instanceConfig: ILcClientInstanceConfig) {\r\n this.clientId = instanceConfig.client_id;\r\n this.clientSecret = instanceConfig.client_secret;\r\n this.accountId = instanceConfig.account_id;\r\n this.baseURL = instanceConfig.base_url || PROJECT_SERVICE_BASE_URL;\r\n this.xLcCallerApp = instanceConfig.x_lc_caller_app || X_LC_CALLER_APP;\r\n this.lcServiceInstance = axios.create({\r\n baseURL: this.baseURL,\r\n paramsSerializer: {\r\n indexes: null,\r\n },\r\n });\r\n if (instanceConfig.access_token) {\r\n this.tokenDetails = {\r\n access_token: instanceConfig.access_token,\r\n token_type: 'Bearer',\r\n timeStamp: Date.now(),\r\n expires_in: 0,\r\n baseURL: this.baseURL,\r\n };\r\n this.lcServiceInstance.defaults.headers = this.getHeaders();\r\n }\r\n }\r\n\r\n /**\r\n * Requests an access token from the authentication service\r\n * @throws {Error} If the client id or client secret is missing\r\n * @throws {Error} If the request to the authentication service fails\r\n * @returns {Promise<void>} A promise that resolves when the token has been requested and the account validity has been checked\r\n */\r\n async requestToken(): Promise<void> {\r\n if (!this.clientId || !this.clientSecret) {\r\n throw new Error(AppMessages.CREDENTIALS_MISSING);\r\n }\r\n\r\n try {\r\n const { data } = await axios.post(\r\n AUTH_URL,\r\n {\r\n client_id: this.clientId,\r\n client_secret: this.clientSecret,\r\n grant_type: GRANT_TYPE,\r\n audience: AUDIENCE,\r\n },\r\n {\r\n headers: {\r\n 'Content-Type': 'application/json',\r\n },\r\n }\r\n );\r\n\r\n this.tokenDetails = { ...data, time_stamp: Date.now() };\r\n this.lcServiceInstance.defaults.headers = this.getHeaders();\r\n\r\n const region = await this.checkAccountValidity();\r\n if (region) {\r\n this.baseURL = `https://${region.hosts.apiHost}/public-api/v1/`;\r\n this.lcServiceInstance = axios.create({\r\n baseURL: this.baseURL,\r\n paramsSerializer: {\r\n indexes: null,\r\n },\r\n });\r\n if (this.tokenDetails) {\r\n this.tokenDetails.baseURL = this.baseURL;\r\n }\r\n } else {\r\n throw new Error('Either valid region not found or Account ID is wrong.');\r\n }\r\n } catch (error: unknown) {\r\n throw error;\r\n }\r\n }\r\n\r\n /**\r\n * Checks the validity of the account by making a request to the project service\r\n * @throws {Error} If the token is not found\r\n * @returns {Promise<void>} A promise that resolves when the account validity has been checked\r\n */\r\n\r\n private async checkAccountValidity(): Promise<Region | null> {\r\n const regionDetails = await getRegions();\r\n if (regionDetails?.items?.length) {\r\n let regionFound = null;\r\n for (let regionItem of regionDetails.items) {\r\n try {\r\n if (!regionItem?.hosts?.apiHost) continue;\r\n\r\n const validityCheck = await axios.get(\r\n `https://${regionItem.hosts.apiHost}/public-api/v1/projects?fields=id&top=1`,\r\n {\r\n headers: { ...this.getHeaders() },\r\n }\r\n );\r\n\r\n if (validityCheck && validityCheck.data) {\r\n regionFound = regionItem;\r\n break;\r\n }\r\n } catch (e) {}\r\n }\r\n\r\n return regionFound;\r\n } else {\r\n throw new Error('Regions unavailable');\r\n }\r\n }\r\n\r\n getHeaders() {\r\n let headers: any = {\r\n 'Content-Type': 'application/json',\r\n };\r\n\r\n if (this.xLcCallerApp) {\r\n headers['X-LC-Caller-App'] = this.xLcCallerApp;\r\n }\r\n if (this.accountId) {\r\n headers['X-LC-Tenant'] = this.accountId;\r\n }\r\n if (this.tokenDetails?.token_type && this.tokenDetails?.access_token) {\r\n headers.Authorization = `${this.tokenDetails.token_type} ${this.tokenDetails?.access_token}`;\r\n }\r\n return headers;\r\n }\r\n\r\n projectService = new ProjectService(this);\r\n projectTemplateService = new ProjectTemplateService(this);\r\n languageService = new LanguageService(this);\r\n customFieldDefinitionsService = new CustomFieldDefinitionsService(this);\r\n sourceFileService = new SourceFileService(this);\r\n targetFileService = new TargetFileService(this);\r\n accountService = new AccountService(this);\r\n userService = new UserService(this);\r\n fileProcessingConfigService = new FileProcessingConfigService(this);\r\n folderService = new FolderService(this);\r\n groupService = new GroupService(this);\r\n fileService = new FileService(this);\r\n languageProcessingService = new LanguageProcessingService(this);\r\n machineTranslationService = new MachineTranslationService(this);\r\n pricingModelService = new PricingModelService(this);\r\n projectGroupService = new ProjectGroupService(this);\r\n perfectMatchMappingService = new PerfectMatchMappingService(this);\r\n scheduleTemplateService = new ScheduleTemplateService(this);\r\n rateLimitService = new RateLimitService(this);\r\n publicKeyService = new PublicKeyService(this);\r\n quoteReportService = new QuoteReportService(this);\r\n termbaseService = new TermbaseService(this);\r\n taskService = new TaskService(this);\r\n termbaseExportService = new TermbaseExportService(this);\r\n termbaseImportService = new TermbaseImportService(this);\r\n termbaseTemplateService = new TermbaseTemplateService(this);\r\n tqaProfileService = new TQAProfileService(this);\r\n workflowService = new WorkflowService(this);\r\n translationEngineService = new TranslationEngineService(this);\r\n translationMemoryService = new TranslationMemoryService(this);\r\n translationMemoryExportService = new TranslationMemoryExportService(this);\r\n translationMemoryImportService = new TranslationMemoryImportService(this);\r\n}\r\n\r\nexport default LanguageCloudClient;\r\n","import LanguageCloudClient from '../core/lcClient';\r\nimport { FieldsParams } from '../models/commonModel';\r\nimport {\r\n CustomFieldDefinition,\r\n CustomFieldDefinitionListRequestParams,\r\n CustomFieldDefinitionListResponse,\r\n} from '../models/customFieldModel';\r\n\r\nexport class CustomFieldDefinitionsService {\r\n private readonly client: LanguageCloudClient;\r\n\r\n constructor(client: LanguageCloudClient) {\r\n this.client = client;\r\n }\r\n\r\n /** Retrieves a list of all the custom field definitions. */\r\n getCustomFieldDefinitions = async (params?: CustomFieldDefinitionListRequestParams): Promise<CustomFieldDefinitionListResponse> => {\r\n return (await this.client.lcServiceInstance.get('custom-field-definitions', { params })).data;\r\n };\r\n\r\n /** Retrieves a Custom Field by identifier. */\r\n getCustomFieldDefinition = async (customFieldDefinitionId: string, params?: FieldsParams): Promise<CustomFieldDefinition> => {\r\n return (await this.client.lcServiceInstance.get(`custom-field-definitions/${customFieldDefinitionId}`, { params })).data;\r\n };\r\n}\r\n","import LanguageCloudClient from '../core/lcClient';\r\nimport { LanguageListRequestParams, LanguageListResponse } from '../models/languageModel';\r\n\r\nexport class LanguageService {\r\n private readonly client: LanguageCloudClient;\r\n\r\n constructor(client: LanguageCloudClient) {\r\n this.client = client;\r\n }\r\n\r\n /** Retrieves a list of all the languages.\r\n *\r\n * The supported values for language `type` filter are: \"all\", \"specific\" or \"neutral\".\r\n * The \"neutral\" languages are the generic languages, e.g.: en -> English.\r\n *\r\n * The \"specific\" languages are the sub-languages, e.g.: en-150 -> English (Europe), en-us -> English (United States).\r\n */\r\n getLanguages = async (params: LanguageListRequestParams = {}): Promise<LanguageListResponse> => {\r\n return (await this.client.lcServiceInstance.get('languages', { params })).data;\r\n };\r\n}\r\n","import LanguageCloudClient from '../core/lcClient';\r\nimport { FieldsParams } from '../models/commonModel';\r\nimport {\r\n IProjectListRequestParams,\r\n IProjectListResponse,\r\n Project,\r\n ProjectConfigurationResponse,\r\n ProjectConfigurationUpdateRequestPayload,\r\n ProjectCreateRequestPayload,\r\n ProjectCustomFieldUpdateRequestPayload,\r\n ProjectPricingModelUpdateRequestPayload,\r\n ProjectTaskListResponse,\r\n ProjectUpdateRequestPayload,\r\n} from '../models/projectModel';\r\nimport { CommonParams } from '../models/commonModel';\r\n\r\nexport class ProjectService {\r\n private readonly client: LanguageCloudClient;\r\n\r\n constructor(client: LanguageCloudClient) {\r\n this.client = client;\r\n }\r\n\r\n /** Retrieves a list of all the projects in the account. */\r\n getProjects = async (params?: IProjectListRequestParams): Promise<IProjectListResponse> => {\r\n return (await this.client.lcServiceInstance.get('projects', { params })).data;\r\n };\r\n\r\n /** Retrieves a project by identifier. */\r\n getProject = async (projectId: string, params?: FieldsParams): Promise<Project> => {\r\n return (await this.client.lcServiceInstance.get(`projects/${projectId}`, { params })).data;\r\n };\r\n\r\n /** Deletes a project. */\r\n deleteProject = async (projectId: string): Promise<void> => {\r\n return (await this.client.lcServiceInstance.delete(`projects/${projectId}`)).data;\r\n };\r\n\r\n /** Creates a new project.\r\n *\r\n * When creating a project using a project template that supports multiple source languages, you must supply the `languageDirections`.\r\n *\r\n * 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.\r\n *\r\n * The values from a selected project template will take precedence over the individual resources when creating a new project.\r\n */\r\n createProject = async (payload: ProjectCreateRequestPayload, params?: FieldsParams): Promise<Project> => {\r\n return (await this.client.lcServiceInstance.post('projects', payload, { params })).data;\r\n };\r\n\r\n /** 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. */\r\n startProject = async (projectId: string): Promise<void> => {\r\n return (await this.client.lcServiceInstance.put(`projects/${projectId}/start`, {})).data;\r\n };\r\n\r\n /** Marks a project as \"completed\". */\r\n completeProject = async (projectId: string): Promise<void> => {\r\n return (await this.client.lcServiceInstance.put(`projects/${projectId}/complete`, {})).data;\r\n };\r\n\r\n /** Updates the project in terms of: name, description, due date, quote, and project resources.\r\n * Observe the rules of {@link https://datatracker.ietf.org/doc/html/rfc7386 | JSON Merge Patch Semantics}.\r\n *\r\n * Project rescheduling (updating dueBy) is permitted only if:\r\n * - there is no Customer Quote Approval task in the associated flow\r\n * - at least one Customer Quote Approval was closed(in case multiple project batches)\r\n *\r\n * Update `projectPlan.taskConfigurations` are now permitted before project is started. Elements are now pre-populated at project creation time.\r\n */\r\n updateProject = async (projectId: string, payload: ProjectUpdateRequestPayload): Promise<void> => {\r\n return (await this.client.lcServiceInstance.put(`projects/${projectId}`, payload)).data;\r\n };\r\n\r\n /** Lists the tasks of a specific project. */\r\n getProjectTasks = async (projectId: string, params?: CommonParams): Promise<ProjectTaskListResponse> => {\r\n return (await this.client.lcServiceInstance.get(`projects/${projectId}/tasks`, { params })).data;\r\n };\r\n\r\n /** Allows updating individual custom fields on a project. */\r\n updateCustomField = async (projectId: string, customFieldKey: string, payload: ProjectCustomFieldUpdateRequestPayload): Promise<void> => {\r\n return (await this.client.lcServiceInstance.put(`projects/${projectId}/custom-fields/${customFieldKey}`, payload)).data;\r\n };\r\n\r\n /** Get the configuration settings of an existing project. */\r\n getProjectConfiguration = async (projectId: string, params?: FieldsParams): Promise<ProjectConfigurationResponse> => {\r\n return (await this.client.lcServiceInstance.get(`projects/${projectId}/configuration`, { params })).data;\r\n };\r\n\r\n /** Updates the configuration settings for an existing project. */\r\n updateProjectConfiguration = async (projectId: string, payload: ProjectConfigurationUpdateRequestPayload): Promise<void> => {\r\n return (await this.client.lcServiceInstance.put(`projects/${projectId}/configuration`, payload)).data;\r\n };\r\n\r\n /** Update project pricing model only during Customer Quote Review task type. */\r\n updateProjectPricingModel = async (projectId: string, payload: ProjectPricingModelUpdateRequestPayload): Promise<void> => {\r\n return (await this.client.lcServiceInstance.put(`projects/${projectId}/pricing-model`, payload)).data;\r\n };\r\n\r\n /** Cancels a project file. */\r\n cancelProjectFile = async (projectId: string, fileId: string): Promise<void> => {\r\n return (await this.client.lcServiceInstance.put(`projects/${projectId}/files/${fileId}/cancel`, {})).data;\r\n };\r\n}\r\n","import LanguageCloudClient from '../core/lcClient';\r\nimport { FieldsParams } from '../models/commonModel';\r\nimport {\r\n ProjectTemplate,\r\n ProjectTemplateListRequestParams,\r\n ProjectTemplateListResponse,\r\n ProjectTemplateRequestPayload,\r\n} from '../models/projectTemplateModel';\r\n\r\nexport class ProjectTemplateService {\r\n private readonly client: LanguageCloudClient;\r\n\r\n constructor(client: LanguageCloudClient) {\r\n this.client = client;\r\n }\r\n\r\n /** Retrieves a project template by identifier. */\r\n getProjectTemplate = async (projectTemplateId: string, params?: FieldsParams): Promise<ProjectTemplate> => {\r\n return (await this.client.lcServiceInstance.get(`project-templates/${projectTemplateId}`, { params })).data;\r\n };\r\n\r\n /** Retrieves a list of all the project templates in an account. */\r\n getProjectTemplates = async (params?: ProjectTemplateListRequestParams): Promise<ProjectTemplateListResponse> => {\r\n return (await this.client.lcServiceInstance.get(`project-templates`, { params })).data;\r\n };\r\n\r\n /** Deletes a project template by id. */\r\n deleteProjectTemplate = async (projectTemplateId: string): Promise<void> => {\r\n return (await this.client.lcServiceInstance.delete(`project-templates/${projectTemplateId}`)).data;\r\n };\r\n\r\n /** Creates a new project template. */\r\n createProjectTemplate = async (payload: ProjectTemplateRequestPayload, params?: FieldsParams): Promise<ProjectTemplate> => {\r\n return (await this.client.lcServiceInstance.post(`project-templates`, payload, { params })).data;\r\n };\r\n\r\n /** Updates a project template by id. */\r\n updateProjectTemplate = async (projectTemplateId: string, payload: ProjectTemplateRequestPayload): Promise<void> => {\r\n return (await this.client.lcServiceInstance.put(`project-templates/${projectTemplateId}`, payload)).data;\r\n };\r\n}\r\n","export const AUTH_URL = 'https://sdl-prod.eu.auth0.com/oauth/token';\r\nexport const PROJECT_SERVICE_BASE_URL = 'https://lc-api.sdl.com/public-api/v1/';\r\nexport const LANGUAGE_CLOUD_V3_BASE_URL = 'https://lc-api.sdl.com/projects/v3/';\r\nexport const GRANT_TYPE = 'client_credentials';\r\nexport const AUDIENCE = 'https://api.sdl.com';\r\nexport const X_LC_CALLER_APP = 'LC_SDK/v1.0.7';\r\nexport const PUBLIC_API_URL = 'https://api.cloud.trados.com/public-api/v1/';\r\n\r\nexport const AppMessages = {\r\n CREDENTIALS_MISSING: 'credentials missing',\r\n TOKEN_NOT_FOUND: 'token not found',\r\n INPUT_MISSING: 'Input contains null or undefined values.',\r\n INVALID_INPUT: 'Invalid input: Expected a non-null object as input.',\r\n};\r\n","import LanguageCloudClient from '../core/lcClient';\r\nimport { FieldsParams } from '../models/commonModel';\r\nimport {\r\n SourceFile,\r\n SourceFileListRequestParams,\r\n SourceFileListResponse,\r\n SourceFileProperties,\r\n SourceFilesAttachPayload,\r\n SourceFilesUpdateRequest,\r\n SourceFileUpdateRequest,\r\n SourceFileVersionsListResponse,\r\n} from '../models/sourceFileModel';\r\n\r\nexport class SourceFileService {\r\n private readonly client: LanguageCloudClient;\r\n\r\n constructor(client: LanguageCloudClient) {\r\n this.client = client;\r\n }\r\n\r\n /** Retrieves the source files in a project. */\r\n getSourceFiles = async (projectId: string, params?: SourceFileListRequestParams): Promise<SourceFileListResponse> => {\r\n return (await this.client.lcServiceInstance.get(`projects/${projectId}/source-files`, { params })).data;\r\n };\r\n\r\n /** Retrieves a source file from the project. */\r\n getSourceFile = async (projectId: string, sourceFileId: string, params?: FieldsParams): Promise<SourceFile> => {\r\n return (await this.client.lcServiceInstance.get(`projects/${projectId}/source-files/${sourceFileId}`, { params })).data;\r\n };\r\n\r\n /**\r\n * 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.\r\n *\r\n * 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.\r\n *\r\n * `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.\r\n */\r\n\r\n // TODO: Need to check how can we set the SourceFileAddRequestPayload interface to FormData\r\n addSourceFile = async (projectId: string, payload: FormData): Promise<SourceFile> => {\r\n const headers = { ...this.client.getHeaders() };\r\n headers['Content-Type'] = 'multipart/form-data';\r\n\r\n return (await this.client.lcServiceInstance.post(`projects/${projectId}/source-files`, payload, { headers })).data;\r\n };\r\n\r\n /**\r\n * 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.\r\n *\r\n * `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.\r\n */\r\n attachSourceFiles = async (projectId: string, payload: SourceFilesAttachPayload, params?: FieldsParams): Promise<SourceFile> => {\r\n return (await this.client.lcServiceInstance.post(`projects/${projectId}/source-files/attach-files`, payload, { params })).data;\r\n };\r\n\r\n /** Updates multiple source files. If any of the files fails to be updated, an error will be returned for each file. */\r\n updateSourceFiles = async (projectId: string, payload: SourceFilesUpdateRequest): Promise<void> => {\r\n return (await this.client.lcServiceInstance.put(`projects/${projectId}/source-files`, payload)).data;\r\n };\r\n\r\n /** Updates a source file. */\r\n updateSourceFile = async (projectId: string, sourceFileId: string, payload: SourceFileUpdateRequest): Promise<void> => {\r\n return (await this.client.lcServiceInstance.put(`projects/${projectId}/source-files/${sourceFileId}`, payload)).data;\r\n };\r\n\r\n /** Retrieves all the versions of a source file. */\r\n listSourceFileVersions = async (\r\n projectId: string,\r\n sourceFileId: string,\r\n params?: FieldsParams\r\n ): Promise<SourceFileVersionsListResponse> => {\r\n return (await this.client.lcServiceInstance.get(`projects/${projectId}/source-files/${sourceFileId}/versions`, { params })).data;\r\n };\r\n\r\n /** Downloads a source file version. */\r\n downloadSourceFileVersion = async (\r\n projectId: string,\r\n sourceFileId: string,\r\n fileVersionId: string,\r\n config?: Record<string, any>\r\n ): Promise<string> => {\r\n const endpoint = `projects/${projectId}/source-files/${sourceFileId}/versions/${fileVersionId}/download`;\r\n return (await this.client.lcServiceInstance.get(endpoint, { ...config })).data;\r\n };\r\n\r\n /** Retrieves the properties for a source file. */\r\n getSourceFileProperties = async (taskId: string, sourceFileId: string): Promise<SourceFileProperties> => {\r\n return (await this.client.lcServiceInstance.get(`tasks/${taskId}/source-files/${sourceFileId}`)).data;\r\n };\r\n\r\n /** Updates the properties of the source file. */\r\n updateSourceFileProperties = async (taskId: string, sourceFileId: string, payload: SourceFileProperties): Promise<void> => {\r\n return (await this.client.lcServiceInstance.put(`tasks/${taskId}/source-files/${sourceFileId}`, payload)).data;\r\n };\r\n}\r\n","import LanguageCloudClient from '../core/lcClient';\r\nimport { FieldsParams } from '../models/commonModel';\r\nimport {\r\n TargetFile,\r\n TargetFileAddResponse,\r\n TargetFilesRequestParams,\r\n TargetFilesResponse,\r\n TargetFilesUpdateRequestPayload,\r\n TargetFileUpdateRequestPayload,\r\n TargetFileVersion,\r\n TargetFileVersionExportRequestParams,\r\n TargetFileVersionExportResponse,\r\n TargetFileVersionImportResponse,\r\n TargetFileVersionsResponse,\r\n} from '../models/targetFileModel';\r\n\r\nexport class TargetFileService {\r\n private readonly client: LanguageCloudClient;\r\n\r\n constructor(client: LanguageCloudClient) {\r\n this.client = client;\r\n }\r\n\r\n /** Retrieves the target files for a project. */\r\n getTargetFiles = async (projectId: string, params?: TargetFilesRequestParams): Promise<TargetFilesResponse> => {\r\n return (await this.client.lcServiceInstance.get(`projects/${projectId}/target-files`, { params })).data;\r\n };\r\n\r\n /** Retrieves a target file from a project. */\r\n getTargetFile = async (projectId: string, targetFileId: string, params?: FieldsParams): Promise<TargetFile> => {\r\n return (await this.client.lcServiceInstance.get(`projects/${projectId}/target-files/${targetFileId}`, { params })).data;\r\n };\r\n\r\n getTargetFileVersion = async (\r\n projectId: string,\r\n targetFileId: string,\r\n fileVersionId: string,\r\n params?: FieldsParams\r\n ): Promise<TargetFileVersion> => {\r\n const endpoint = `projects/${projectId}/target-files/${targetFileId}/versions/${fileVersionId}`;\r\n\r\n return (await this.client.lcServiceInstance.get(endpoint, { params })).data;\r\n };\r\n\r\n /** Updates a target file. */\r\n updateTargetFile = async (projectId: string, targetFileId: string, payload: TargetFileUpdateRequestPayload): Promise<void> => {\r\n return (await this.client.lcServiceInstance.put(`projects/${projectId}/target-files/${targetFileId}`, payload)).data;\r\n };\r\n\r\n /** Updates multiple target files. If any of the files fails to be updated, an error will be returned for each file. */\r\n updateTargetFiles = async (projectId: string, payload: TargetFilesUpdateRequestPayload): Promise<void> => {\r\n return (await this.client.lcServiceInstance.put(`projects/${projectId}/target-files`, payload)).data;\r\n };\r\n\r\n /** Retrieves the versions of a target file. */\r\n getTargetFileVersions = async (projectId: string, targetFileId: string, params?: FieldsParams): Promise<TargetFileVersionsResponse> => {\r\n return (await this.client.lcServiceInstance.get(`projects/${projectId}/target-files/${targetFileId}/versions`, { params })).data;\r\n };\r\n\r\n /**\r\n * 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.\r\n *\r\n * 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.\r\n *\r\n * 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.\r\n */\r\n exportTargetFileVersion = async (\r\n projectId: string,\r\n targetFileId: string,\r\n fileVersionId: string,\r\n params?: TargetFileVersionExportRequestParams\r\n ): Promise<TargetFileVersionExportResponse> => {\r\n const endpoint = `projects/${projectId}/target-files/${targetFileId}/versions/${fileVersionId}/exports`;\r\n return (await this.client.lcServiceInstance.post(endpoint, null, { params })).data;\r\n };\r\n\r\n /**\r\n * Polls a target file version via an export operation. The new version can be downloaded once the status is \"completed\".\r\n */\r\n pollTargetFileVersionExport = async (\r\n projectId: string,\r\n targetFileId: string,\r\n fileVersionId: string,\r\n exportId: string\r\n ): Promise<TargetFileVersionExportResponse> => {\r\n const endpoint = `projects/${projectId}/target-files/${targetFileId}/versions/${fileVersionId}/exports/${exportId}`;\r\n return (await this.client.lcServiceInstance.get(endpoint)).data;\r\n };\r\n\r\n /**\r\n * Downloads a completed target file version via an export operation.\r\n */\r\n downloadExportedTargetFileVersion = async (projectId: string, targetFileId: string, fileVersionId: string, exportId: string): Promise<string> => {\r\n const endpoint = `projects/${projectId}/target-files/${targetFileId}/versions/${fileVersionId}/exports/${exportId}/download`;\r\n return (await this.client.lcServiceInstance.get(endpoint)).data;\r\n };\r\n\r\n /**\r\n * Downloads the file version (native or BCM).\r\n *\r\n * 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.\r\n */\r\n downloadTargetFileVersion = async (\r\n projectId: string,\r\n targetFileId: string,\r\n fileVersionId: string,\r\n config?: Record<string, any>\r\n ): Promise<string> => {\r\n const endpoint = `projects/${projectId}/target-files/${targetFileId}/versions/${fileVersionId}/download`;\r\n return (await this.client.lcServiceInstance.get(endpoint, { ...config })).data;\r\n };\r\n\r\n /**\r\n * 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.\r\n *\r\n * 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.\r\n *\r\n * 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.\r\n */\r\n // TODO: Need to check how can we set the interface to FormData\r\n importTargetFileVersion = async (projectId: string, targetFileId: string, payload: FormData): Promise<TargetFileVersionImportResponse> => {\r\n const endpoint = `projects/${projectId}/target-files/${targetFileId}/versions/imports`;\r\n\r\n const headers = { ...this.client.getHeaders() };\r\n headers['Content-Type'] = 'multipart/form-data';\r\n\r\n return (await this.client.lcServiceInstance.post(endpoint, payload, { headers })).data;\r\n };\r\n\r\n /**\r\n * Polls a target file version via an import operation. The new version can be seen on the file versions once the status is \"completed\".\r\n */\r\n pollTargetFileVersionImport = async (projectId: string, targetFileId: string, importId: string): Promise<TargetFileVersionImportResponse> => {\r\n const endpoint = `projects/${projectId}/target-files/${targetFileId}/versions/imports/${importId}`;\r\n return (await this.client.lcServiceInstance.get(endpoint)).data;\r\n };\r\n\r\n /**\r\n * 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}.\r\n *\r\n * 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`.\r\n *\r\n * 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.\r\n *\r\n * For adding a target file version using an extension task, the configuration of the task type must declare the `scope`'s value as \"file\".\r\n *\r\n * The multipart parameters in the body should respect and strictly follow the order specified in our documentation.\r\n *\r\n * 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.\r\n */\r\n // TODO: Need to check how can we set the interface to FormData\r\n addTargetFileVersion = async (taskId: string, targetFileId: string, payload: FormData, params?: FieldsParams): Promise<TargetFileAddResponse> => {\r\n const endpoint = `tasks/${taskId}/target-files/${targetFileId}/versions`;\r\n return (await this.client.lcServiceInstance.post(endpoint, payload, { params })).data;\r\n };\r\n}\r\n","import LanguageCloudClient from '../core/lcClient';\r\nimport { AccountListResponse } from '../models/accountModel';\r\n\r\nexport class AccountService {\r\n private readonly client: LanguageCloudClient;\r\n constructor(client: LanguageCloudClient) {\r\n this.client = client;\r\n }\r\n\r\n /** Retrieves a list of all accounts accessible to the authenticated user. */\r\n getAccounts = async (): Promise<AccountListResponse> => {\r\n return (await this.client.lcServiceInstance.get<AccountListResponse>('accounts')).data;\r\n };\r\n}\r\n","import LanguageCloudClient from '../core/lcClient';\r\nimport { FieldsParams } from '../models/commonModel';\r\nimport { CommonParams } from '../models/commonModel';\r\nimport { User, UserListResponse } from '../models/userModel';\r\n\r\nexport class UserService {\r\n private readonly client: LanguageCloudClient;\r\n constructor(client: LanguageCloudClient) {\r\n this.client = client;\r\n }\r\n\r\n /** Retrieves the authenticated user. */\r\n getMyUser = async (params?: FieldsParams): Promise<User> => {\r\n return (await this.client.lcServiceInstance.get('users/me', { params })).data;\r\n };\r\n\r\n /** Retrieves a list of all users in an account.*/\r\n listUsers = async (params?: CommonParams): Promise<UserListResponse> => {\r\n return (await this.client.lcServiceInstance.get('users')).data;\r\n };\r\n\r\n /** Retrieves a user by identifier. */\r\n getUser = async (userId: string): Promise<User> => {\r\n return (await this.client.lcServiceInstance.get(`users/${userId}`)).data;\r\n };\r\n}\r\n","import LanguageCloudClient from '../core/lcClient';\r\nimport { FieldsParams } from '../models/commonModel';\r\nimport {\r\n FileProcessingConfig,\r\n FileProcessingConfigListResponse,\r\n FileTypeSetting,\r\n FileTypeSettingListResponse,\r\n ListFileProcessingConfigurationsParams,\r\n} from '../models/fileProcessingConfigModel';\r\n\r\nexport class FileProcessingConfigService {\r\n private readonly client: LanguageCloudClient;\r\n constructor(client: LanguageCloudClient) {\r\n this.client = client;\r\n }\r\n\r\n /** Retrieves a list of all the file processing configurations in an account. */\r\n listFileProcessingConfigurations = async (\r\n params?: ListFileProcessingConfigurationsParams\r\n ): Promise<FileProcessingConfigListResponse> => {\r\n return (await this.client.lcServiceInstance.get('file-processing-configurations', { params })).data;\r\n };\r\n\r\n /** Retrieves a file processing configuration by identifier. */\r\n getFileProcessingConfiguration = async (fileProcessingConfigurationId: string): Promise<FileProcessingConfig> => {\r\n return (await this.client.lcServiceInstance.get(`file-processing-configurations/${fileProcessingConfigurationId}`)).data;\r\n };\r\n\r\n /** Retrieves a file type setting by identifier. */\r\n getFileTypeSetting = async (\r\n fileProcessingConfigurationId: string,\r\n fileTypeSettingId: string,\r\n params?: FieldsParams\r\n ): Promise<FileTypeSetting> => {\r\n return (\r\n await this.client.lcServiceInstance.get(\r\n `file-processing-configurations/${fileProcessingConfigurationId}/file-type-settings/${fileTypeSettingId}`,\r\n { params }\r\n )\r\n ).data;\r\n };\r\n\r\n /** Retrieves a list of all the file type settings in a file processing configuration. */\r\n listFileTypeSettings = async (fileProcessingConfigurationId: string, params?: FieldsParams): Promise<FileTypeSettingListResponse> => {\r\n return (\r\n await this.client.lcServiceInstance.get(`file-processing-configurations/${fileProcessingConfigurationId}/file-type-settings`, {\r\n params,\r\n })\r\n ).data;\r\n };\r\n}\r\n","import LanguageCloudClient from '../core/lcClient';\r\nimport { FieldsParams } from '../models/commonModel';\r\nimport { Folder, FolderListRequestParams, FolderListResponse } from '../models/folderModel';\r\n\r\nexport class FolderService {\r\n private readonly client: LanguageCloudClient;\r\n constructor(client: LanguageCloudClient) {\r\n this.client = client;\r\n }\r\n\r\n /** Retrieves a list of all the folders in an account. Max 500. */\r\n getFolders = async (params?: FolderListRequestParams): Promise<FolderListResponse> => {\r\n return (await this.client.lcServiceInstance.get('folders', { params })).data;\r\n };\r\n\r\n /** Retrieves a folder by identifier. */\r\n getFolder = async (folderId: string, params?: FieldsParams): Promise<Folder> => {\r\n return (await this.client.lcServiceInstance.get(`folders/${folderId}`, { params })).data;\r\n };\r\n\r\n /** Retrieves the Root folder in the account. */\r\n getRootFolder = async (params?: FieldsParams): Promise<Folder> => {\r\n return (await this.client.lcServiceInstance.get('folders/root', { params })).data;\r\n };\r\n}\r\n","import LanguageCloudClient from '../core/lcClient';\r\nimport { FieldsParams } from '../models/commonModel';\r\nimport { Group, GroupListRequestParams, GroupListResponse } from '../models/groupModel';\r\n\r\nexport class GroupService {\r\n private readonly client: LanguageCloudClient;\r\n constructor(client: LanguageCloudClient) {\r\n this.client = client;\r\n }\r\n\r\n /** Retrieves a list of all the groups in an account. */\r\n getGroups = async (params?: GroupListRequestParams): Promise<GroupListResponse> => {\r\n return (await this.client.lcServiceInstance.get('groups', { params })).data;\r\n };\r\n\r\n /** Retrieves a group by identifier. */\r\n getGroup = async (groupId: string, params?: FieldsParams): Promise<Group> => {\r\n return (await this.client.lcServiceInstance.get(`groups/${groupId}`, { params })).data;\r\n };\r\n}\r\n","import LanguageCloudClient from '../core/lcClient';\r\nimport { PollUploadZipFileResponse, UploadZipFileResponse } from '../models/fileModel';\r\n\r\nexport class FileService {\r\n private readonly client: LanguageCloudClient;\r\n constructor(client: LanguageCloudClient) {\r\n this.client = client;\r\n }\r\n\r\n /**\r\n * Uploads an archive with source files in a .zip format, to be extracted and used at project creation.\r\n *\r\n * 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.\r\n */\r\n uploadZipFile = async (formData: FormData): Promise<UploadZipFileResponse> => {\r\n const headers = { ...this.client.getHeaders() };\r\n headers['Content-Type'] = 'multipart/form-data';\r\n\r\n return (await this.client.lcServiceInstance.post('files', formData, { headers })).data;\r\n };\r\n\r\n /**\r\n * Monitors the unzipping operation for a previously uploaded archive and gets details on the extracted files.\r\n */\r\n pollUploadZipFile = async (fileId: string): Promise<PollUploadZipFileResponse> => {\r\n return (await this.client.lcServiceInstance.get(`files/${fileId}`)).data;\r\n };\r\n}\r\n","import LanguageCloudClient from '../core/lcClient';\r\nimport { FieldsParams } from '../models/commonModel';\r\nimport {\r\n LanguageProcessingRule,\r\n LanguageProcessingRulesListRequestParams,\r\n LanguageProcessingRulesListResponse,\r\n} from '../models/languageProcessingModel';\r\n\r\nexport class LanguageProcessingService {\r\n private readonly client: LanguageCloudClient;\r\n constructor(client: LanguageCloudClient) {\r\n this.client = client;\r\n }\r\n\r\n /** Returns a list of Language Processing Rules. */\r\n getLanguageProcessingRules = async (\r\n params?: LanguageProcessingRulesListRequestParams\r\n ): Promise<LanguageProcessingRulesListResponse> => {\r\n return (await this.client.lcServiceInstance.get('language-processing-rules', { params })).data;\r\n };\r\n\r\n /** Returns a Language Processing Rule by identifier. */\r\n getLanguageProcessingRule = async (languageProcessingRuleId: string, params?: FieldsParams): Promise<LanguageProcessingRule> => {\r\n return (await this.client.lcServiceInstance.get(`language-processing-rules/${languageProcessingRuleId}`, { params })).data;\r\n };\r\n}\r\n","import LanguageCloudClient from '../core/lcClient';\r\nimport { MachineTranslationsListRequestParams, MachineTranslationsListResponse } from '../models/machineTranslationModel';\r\n\r\nexport class MachineTranslationService {\r\n private readonly client: LanguageCloudClient;\r\n constructor(client: LanguageCloudClient) {\r\n this.client = client;\r\n }\r\n\r\n /** Retrieves a list of machine translations that can be used in a translation engine. */\r\n getMachineTranslations = async (params: MachineTranslationsListRequestParams): Promise<MachineTranslationsListResponse> => {\r\n return (await this.client.lcServiceInstance.get('machine-translation', { params })).data;\r\n };\r\n}\r\n","import LanguageCloudClient from '../core/lcClient';\r\nimport { FieldsParams } from '../models/commonModel';\r\nimport { PricingModel, PricingModelsListRequestParams, PricingModelsListResponse } from '../models/pricingModel';\r\n\r\nexport class PricingModelService {\r\n private readonly client: LanguageCloudClient;\r\n constructor(client: LanguageCloudClient) {\r\n this.client = client;\r\n }\r\n\r\n /** Retrieves a list of all the pricing models in an account.\r\n *\r\n * Sorting is supported for the following fields: `name`, `description`, `currencyCode` and `location`. */\r\n getPricingModels = async (params?: PricingModelsListRequestParams): Promise<PricingModelsListResponse> => {\r\n return (await this.client.lcServiceInstance.get('pricing-models', { params })).data;\r\n };\r\n\r\n /** Retrieves a pricing model by identifier. */\r\n getPricingModel = async (pricingModelId: string, params?: FieldsParams): Promise<PricingModel> => {\r\n return (await this.client.lcServiceInstance.get(`pricing-models/${pricingModelId}`, { params })).data;\r\n };\r\n}\r\n","import LanguageCloudClient from '../core/lcClient';\r\nimport { FieldsParams } from '../models/commonModel';\r\nimport {\r\n ProjectGroup,\r\n ProjectGroupCreateRequestPayload,\r\n ProjectGroupsListRequestParams,\r\n ProjectGroupsListResponse,\r\n ProjectGroupUpdateRequestPayload,\r\n AddProjectToGroupRequestPayload,\r\n RemoveProjectFromGroupRequestPayload,\r\n} from '../models/projectGroupModel';\r\n\r\nexport class ProjectGroupService {\r\n private readonly client: LanguageCloudClient;\r\n constructor(client: LanguageCloudClient) {\r\n this.client = client;\r\n }\r\n\r\n /** Retrieves a list of all the project groups in an account. */\r\n getProjectGroups = async (params?: ProjectGroupsListRequestParams): Promise<ProjectGroupsListResponse> => {\r\n return (await this.client.lcServiceInstance.get('project-groups', { params })).data;\r\n };\r\n\r\n /** Retrieves a project group by identifier. */\r\n getProjectGroup = async (projectGroupId: string, params?: FieldsParams): Promise<ProjectGroup> => {\r\n return (await this.client.lcServiceInstance.get(`project-groups/${projectGroupId}`, { params })).data;\r\n };\r\n\r\n /** Creates a new project group. */\r\n createProjectGroup = async (payload: ProjectGroupCreateRequestPayload, params?: FieldsParams): Promise<ProjectGroup> => {\r\n return (await this.client.lcServiceInstance.post('project-groups', payload, { params })).data;\r\n };\r\n\r\n /** Updates the project group. */\r\n updateProjectGroup = async (projectGroupId: string, payload: ProjectGroupUpdateRequestPayload): Promise<void> => {\r\n return (await this.client.lcServiceInstance.put(`