@translated/lara 2.0.0-beta.7 → 2.0.0-beta.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.d.mts +238 -0
- package/lib/index.d.ts +238 -3
- package/lib/index.js +2 -3
- package/lib/index.js.map +1 -0
- package/lib/index.mjs +2 -0
- package/lib/index.mjs.map +1 -0
- package/package.json +10 -5
- package/lib/Documents.d.ts +0 -12
- package/lib/Documents.js +0 -82
- package/lib/Glossaries.d.ts +0 -17
- package/lib/Glossaries.js +0 -78
- package/lib/Memories.d.ts +0 -18
- package/lib/Memories.js +0 -95
- package/lib/Translator.d.ts +0 -24
- package/lib/Translator.js +0 -151
- package/lib/models/Authentication.d.ts +0 -15
- package/lib/models/Authentication.js +0 -1
- package/lib/models/UploadableFile.d.ts +0 -2
- package/lib/models/UploadableFile.js +0 -1
- package/lib/models/documents.d.ts +0 -51
- package/lib/models/documents.js +0 -10
- package/lib/models/glossaries.d.ts +0 -19
- package/lib/models/glossaries.js +0 -1
- package/lib/models/index.d.ts +0 -6
- package/lib/models/index.js +0 -6
- package/lib/models/memories.d.ts +0 -19
- package/lib/models/memories.js +0 -1
- package/lib/models/translator.d.ts +0 -48
- package/lib/models/translator.js +0 -1
- package/lib/sdk-version.d.ts +0 -1
- package/lib/sdk-version.js +0 -1
- package/lib/utils/errors.d.ts +0 -10
- package/lib/utils/errors.js +0 -12
- package/lib/utils/formdata/browser.d.ts +0 -2
- package/lib/utils/formdata/browser.js +0 -15
- package/lib/utils/formdata/index.d.ts +0 -4
- package/lib/utils/formdata/index.js +0 -10
- package/lib/utils/formdata/node.d.ts +0 -5
- package/lib/utils/formdata/node.js +0 -16
- package/lib/utils/isNode.d.ts +0 -2
- package/lib/utils/isNode.js +0 -1
- package/lib/utils/sleep.d.ts +0 -2
- package/lib/utils/sleep.js +0 -1
- package/lib/utils/toCamelCase.d.ts +0 -2
- package/lib/utils/toCamelCase.js +0 -16
- package/lib/utils/toQueryString.d.ts +0 -2
- package/lib/utils/toQueryString.js +0 -8
- package/lib/utils/toSnakeCase.d.ts +0 -2
- package/lib/utils/toSnakeCase.js +0 -16
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { TranslationStyle } from './translator';
|
|
2
|
-
export interface Document {
|
|
3
|
-
readonly id: string;
|
|
4
|
-
readonly status: DocumentStatus;
|
|
5
|
-
readonly source?: string;
|
|
6
|
-
readonly target: string;
|
|
7
|
-
readonly filename: string;
|
|
8
|
-
readonly createdAt: Date;
|
|
9
|
-
readonly updatedAt: Date;
|
|
10
|
-
readonly options?: DocumentOptions;
|
|
11
|
-
readonly translatedChars?: number;
|
|
12
|
-
readonly totalChars?: number;
|
|
13
|
-
readonly errorReason?: string;
|
|
14
|
-
}
|
|
15
|
-
export declare enum DocumentStatus {
|
|
16
|
-
INITIALIZED = "initialized",// just been created
|
|
17
|
-
ANALYZING = "analyzing",// being analyzed for language detection and chars count
|
|
18
|
-
PAUSED = "paused",// paused after analysis, needs user confirm
|
|
19
|
-
READY = "ready",// ready to be translated
|
|
20
|
-
TRANSLATING = "translating",
|
|
21
|
-
TRANSLATED = "translated",
|
|
22
|
-
ERROR = "error"
|
|
23
|
-
}
|
|
24
|
-
export type DocumentOptions = {
|
|
25
|
-
adaptTo?: string[];
|
|
26
|
-
glossaries?: string[];
|
|
27
|
-
noTrace?: boolean;
|
|
28
|
-
style?: TranslationStyle;
|
|
29
|
-
};
|
|
30
|
-
export type DocumentUploadOptions = DocumentOptions & {
|
|
31
|
-
password?: string;
|
|
32
|
-
extractionParams?: DocxExtractionParams;
|
|
33
|
-
};
|
|
34
|
-
export type DocumentDownloadOptions = {
|
|
35
|
-
outputFormat?: string;
|
|
36
|
-
};
|
|
37
|
-
export type DocumentTranslateOptions = DocumentUploadOptions & DocumentDownloadOptions;
|
|
38
|
-
export interface DocxExtractionParams {
|
|
39
|
-
extractComments?: boolean;
|
|
40
|
-
accepsRevisions?: boolean;
|
|
41
|
-
}
|
|
42
|
-
interface S3UploadFields {
|
|
43
|
-
acl: string;
|
|
44
|
-
bucket: string;
|
|
45
|
-
key: string;
|
|
46
|
-
}
|
|
47
|
-
export interface UploadUrlData {
|
|
48
|
-
url: string;
|
|
49
|
-
fields: S3UploadFields;
|
|
50
|
-
}
|
|
51
|
-
export {};
|
package/lib/models/documents.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export var DocumentStatus;
|
|
2
|
-
(function (DocumentStatus) {
|
|
3
|
-
DocumentStatus["INITIALIZED"] = "initialized";
|
|
4
|
-
DocumentStatus["ANALYZING"] = "analyzing";
|
|
5
|
-
DocumentStatus["PAUSED"] = "paused";
|
|
6
|
-
DocumentStatus["READY"] = "ready";
|
|
7
|
-
DocumentStatus["TRANSLATING"] = "translating";
|
|
8
|
-
DocumentStatus["TRANSLATED"] = "translated";
|
|
9
|
-
DocumentStatus["ERROR"] = "error";
|
|
10
|
-
})(DocumentStatus || (DocumentStatus = {}));
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export interface Glossary {
|
|
2
|
-
readonly id: string;
|
|
3
|
-
readonly name: string;
|
|
4
|
-
readonly ownerId: string;
|
|
5
|
-
readonly createdAt: Date;
|
|
6
|
-
readonly updatedAt: Date;
|
|
7
|
-
}
|
|
8
|
-
export interface GlossaryImport {
|
|
9
|
-
readonly id: string;
|
|
10
|
-
readonly begin: number;
|
|
11
|
-
readonly end: number;
|
|
12
|
-
readonly channel: number;
|
|
13
|
-
readonly size: number;
|
|
14
|
-
readonly progress: number;
|
|
15
|
-
}
|
|
16
|
-
export interface GlossaryCounts {
|
|
17
|
-
unidirectional?: Record<string, number>;
|
|
18
|
-
multidirectional?: number;
|
|
19
|
-
}
|
package/lib/models/glossaries.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/lib/models/index.d.ts
DELETED
package/lib/models/index.js
DELETED
package/lib/models/memories.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export interface Memory {
|
|
2
|
-
readonly id: string;
|
|
3
|
-
readonly createdAt: Date;
|
|
4
|
-
readonly updatedAt: Date;
|
|
5
|
-
readonly sharedAt: Date;
|
|
6
|
-
readonly name: string;
|
|
7
|
-
readonly externalId?: string;
|
|
8
|
-
readonly secret?: string;
|
|
9
|
-
readonly ownerId: string;
|
|
10
|
-
readonly collaboratorsCount: number;
|
|
11
|
-
}
|
|
12
|
-
export interface MemoryImport {
|
|
13
|
-
readonly id: string;
|
|
14
|
-
readonly begin: number;
|
|
15
|
-
readonly end: number;
|
|
16
|
-
readonly channel: number;
|
|
17
|
-
readonly size: number;
|
|
18
|
-
readonly progress: number;
|
|
19
|
-
}
|
package/lib/models/memories.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
export interface TranslatorOptions {
|
|
2
|
-
serverUrl?: string;
|
|
3
|
-
extraHeaders?: Record<string, any>;
|
|
4
|
-
}
|
|
5
|
-
export interface TextBlock {
|
|
6
|
-
readonly text: string;
|
|
7
|
-
readonly translatable?: boolean;
|
|
8
|
-
}
|
|
9
|
-
export type TranslationStyle = 'faithful' | 'fluid' | 'creative';
|
|
10
|
-
export type TranslateOptions = {
|
|
11
|
-
sourceHint?: string;
|
|
12
|
-
adaptTo?: string[];
|
|
13
|
-
instructions?: string[];
|
|
14
|
-
glossaries?: string[];
|
|
15
|
-
contentType?: string;
|
|
16
|
-
multiline?: boolean;
|
|
17
|
-
timeoutInMillis?: number;
|
|
18
|
-
priority?: 'normal' | 'background';
|
|
19
|
-
useCache?: boolean | 'overwrite';
|
|
20
|
-
cacheTTLSeconds?: number;
|
|
21
|
-
noTrace?: boolean;
|
|
22
|
-
verbose?: boolean;
|
|
23
|
-
headers?: Record<string, string>;
|
|
24
|
-
style?: TranslationStyle;
|
|
25
|
-
};
|
|
26
|
-
export interface NGMemoryMatch {
|
|
27
|
-
memory: string;
|
|
28
|
-
tuid?: string;
|
|
29
|
-
language: [string, string];
|
|
30
|
-
sentence: string;
|
|
31
|
-
translation: string;
|
|
32
|
-
score: number;
|
|
33
|
-
}
|
|
34
|
-
export interface NGGlossaryMatch {
|
|
35
|
-
glossary: string;
|
|
36
|
-
language: [string, string];
|
|
37
|
-
term: string;
|
|
38
|
-
translation: string;
|
|
39
|
-
}
|
|
40
|
-
export interface TextResult<T extends string | string[] | TextBlock[]> {
|
|
41
|
-
readonly contentType: string;
|
|
42
|
-
readonly sourceLanguage: string;
|
|
43
|
-
readonly translation: T;
|
|
44
|
-
readonly adaptedTo?: string[];
|
|
45
|
-
readonly glossaries?: string[];
|
|
46
|
-
readonly adaptedToMatches?: NGMemoryMatch[] | NGMemoryMatch[][];
|
|
47
|
-
readonly glossariesMatches?: NGGlossaryMatch[] | NGGlossaryMatch[][];
|
|
48
|
-
}
|
package/lib/models/translator.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/lib/sdk-version.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const version = "2.0.0-beta.6";
|
package/lib/sdk-version.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const version = '2.0.0-beta.6';
|
package/lib/utils/errors.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export declare class LaraError extends Error {
|
|
2
|
-
}
|
|
3
|
-
export declare class LaraTimeoutError extends LaraError {
|
|
4
|
-
}
|
|
5
|
-
export declare class LaraApiError extends LaraError {
|
|
6
|
-
readonly statusCode: number;
|
|
7
|
-
readonly message: string;
|
|
8
|
-
readonly idTransaction: string;
|
|
9
|
-
constructor(statusCode: number, message: string, idTransaction: string);
|
|
10
|
-
}
|
package/lib/utils/errors.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export class LaraError extends Error {
|
|
2
|
-
}
|
|
3
|
-
export class LaraTimeoutError extends LaraError {
|
|
4
|
-
}
|
|
5
|
-
export class LaraApiError extends LaraError {
|
|
6
|
-
constructor(statusCode, message, idTransaction) {
|
|
7
|
-
super(message);
|
|
8
|
-
this.statusCode = statusCode;
|
|
9
|
-
this.message = message;
|
|
10
|
-
this.idTransaction = idTransaction;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export default (data) => {
|
|
2
|
-
const formData = new FormData();
|
|
3
|
-
for (const [key, value] of Object.entries(data)) {
|
|
4
|
-
if (!value)
|
|
5
|
-
continue;
|
|
6
|
-
if (Array.isArray(value)) {
|
|
7
|
-
for (const v of value)
|
|
8
|
-
formData.append(key, v);
|
|
9
|
-
}
|
|
10
|
-
else {
|
|
11
|
-
formData.append(key, value);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
return [formData, {}];
|
|
15
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import FormData from 'form-data';
|
|
2
|
-
export default (data) => {
|
|
3
|
-
const formData = new FormData();
|
|
4
|
-
for (const [key, value] of Object.entries(data)) {
|
|
5
|
-
if (!value)
|
|
6
|
-
continue;
|
|
7
|
-
if (Array.isArray(value)) {
|
|
8
|
-
for (const v of value)
|
|
9
|
-
formData.append(key, v);
|
|
10
|
-
}
|
|
11
|
-
else {
|
|
12
|
-
formData.append(key, value);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
return [formData, { ...formData.getHeaders() }];
|
|
16
|
-
};
|
package/lib/utils/isNode.d.ts
DELETED
package/lib/utils/isNode.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default typeof window === 'undefined';
|
package/lib/utils/sleep.d.ts
DELETED
package/lib/utils/sleep.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default (millis) => new Promise((resolve) => setTimeout(resolve, millis));
|
package/lib/utils/toCamelCase.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
const toCamelCase = (content) => {
|
|
2
|
-
if (typeof content === 'string')
|
|
3
|
-
return content;
|
|
4
|
-
if (Array.isArray(content))
|
|
5
|
-
return content.map(toCamelCase);
|
|
6
|
-
if (typeof content === 'object' && content !== null) {
|
|
7
|
-
const result = {};
|
|
8
|
-
for (const [key, value] of Object.entries(content)) {
|
|
9
|
-
const camelKey = key.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase());
|
|
10
|
-
result[camelKey] = toCamelCase(value);
|
|
11
|
-
}
|
|
12
|
-
return result;
|
|
13
|
-
}
|
|
14
|
-
return content;
|
|
15
|
-
};
|
|
16
|
-
export default toCamelCase;
|
package/lib/utils/toSnakeCase.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
const toSnakeCase = (content) => {
|
|
2
|
-
if (typeof content === 'string')
|
|
3
|
-
return content;
|
|
4
|
-
if (Array.isArray(content))
|
|
5
|
-
return content.map(toSnakeCase);
|
|
6
|
-
if (typeof content === 'object' && content !== null) {
|
|
7
|
-
const result = {};
|
|
8
|
-
for (const [key, value] of Object.entries(content)) {
|
|
9
|
-
const snakeKey = key.replace(/([A-Z])/g, '_$1').toLowerCase();
|
|
10
|
-
result[snakeKey] = toSnakeCase(value);
|
|
11
|
-
}
|
|
12
|
-
return result;
|
|
13
|
-
}
|
|
14
|
-
return content;
|
|
15
|
-
};
|
|
16
|
-
export default toSnakeCase;
|