typesrestmem
v0.1.0
Published
TypeScript REST client for RemoteTM servers
Downloads
26
Maintainers
Readme
TypesRestMem
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.
Installation
npm install typesrestmemQuick start
import { RestMemory, RemoteUtils } from "typesrestmem";
const ticket = await RemoteUtils.getTicket("https://tm.example.com", "user", "password");
const memories = await RemoteUtils.getRemoteMemories("https://tm.example.com", ticket);
const tm = await RestMemory.open("https://tm.example.com", "user", "password", "myMemory");
const matches = await tm.searchTranslation("Hello world", "en-US", "es-ES", 70);
for (const match of matches) {
console.log(match.similarity + "% - " + match.target.toString());
}
await tm.close();API
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:
import type { Match } from "typesmatch";License
Eclipse Public License 1.0 — see LICENSE.
