TypesRestMem is a TypeScript REST client for RemoteTM servers. It speaks RemoteTM's existing, open REST API — ticket-based authentication, memory management, TU search/storage, TMX import/export — from any Node/TypeScript application. RemoteTM itself is unchanged.
npm install typesrestmemimport{RestMemory,RemoteUtils}from"typesrestmem";constticket=awaitRemoteUtils.getTicket("https://tm.example.com","user","password");constmemories=awaitRemoteUtils.getRemoteMemories("https://tm.example.com",ticket);consttm=awaitRestMemory.open("https://tm.example.com","user","password","myMemory");constmatches=awaittm.searchTranslation("Hello world","en-US","es-ES",70);for(constmatchofmatches){console.log(match.similarity+"% - "+match.target.toString());}awaittm.close();RestMemory.open(server, user, password, memoryName) authenticates, opens the named memory, and returns a ready-to-use instance. Every instance method returns a Promise, since every call is a network round trip:
| Method | REST command |
|---|---|
close() | closeMemory |
deleteDatabase() | removeMemory |
commit() | commit |
searchTranslation(text, srcLang, tgtLang, similarity, caseSensitive?) | searchTranslation |
searchAll(text, srcLang, similarity, caseSensitive?) | searchAll |
concordanceSearch(text, srcLang, limit?, isRegexp?, caseSensitive?) | concordanceSearch |
storeTu(tu) | storeTu |
getTu(tuid) | getTu |
removeTu(tuid) | removeTu |
getAllClients() / getAllLanguages() / getAllProjects() / getAllSubjects() | memoryClients / memoryLanguages / memoryProjects / memorySubjects |
storeTMX(tmxFile, project?, subject?, client?) | zips the file, uploads it, then importTMX |
exportMemory(tmxFile, langs, srcLang) | exportMemory, then downloads the resulting file |
batchTranslate(params) | batchTranslate |
RemoteUtils.getTicket(server, user, password) and RemoteUtils.getRemoteMemories(server, ticket) are the two calls needed before a memory is opened — a "browse remote server, pick a memory" flow.
searchTranslation returns Match[] ({ id, source, target, origin, type, similarity, properties }) — the shared type from typesmatch, imported from there directly:
importtype{Match}from"typesmatch";Eclipse Public License 1.0 — see LICENSE.