generaltranslation 7.6.4-alpha.1 → 7.6.4
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/CHANGELOG.md +6 -0
- package/dist/backwards-compatability/dataConversion.d.ts +23 -0
- package/dist/backwards-compatability/oldHashJsxChildren.d.ts +23 -0
- package/dist/backwards-compatability/oldTypes.d.ts +21 -0
- package/dist/backwards-compatability/typeChecking.d.ts +21 -0
- package/dist/cache/IntlCache.d.ts +8 -0
- package/dist/deprecated/batch/translateBatch.d.ts +1 -0
- package/dist/deprecated/icu/translate.d.ts +1 -0
- package/dist/deprecated/jsx/translateJsx.d.ts +1 -0
- package/dist/deprecated/translate/translate.d.ts +1 -0
- package/dist/formatting/format.d.ts +1 -0
- package/dist/id/hashSource.d.ts +26 -0
- package/dist/id/hashTemplate.d.ts +4 -0
- package/dist/id.cjs.min.cjs.map +1 -1
- package/dist/id.esm.min.mjs.map +1 -1
- package/dist/index.cjs.min.cjs.map +1 -1
- package/dist/index.esm.min.mjs.map +1 -1
- package/dist/internal.cjs.min.cjs.map +1 -1
- package/dist/internal.esm.min.mjs.map +1 -1
- package/dist/locales/customLocaleMapping.d.ts +5 -0
- package/dist/locales/determineLocale.d.ts +1 -0
- package/dist/locales/getLocaleDirection.d.ts +1 -0
- package/dist/locales/getLocaleEmoji.d.ts +2 -0
- package/dist/locales/getLocaleName.d.ts +1 -0
- package/dist/locales/getLocaleProperties.d.ts +32 -0
- package/dist/locales/getPluralForm.d.ts +9 -0
- package/dist/locales/getRegionProperties.d.ts +7 -0
- package/dist/locales/isSameDialect.d.ts +1 -0
- package/dist/locales/isSameLanguage.d.ts +1 -0
- package/dist/locales/isSupersetLocale.d.ts +1 -0
- package/dist/locales/isValidLocale.d.ts +1 -0
- package/dist/locales/requiresTranslation.d.ts +1 -0
- package/dist/locales/resolveAliasLocale.d.ts +8 -0
- package/dist/logging/errors.d.ts +10 -0
- package/dist/logging/logger.d.ts +117 -0
- package/dist/logging/warnings.d.ts +2 -0
- package/dist/projects/getProjectData.d.ts +1 -0
- package/dist/settings/plurals.d.ts +3 -0
- package/dist/settings/settings.d.ts +2 -0
- package/dist/settings/settingsUrls.d.ts +9 -0
- package/dist/translate/checkFileTranslations.d.ts +1 -0
- package/dist/translate/checkSetupStatus.d.ts +8 -0
- package/dist/translate/checkTranslationStatus.d.ts +1 -0
- package/dist/translate/downloadFile.d.ts +1 -0
- package/dist/translate/downloadFileBatch.d.ts +1 -0
- package/dist/translate/enqueueEntries.d.ts +1 -0
- package/dist/translate/enqueueFiles.d.ts +9 -0
- package/dist/translate/fetchTranslations.d.ts +1 -0
- package/dist/translate/querySourceFile.d.ts +1 -0
- package/dist/translate/setupProject.d.ts +4 -0
- package/dist/translate/shouldSetupProject.d.ts +3 -0
- package/dist/translate/translate.d.ts +1 -0
- package/dist/translate/translateMany.d.ts +1 -0
- package/dist/translate/uploadSourceFiles.d.ts +1 -0
- package/dist/translate/uploadTranslations.d.ts +1 -0
- package/dist/translate/utils/fetchWithTimeout.d.ts +1 -0
- package/dist/translate/utils/generateRequestHeaders.d.ts +2 -0
- package/dist/translate/utils/handleFetchError.d.ts +1 -0
- package/dist/translate/utils/validateResponse.d.ts +1 -0
- package/dist/types-dir/checkFileTranslations.d.ts +40 -0
- package/dist/types-dir/content.d.ts +49 -0
- package/dist/types-dir/downloadFile.d.ts +3 -0
- package/dist/types-dir/downloadFileBatch.d.ts +22 -0
- package/dist/types-dir/enqueueEntries.d.ts +21 -0
- package/dist/types-dir/enqueueFiles.d.ts +62 -0
- package/dist/types-dir/entry.d.ts +39 -0
- package/dist/types-dir/fetchTranslations.d.ts +11 -0
- package/dist/types-dir/file.d.ts +23 -0
- package/dist/types-dir/project.d.ts +7 -0
- package/dist/types-dir/translate.d.ts +34 -0
- package/dist/types-dir/translateMany.d.ts +5 -0
- package/dist/types-dir/translationStatus.d.ts +9 -0
- package/dist/types-dir/uploadFiles.d.ts +38 -0
- package/dist/types-dir/variables.d.ts +9 -0
- package/dist/utils/base64.d.ts +2 -0
- package/dist/utils/isVariable.d.ts +2 -0
- package/dist/utils/minify.d.ts +2 -0
- package/package.json +2 -2
@@ -0,0 +1,117 @@
|
|
1
|
+
/**
|
2
|
+
* Comprehensive logging system for the General Translation library
|
3
|
+
* Provides structured logging with multiple levels and configurable output
|
4
|
+
*/
|
5
|
+
export type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'off';
|
6
|
+
export interface LogEntry {
|
7
|
+
level: LogLevel;
|
8
|
+
message: string;
|
9
|
+
timestamp: Date;
|
10
|
+
context?: string;
|
11
|
+
metadata?: Record<string, any>;
|
12
|
+
}
|
13
|
+
export interface LoggerConfig {
|
14
|
+
/** Minimum log level to output */
|
15
|
+
level: LogLevel;
|
16
|
+
/** Whether to include timestamps in log output */
|
17
|
+
includeTimestamp: boolean;
|
18
|
+
/** Whether to include context information */
|
19
|
+
includeContext: boolean;
|
20
|
+
/** Custom prefix for all log messages */
|
21
|
+
prefix?: string;
|
22
|
+
/** Whether to output to console (default: true) */
|
23
|
+
enableConsole: boolean;
|
24
|
+
/** Custom log handlers */
|
25
|
+
handlers?: LogHandler[];
|
26
|
+
}
|
27
|
+
export interface LogHandler {
|
28
|
+
handle(entry: LogEntry): void;
|
29
|
+
}
|
30
|
+
/**
|
31
|
+
* Console log handler that outputs formatted messages to console
|
32
|
+
*/
|
33
|
+
export declare class ConsoleLogHandler implements LogHandler {
|
34
|
+
private config;
|
35
|
+
constructor(config: LoggerConfig);
|
36
|
+
handle(entry: LogEntry): void;
|
37
|
+
}
|
38
|
+
/**
|
39
|
+
* Main Logger class providing structured logging capabilities
|
40
|
+
*/
|
41
|
+
export declare class Logger {
|
42
|
+
private config;
|
43
|
+
private handlers;
|
44
|
+
constructor(config?: Partial<LoggerConfig>);
|
45
|
+
/**
|
46
|
+
* Add a custom log handler
|
47
|
+
*/
|
48
|
+
addHandler(handler: LogHandler): void;
|
49
|
+
/**
|
50
|
+
* Remove a log handler
|
51
|
+
*/
|
52
|
+
removeHandler(handler: LogHandler): void;
|
53
|
+
/**
|
54
|
+
* Update logger configuration
|
55
|
+
*/
|
56
|
+
configure(config: Partial<LoggerConfig>): void;
|
57
|
+
/**
|
58
|
+
* Check if a log level should be output based on current configuration
|
59
|
+
*/
|
60
|
+
private shouldLog;
|
61
|
+
/**
|
62
|
+
* Internal logging method that creates log entries and passes them to handlers
|
63
|
+
*/
|
64
|
+
private log;
|
65
|
+
/**
|
66
|
+
* Log a debug message
|
67
|
+
* Used for detailed diagnostic information, typically of interest only when diagnosing problems
|
68
|
+
*/
|
69
|
+
debug(message: string, context?: string, metadata?: Record<string, any>): void;
|
70
|
+
/**
|
71
|
+
* Log an info message
|
72
|
+
* Used for general information about application operation
|
73
|
+
*/
|
74
|
+
info(message: string, context?: string, metadata?: Record<string, any>): void;
|
75
|
+
/**
|
76
|
+
* Log a warning message
|
77
|
+
* Used for potentially problematic situations that don't prevent operation
|
78
|
+
*/
|
79
|
+
warn(message: string, context?: string, metadata?: Record<string, any>): void;
|
80
|
+
/**
|
81
|
+
* Log an error message
|
82
|
+
* Used for error events that might still allow the application to continue
|
83
|
+
*/
|
84
|
+
error(message: string, context?: string, metadata?: Record<string, any>): void;
|
85
|
+
/**
|
86
|
+
* Create a child logger with a specific context
|
87
|
+
*/
|
88
|
+
child(context: string): ContextLogger;
|
89
|
+
/**
|
90
|
+
* Get current logger configuration
|
91
|
+
*/
|
92
|
+
getConfig(): LoggerConfig;
|
93
|
+
}
|
94
|
+
/**
|
95
|
+
* Context logger that automatically includes context information
|
96
|
+
*/
|
97
|
+
export declare class ContextLogger {
|
98
|
+
private logger;
|
99
|
+
private context;
|
100
|
+
constructor(logger: Logger, context: string);
|
101
|
+
debug(message: string, metadata?: Record<string, any>): void;
|
102
|
+
info(message: string, metadata?: Record<string, any>): void;
|
103
|
+
warn(message: string, metadata?: Record<string, any>): void;
|
104
|
+
error(message: string, metadata?: Record<string, any>): void;
|
105
|
+
child(childContext: string): ContextLogger;
|
106
|
+
}
|
107
|
+
export declare const defaultLogger: Logger;
|
108
|
+
export declare const debug: (message: string, context?: string, metadata?: Record<string, any>) => void;
|
109
|
+
export declare const info: (message: string, context?: string, metadata?: Record<string, any>) => void;
|
110
|
+
export declare const warn: (message: string, context?: string, metadata?: Record<string, any>) => void;
|
111
|
+
export declare const error: (message: string, context?: string, metadata?: Record<string, any>) => void;
|
112
|
+
export declare const fetchLogger: ContextLogger;
|
113
|
+
export declare const validationLogger: ContextLogger;
|
114
|
+
export declare const formattingLogger: ContextLogger;
|
115
|
+
export declare const localeLogger: ContextLogger;
|
116
|
+
export declare const gtInstanceLogger: ContextLogger;
|
117
|
+
export { Logger as GTLogger };
|
@@ -0,0 +1,2 @@
|
|
1
|
+
export declare const formatI18nextWarning = "Warning: formatI18next is not currently supported but will be implemented in a future version. Use _formatMessage for current ICU message format support.";
|
2
|
+
export declare const formatJsxWarning = "Warning: formatJsx is not currently supported but will be implemented in a future version. Use _formatMessage for current ICU message format support.";
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,9 @@
|
|
1
|
+
export declare const defaultCacheUrl: "https://cdn.gtx.dev";
|
2
|
+
export declare const defaultBaseUrl: "https://api2.gtx.dev";
|
3
|
+
export declare const defaultRuntimeApiUrl: "https://runtime2.gtx.dev";
|
4
|
+
export declare const translateBatchUrl: "/v1/translate/batch";
|
5
|
+
export declare const translateJsxUrl: "/v1/translate/react";
|
6
|
+
export declare const translateContentUrl: "/v1/translate/content";
|
7
|
+
export declare const translateIcuUrl: "/v1/translate/icu";
|
8
|
+
export declare const updateProjectTranslationsUrl: "/v1/project/translations/update";
|
9
|
+
export declare const getProjectLocalesUrl: "/v1/project/locales";
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1 @@
|
|
1
|
+
export default function handleFetchError(error: unknown, timeout: number): never;
|
@@ -0,0 +1 @@
|
|
1
|
+
export default function validateResponse(response: Response): Promise<void>;
|
@@ -0,0 +1,40 @@
|
|
1
|
+
import { CompletedFileTranslationData } from './file';
|
2
|
+
export type FileTranslationQuery = {
|
3
|
+
versionId: string;
|
4
|
+
fileName?: string;
|
5
|
+
fileId?: string;
|
6
|
+
locale: string;
|
7
|
+
};
|
8
|
+
export type CheckFileTranslationsOptions = {
|
9
|
+
timeout?: number;
|
10
|
+
};
|
11
|
+
export type CheckFileTranslationsResult = {
|
12
|
+
translations: CompletedFileTranslationData[];
|
13
|
+
};
|
14
|
+
export type FileQuery = {
|
15
|
+
fileId: string;
|
16
|
+
versionId?: string;
|
17
|
+
};
|
18
|
+
export type FileQueryResult = {
|
19
|
+
sourceFile: {
|
20
|
+
id: string;
|
21
|
+
fileId: string;
|
22
|
+
versionId: string;
|
23
|
+
sourceLocale: string;
|
24
|
+
fileName: string;
|
25
|
+
fileFormat: string;
|
26
|
+
dataFormat: string | null;
|
27
|
+
createdAt: string;
|
28
|
+
updatedAt: string;
|
29
|
+
approvalRequiredAt: string | null;
|
30
|
+
locales: string[];
|
31
|
+
};
|
32
|
+
translations: {
|
33
|
+
locale: string;
|
34
|
+
completedAt: string | null;
|
35
|
+
approvedAt: string | null;
|
36
|
+
publishedAt: string | null;
|
37
|
+
createdAt: string | null;
|
38
|
+
updatedAt: string | null;
|
39
|
+
}[];
|
40
|
+
};
|
@@ -0,0 +1,49 @@
|
|
1
|
+
import { Variable } from './variables';
|
2
|
+
/**
|
3
|
+
* Map of data-_gt properties to their corresponding React props
|
4
|
+
*/
|
5
|
+
export declare const HTML_CONTENT_PROPS: {
|
6
|
+
readonly pl: "placeholder";
|
7
|
+
readonly ti: "title";
|
8
|
+
readonly alt: "alt";
|
9
|
+
readonly arl: "aria-label";
|
10
|
+
readonly arb: "aria-labelledby";
|
11
|
+
readonly ard: "aria-describedby";
|
12
|
+
};
|
13
|
+
export type HtmlContentPropKeysRecord = Partial<Record<keyof typeof HTML_CONTENT_PROPS, string>>;
|
14
|
+
export type HtmlContentPropValuesRecord = Partial<Record<(typeof HTML_CONTENT_PROPS)[keyof typeof HTML_CONTENT_PROPS], string>>;
|
15
|
+
/**
|
16
|
+
* GTProp is an internal property used to contain data for translating and rendering elements.
|
17
|
+
* note, transformations are only read on the server side if they are 'plural' or 'branch'
|
18
|
+
*/
|
19
|
+
export type GTProp = {
|
20
|
+
b?: Record<string, JsxChildren>;
|
21
|
+
t?: 'p' | 'b';
|
22
|
+
} & HtmlContentPropKeysRecord;
|
23
|
+
export type JsxElement = {
|
24
|
+
t?: string;
|
25
|
+
i?: number;
|
26
|
+
d?: GTProp;
|
27
|
+
c?: JsxChildren;
|
28
|
+
};
|
29
|
+
export type JsxChild = string | JsxElement | Variable;
|
30
|
+
/**
|
31
|
+
* The format of the content
|
32
|
+
*/
|
33
|
+
export type DataFormat = 'JSX' | 'ICU' | 'I18NEXT';
|
34
|
+
/**
|
35
|
+
* A content type representing JSX, ICU, and I18next messages
|
36
|
+
*/
|
37
|
+
export type Content = JsxChildren | IcuMessage | I18nextMessage;
|
38
|
+
/**
|
39
|
+
* A content type representing JSX elements
|
40
|
+
*/
|
41
|
+
export type JsxChildren = JsxChild | JsxChild[];
|
42
|
+
/**
|
43
|
+
* A content type representing ICU messages
|
44
|
+
*/
|
45
|
+
export type IcuMessage = string;
|
46
|
+
/**
|
47
|
+
* A content type representing I18next messages
|
48
|
+
*/
|
49
|
+
export type I18nextMessage = string;
|
@@ -0,0 +1,22 @@
|
|
1
|
+
export type DownloadFileBatchOptions = {
|
2
|
+
timeout?: number;
|
3
|
+
};
|
4
|
+
export type BatchDownloadResult = {
|
5
|
+
translationId: string;
|
6
|
+
fileName?: string;
|
7
|
+
success: boolean;
|
8
|
+
content?: string;
|
9
|
+
contentType?: string;
|
10
|
+
error?: string;
|
11
|
+
};
|
12
|
+
type File = {
|
13
|
+
id: string;
|
14
|
+
fileName: string;
|
15
|
+
data: string;
|
16
|
+
metadata: any;
|
17
|
+
};
|
18
|
+
export type DownloadFileBatchResult = {
|
19
|
+
files: File[];
|
20
|
+
count: number;
|
21
|
+
};
|
22
|
+
export {};
|
@@ -0,0 +1,21 @@
|
|
1
|
+
import { DataFormat } from './content';
|
2
|
+
export type { Updates } from './enqueueFiles';
|
3
|
+
export type EnqueueEntriesOptions = {
|
4
|
+
timeout?: number;
|
5
|
+
sourceLocale?: string;
|
6
|
+
targetLocales?: string[];
|
7
|
+
dataFormat?: DataFormat;
|
8
|
+
version?: string;
|
9
|
+
description?: string;
|
10
|
+
requireApproval?: boolean;
|
11
|
+
modelProvider?: string;
|
12
|
+
};
|
13
|
+
export type EnqueueEntriesResult = {
|
14
|
+
versionId: string;
|
15
|
+
locales: string[];
|
16
|
+
message: string;
|
17
|
+
projectSettings: {
|
18
|
+
cdnEnabled: boolean;
|
19
|
+
requireApproval: boolean;
|
20
|
+
};
|
21
|
+
};
|
@@ -0,0 +1,62 @@
|
|
1
|
+
import { DataFormat, JsxChildren } from './content';
|
2
|
+
import { CompletedFileTranslationData, FileFormat } from './file';
|
3
|
+
export type Updates = ({
|
4
|
+
metadata: Record<string, any>;
|
5
|
+
} & ({
|
6
|
+
dataFormat: 'JSX';
|
7
|
+
source: JsxChildren;
|
8
|
+
} | {
|
9
|
+
dataFormat: 'ICU';
|
10
|
+
source: string;
|
11
|
+
} | {
|
12
|
+
dataFormat: 'I18NEXT';
|
13
|
+
source: string;
|
14
|
+
}))[];
|
15
|
+
/**
|
16
|
+
* File object structure for enqueueing files
|
17
|
+
* @param content - Content of the file
|
18
|
+
* @param fileName - Unique identifier for the file (such as the file path + file name)
|
19
|
+
* @param fileFormat - The format of the file (JSON, MDX, MD, etc.)
|
20
|
+
* @param formatMetadata - Optional metadata for the file, specific to the format of the file
|
21
|
+
* @param dataFormat - Optional format of the data within the file
|
22
|
+
*/
|
23
|
+
export type FileToTranslate = {
|
24
|
+
content: string;
|
25
|
+
fileName: string;
|
26
|
+
fileFormat: FileFormat;
|
27
|
+
formatMetadata?: Record<string, any>;
|
28
|
+
dataFormat?: DataFormat;
|
29
|
+
};
|
30
|
+
/**
|
31
|
+
* Options for enqueueing files
|
32
|
+
* @param publish - Whether to publish the files
|
33
|
+
* @param requireApproval - Whether to require approval for the files
|
34
|
+
* @param description - Optional description for the project
|
35
|
+
* @param sourceLocale - The project's source locale
|
36
|
+
* @param targetLocales - The locales to translate the files to
|
37
|
+
* @param version - Optional custom version ID to specify
|
38
|
+
* @param timeout - Optional timeout for the request
|
39
|
+
* @param modelProvider - Optional model provider to use
|
40
|
+
*/
|
41
|
+
export type EnqueueFilesOptions = {
|
42
|
+
publish?: boolean;
|
43
|
+
requireApproval?: boolean;
|
44
|
+
description?: string;
|
45
|
+
sourceLocale?: string;
|
46
|
+
targetLocales: string[];
|
47
|
+
version?: string;
|
48
|
+
_versionId?: string;
|
49
|
+
timeout?: number;
|
50
|
+
modelProvider?: string;
|
51
|
+
force?: boolean;
|
52
|
+
};
|
53
|
+
export type RequiredEnqueueFilesOptions = EnqueueFilesOptions & Required<Pick<EnqueueFilesOptions, 'sourceLocale'>>;
|
54
|
+
export type EnqueueFilesResult = {
|
55
|
+
translations: CompletedFileTranslationData[];
|
56
|
+
data: Record<string, {
|
57
|
+
fileName: string;
|
58
|
+
versionId: string;
|
59
|
+
}>;
|
60
|
+
locales: string[];
|
61
|
+
message: string;
|
62
|
+
};
|
@@ -0,0 +1,39 @@
|
|
1
|
+
import { Content, DataFormat } from '../types';
|
2
|
+
/**
|
3
|
+
* ActionType is the type of action to perform on the request.
|
4
|
+
*
|
5
|
+
* @param standard - The standard action type (standard model).
|
6
|
+
* @param fast - The fast action type (mini model).
|
7
|
+
* @param string - Other model
|
8
|
+
*/
|
9
|
+
export type ActionType = 'standard' | 'fast' | string;
|
10
|
+
/**
|
11
|
+
* EntryMetadata is the metadata for a GTRequest.
|
12
|
+
*
|
13
|
+
* @param context - The context of the request.
|
14
|
+
* @param id - The id of the request.
|
15
|
+
* @param hash - The hash of the request.
|
16
|
+
*/
|
17
|
+
export type EntryMetadata = {
|
18
|
+
context?: string;
|
19
|
+
id?: string;
|
20
|
+
hash?: string;
|
21
|
+
dataFormat?: DataFormat;
|
22
|
+
sourceLocale?: string;
|
23
|
+
actionType?: ActionType;
|
24
|
+
timeout?: number;
|
25
|
+
regionCode?: string;
|
26
|
+
scriptCode?: string;
|
27
|
+
};
|
28
|
+
/**
|
29
|
+
* GTRequest is a translation request object for {@link JsxChildren} | {@link IcuMessage} | {@link I18nextMessage}
|
30
|
+
*
|
31
|
+
* @param source - The source content to translate.
|
32
|
+
* @param targetLocale - The target locale to translate to.
|
33
|
+
* @param metadata - The metadata for the request.
|
34
|
+
*/
|
35
|
+
export type Entry = {
|
36
|
+
source: Content;
|
37
|
+
targetLocale?: string;
|
38
|
+
metadata?: EntryMetadata;
|
39
|
+
};
|
@@ -0,0 +1,11 @@
|
|
1
|
+
export type FetchTranslationsOptions = {
|
2
|
+
timeout?: number;
|
3
|
+
};
|
4
|
+
export type RetrievedTranslation = {
|
5
|
+
locale: string;
|
6
|
+
translation: any;
|
7
|
+
};
|
8
|
+
export type RetrievedTranslations = RetrievedTranslation[];
|
9
|
+
export type FetchTranslationsResult = {
|
10
|
+
translations: RetrievedTranslations;
|
11
|
+
};
|
@@ -0,0 +1,23 @@
|
|
1
|
+
import { Entry } from './entry';
|
2
|
+
export type FileFormat = 'GTJSON' | 'JSON' | 'YAML' | 'MDX' | 'MD' | 'TS' | 'JS' | 'HTML';
|
3
|
+
export type FileMetadata = {
|
4
|
+
filePath: string;
|
5
|
+
fileFormat: FileFormat;
|
6
|
+
context?: string;
|
7
|
+
sourceLocale?: string;
|
8
|
+
hash?: string;
|
9
|
+
};
|
10
|
+
export type File = {
|
11
|
+
source: Entry[] | string;
|
12
|
+
fileMetadata: FileMetadata;
|
13
|
+
};
|
14
|
+
export type CompletedFileTranslationData = {
|
15
|
+
locale: string;
|
16
|
+
metadata: any;
|
17
|
+
fileId: string;
|
18
|
+
fileName: string;
|
19
|
+
versionId: string;
|
20
|
+
id: string;
|
21
|
+
isReady: boolean;
|
22
|
+
downloadUrl: string;
|
23
|
+
};
|
@@ -0,0 +1,34 @@
|
|
1
|
+
import { I18nextMessage, IcuMessage, JsxChildren } from './content';
|
2
|
+
/**
|
3
|
+
* TranslationResultReference is used to store the reference for a translation result.
|
4
|
+
*/
|
5
|
+
export type TranslationResultReference = {
|
6
|
+
id?: string;
|
7
|
+
hash: string;
|
8
|
+
};
|
9
|
+
/**
|
10
|
+
* TypedResult is a union type that represents the different types of translations that can be returned.
|
11
|
+
*/
|
12
|
+
export type TypedResult = {
|
13
|
+
translation: JsxChildren;
|
14
|
+
dataFormat: 'JSX';
|
15
|
+
} | {
|
16
|
+
translation: I18nextMessage | IcuMessage;
|
17
|
+
dataFormat: 'ICU' | 'I18NEXT';
|
18
|
+
};
|
19
|
+
/**
|
20
|
+
* RequestError is a type that represents an error that occurred during a translation request.
|
21
|
+
*/
|
22
|
+
export type TranslationError = {
|
23
|
+
error: string;
|
24
|
+
code: number;
|
25
|
+
reference?: TranslationResultReference;
|
26
|
+
};
|
27
|
+
/**
|
28
|
+
* RequestSuccess is a type that represents a successful translation request.
|
29
|
+
*/
|
30
|
+
export type RequestSuccess = TypedResult & {
|
31
|
+
locale: string;
|
32
|
+
reference: TranslationResultReference;
|
33
|
+
};
|
34
|
+
export type TranslationResult = RequestSuccess | TranslationError;
|
@@ -0,0 +1,38 @@
|
|
1
|
+
import { DataFormat } from './content';
|
2
|
+
import { FileFormat } from './file';
|
3
|
+
export type FileUpload = {
|
4
|
+
content: string;
|
5
|
+
fileName: string;
|
6
|
+
fileFormat: FileFormat;
|
7
|
+
dataFormat?: DataFormat;
|
8
|
+
locale: string;
|
9
|
+
versionId?: string;
|
10
|
+
fileId?: string;
|
11
|
+
};
|
12
|
+
export type FileUploadRef = {
|
13
|
+
fileId: string;
|
14
|
+
versionId: string;
|
15
|
+
fileName: string;
|
16
|
+
fileFormat: FileFormat;
|
17
|
+
dataFormat?: DataFormat;
|
18
|
+
locale?: string;
|
19
|
+
};
|
20
|
+
export type UploadData = {
|
21
|
+
data: {
|
22
|
+
source: FileUpload;
|
23
|
+
translations: FileUpload[];
|
24
|
+
}[];
|
25
|
+
sourceLocale: string;
|
26
|
+
modelProvider?: string;
|
27
|
+
};
|
28
|
+
export type UploadFilesOptions = {
|
29
|
+
sourceLocale: string;
|
30
|
+
modelProvider?: string;
|
31
|
+
timeout?: number;
|
32
|
+
};
|
33
|
+
export type UploadFilesResponse = {
|
34
|
+
uploadedFiles: FileUploadRef[];
|
35
|
+
count: number;
|
36
|
+
message: string;
|
37
|
+
};
|
38
|
+
export type RequiredUploadFilesOptions = UploadFilesOptions & Required<Pick<UploadFilesOptions, 'sourceLocale'>>;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "generaltranslation",
|
3
|
-
"version": "7.6.4
|
3
|
+
"version": "7.6.4",
|
4
4
|
"description": "A language toolkit for AI developers",
|
5
5
|
"main": "dist/index.cjs.min.cjs",
|
6
6
|
"module": "dist/index.esm.min.mjs",
|
@@ -100,7 +100,7 @@
|
|
100
100
|
},
|
101
101
|
"scripts": {
|
102
102
|
"build:release": "pnpm run build:clean",
|
103
|
-
"build:clean": "
|
103
|
+
"build:clean": "sh ../../scripts/clean.sh && pnpm run build",
|
104
104
|
"build": "rollup -c",
|
105
105
|
"lint": "eslint \"src/**/*.{js,ts}\" \"./**/__tests__/**/*.{js,ts}\"",
|
106
106
|
"lint:fix": "eslint \"src/**/*.{js,ts}\" \"./**/__tests__/**/*.{js,ts}\" --fix",
|