generaltranslation 8.2.12 → 8.2.13
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 +8 -0
- package/dist/LocaleConfig.d.ts +59 -0
- package/dist/LocaleConfig.js +225 -0
- package/dist/backwards-compatability/dataConversion.d.ts +23 -0
- package/dist/backwards-compatability/dataConversion.js +207 -0
- package/dist/backwards-compatability/oldHashJsxChildren.d.ts +23 -0
- package/dist/backwards-compatability/oldHashJsxChildren.js +79 -0
- package/dist/backwards-compatability/oldTypes.d.ts +21 -0
- package/dist/backwards-compatability/oldTypes.js +1 -0
- package/dist/backwards-compatability/typeChecking.d.ts +21 -0
- package/dist/backwards-compatability/typeChecking.js +61 -0
- package/dist/cache/IntlCache.d.ts +26 -0
- package/dist/cache/IntlCache.js +84 -0
- package/dist/cache/types.d.ts +32 -0
- package/dist/cache/types.js +1 -0
- package/dist/{core-CST4J4WU.cjs → core-7RP541eY.cjs} +2 -2
- package/dist/core-7RP541eY.cjs.map +1 -0
- package/dist/{core-D-E8qhLn.d.cts → core-I9pWGafA.d.mts} +2 -2
- package/dist/{core-CGhlXrrK.d.mts → core-TLJoDpJP.d.cts} +2 -2
- package/dist/{core-7RJsqw6c.mjs → core-isLphYAZ.mjs} +2 -2
- package/dist/core-isLphYAZ.mjs.map +1 -0
- package/dist/core.cjs +1 -1
- package/dist/core.d.cts +1 -1
- package/dist/core.d.mts +1 -1
- package/dist/core.d.ts +128 -0
- package/dist/core.js +137 -0
- package/dist/core.mjs +1 -1
- package/dist/derive/condenseVars.d.ts +7 -0
- package/dist/derive/condenseVars.js +30 -0
- package/dist/derive/declareVar.d.ts +26 -0
- package/dist/derive/declareVar.js +38 -0
- package/dist/derive/decodeVars.d.ts +9 -0
- package/dist/derive/decodeVars.js +52 -0
- package/dist/derive/derive.d.ts +53 -0
- package/dist/derive/derive.js +55 -0
- package/dist/derive/extractVars.d.ts +9 -0
- package/dist/derive/extractVars.js +34 -0
- package/dist/derive/index.d.ts +7 -0
- package/dist/derive/index.js +7 -0
- package/dist/derive/indexVars.d.ts +6 -0
- package/dist/derive/indexVars.js +52 -0
- package/dist/derive/utils/constants.d.ts +2 -0
- package/dist/derive/utils/constants.js +2 -0
- package/dist/derive/utils/regex.d.ts +2 -0
- package/dist/derive/utils/regex.js +4 -0
- package/dist/derive/utils/sanitizeVar.d.ts +12 -0
- package/dist/derive/utils/sanitizeVar.js +38 -0
- package/dist/derive/utils/traverseHelpers.d.ts +4 -0
- package/dist/derive/utils/traverseHelpers.js +22 -0
- package/dist/derive/utils/traverseIcu.d.ts +20 -0
- package/dist/derive/utils/traverseIcu.js +49 -0
- package/dist/derive/utils/types.d.ts +23 -0
- package/dist/derive/utils/types.js +1 -0
- package/dist/errors/ApiError.d.ts +7 -0
- package/dist/errors/ApiError.js +33 -0
- package/dist/errors/formattingErrors.d.ts +1 -0
- package/dist/errors/formattingErrors.js +3 -0
- package/dist/errors.d.ts +1 -0
- package/dist/errors.js +1 -0
- package/dist/formatting/custom-formats/CutoffFormat/CutoffFormat.d.ts +59 -0
- package/dist/formatting/custom-formats/CutoffFormat/CutoffFormat.js +147 -0
- package/dist/formatting/custom-formats/CutoffFormat/constants.d.ts +4 -0
- package/dist/formatting/custom-formats/CutoffFormat/constants.js +30 -0
- package/dist/formatting/custom-formats/CutoffFormat/types.d.ts +48 -0
- package/dist/formatting/custom-formats/CutoffFormat/types.js +2 -0
- package/dist/formatting/format.d.ts +1 -0
- package/dist/formatting/format.js +257 -0
- package/dist/id/hashSource.d.ts +25 -0
- package/dist/id/hashSource.js +98 -0
- package/dist/id/hashTemplate.d.ts +4 -0
- package/dist/id/hashTemplate.js +6 -0
- package/dist/id/types.d.ts +7 -0
- package/dist/id/types.js +1 -0
- package/dist/id.d.cts +1 -1
- package/dist/id.d.mts +1 -1
- package/dist/id.d.ts +3 -0
- package/dist/id.js +3 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +1019 -0
- package/dist/index.js +1664 -0
- package/dist/index.mjs +1 -1
- package/dist/internal.cjs +1 -1
- package/dist/internal.cjs.map +1 -1
- package/dist/internal.d.cts +2 -2
- package/dist/internal.d.mts +2 -2
- package/dist/internal.d.ts +19 -0
- package/dist/internal.js +17 -0
- package/dist/internal.mjs +1 -1
- package/dist/internal.mjs.map +1 -1
- package/dist/locales/customLocaleMapping.d.ts +11 -0
- package/dist/locales/customLocaleMapping.js +23 -0
- package/dist/locales/determineLocale.d.ts +1 -0
- package/dist/locales/determineLocale.js +72 -0
- package/dist/locales/getLocaleDirection.d.ts +1 -0
- package/dist/locales/getLocaleDirection.js +89 -0
- package/dist/locales/getLocaleEmoji.d.ts +2 -0
- package/dist/locales/getLocaleEmoji.js +319 -0
- package/dist/locales/getLocaleName.d.ts +1 -0
- package/dist/locales/getLocaleName.js +45 -0
- package/dist/locales/getLocaleProperties.d.ts +32 -0
- package/dist/locales/getLocaleProperties.js +220 -0
- package/dist/locales/getPluralForm.d.ts +9 -0
- package/dist/locales/getPluralForm.js +63 -0
- package/dist/locales/getRegionProperties.d.ts +7 -0
- package/dist/locales/getRegionProperties.js +61 -0
- package/dist/locales/isSameDialect.d.ts +1 -0
- package/dist/locales/isSameDialect.js +41 -0
- package/dist/locales/isSameLanguage.d.ts +1 -0
- package/dist/locales/isSameLanguage.js +20 -0
- package/dist/locales/isSupersetLocale.d.ts +1 -0
- package/dist/locales/isSupersetLocale.js +22 -0
- package/dist/locales/isValidLocale.d.ts +1 -0
- package/dist/locales/isValidLocale.js +75 -0
- package/dist/locales/requiresTranslation.d.ts +1 -0
- package/dist/locales/requiresTranslation.js +32 -0
- package/dist/locales/resolveAliasLocale.d.ts +8 -0
- package/dist/locales/resolveAliasLocale.js +21 -0
- package/dist/locales/resolveCanonicalLocale.d.ts +8 -0
- package/dist/locales/resolveCanonicalLocale.js +13 -0
- package/dist/logging/errors.d.ts +10 -0
- package/dist/logging/errors.js +29 -0
- package/dist/logging/logger.d.ts +121 -0
- package/dist/logging/logger.js +259 -0
- package/dist/logging/warnings.d.ts +2 -0
- package/dist/logging/warnings.js +2 -0
- package/dist/projects/getProjectData.d.ts +1 -0
- package/dist/projects/getProjectData.js +87 -0
- package/dist/settings/plurals.d.ts +3 -0
- package/dist/settings/plurals.js +14 -0
- package/dist/settings/settings.d.ts +2 -0
- package/dist/settings/settings.js +2 -0
- package/dist/settings/settingsUrls.d.ts +3 -0
- package/dist/settings/settingsUrls.js +3 -0
- package/dist/translate/api.d.ts +1 -0
- package/dist/translate/api.js +1 -0
- package/dist/translate/awaitJobs.d.ts +19 -0
- package/dist/translate/awaitJobs.js +112 -0
- package/dist/translate/checkJobStatus.d.ts +8 -0
- package/dist/translate/checkJobStatus.js +55 -0
- package/dist/translate/createBranch.d.ts +10 -0
- package/dist/translate/createBranch.js +53 -0
- package/dist/translate/createTag.d.ts +19 -0
- package/dist/translate/createTag.js +67 -0
- package/dist/translate/downloadFileBatch.d.ts +1 -0
- package/dist/translate/downloadFileBatch.js +77 -0
- package/dist/translate/enqueueFiles.d.ts +8 -0
- package/dist/translate/enqueueFiles.js +96 -0
- package/dist/translate/getOrphanedFiles.d.ts +8 -0
- package/dist/translate/getOrphanedFiles.js +97 -0
- package/dist/translate/processFileMoves.d.ts +25 -0
- package/dist/translate/processFileMoves.js +90 -0
- package/dist/translate/publishFiles.d.ts +17 -0
- package/dist/translate/publishFiles.js +56 -0
- package/dist/translate/queryBranchData.d.ts +3 -0
- package/dist/translate/queryBranchData.js +53 -0
- package/dist/translate/queryFileData.d.ts +42 -0
- package/dist/translate/queryFileData.js +71 -0
- package/dist/translate/querySourceFile.d.ts +1 -0
- package/dist/translate/querySourceFile.js +67 -0
- package/dist/translate/setupProject.d.ts +11 -0
- package/dist/translate/setupProject.js +63 -0
- package/dist/translate/submitUserEditDiffs.d.ts +12 -0
- package/dist/translate/submitUserEditDiffs.js +68 -0
- package/dist/translate/translateMany.d.ts +1 -0
- package/dist/translate/translateMany.js +103 -0
- package/dist/translate/uploadSourceFiles.d.ts +1 -0
- package/dist/translate/uploadSourceFiles.js +87 -0
- package/dist/translate/uploadTranslations.d.ts +1 -0
- package/dist/translate/uploadTranslations.js +101 -0
- package/dist/translate/utils/apiRequest.d.ts +1 -0
- package/dist/translate/utils/apiRequest.js +130 -0
- package/dist/translate/utils/batch.d.ts +52 -0
- package/dist/translate/utils/batch.js +126 -0
- package/dist/translate/utils/fetchWithTimeout.d.ts +1 -0
- package/dist/translate/utils/fetchWithTimeout.js +93 -0
- package/dist/translate/utils/generateRequestHeaders.d.ts +2 -0
- package/dist/translate/utils/generateRequestHeaders.js +26 -0
- package/dist/translate/utils/handleFetchError.d.ts +1 -0
- package/dist/translate/utils/handleFetchError.js +12 -0
- package/dist/translate/utils/validateFileFormatTransform.d.ts +16 -0
- package/dist/translate/utils/validateFileFormatTransform.js +29 -0
- package/dist/translate/utils/validateResponse.d.ts +1 -0
- package/dist/translate/utils/validateResponse.js +72 -0
- package/dist/{types-BsGsgJWF.d.mts → types-AHtYZIP-.d.mts} +34 -11
- package/dist/{types-V5rqd1WR.d.cts → types-Bf8_Apq_.d.cts} +34 -11
- package/dist/types-dir/api/branch.d.ts +10 -0
- package/dist/types-dir/api/branch.js +1 -0
- package/dist/types-dir/api/checkFileTranslations.d.ts +37 -0
- package/dist/types-dir/api/checkFileTranslations.js +1 -0
- package/dist/types-dir/api/downloadFile.d.ts +3 -0
- package/dist/types-dir/api/downloadFile.js +1 -0
- package/dist/types-dir/api/downloadFileBatch.d.ts +35 -0
- package/dist/types-dir/api/downloadFileBatch.js +1 -0
- package/dist/types-dir/api/enqueueEntries.d.ts +21 -0
- package/dist/types-dir/api/enqueueEntries.js +1 -0
- package/dist/types-dir/api/enqueueFiles.d.ts +70 -0
- package/dist/types-dir/api/enqueueFiles.js +1 -0
- package/dist/types-dir/api/entry.d.ts +39 -0
- package/dist/types-dir/api/entry.js +1 -0
- package/dist/types-dir/api/fetchTranslations.d.ts +12 -0
- package/dist/types-dir/api/fetchTranslations.js +1 -0
- package/dist/types-dir/api/file.d.ts +57 -0
- package/dist/types-dir/api/file.js +1 -0
- package/dist/types-dir/api/json.d.ts +5 -0
- package/dist/types-dir/api/json.js +1 -0
- package/dist/types-dir/api/project.d.ts +7 -0
- package/dist/types-dir/api/project.js +1 -0
- package/dist/types-dir/api/translate.d.ts +34 -0
- package/dist/types-dir/api/translate.js +1 -0
- package/dist/types-dir/api/translateMany.d.ts +5 -0
- package/dist/types-dir/api/translateMany.js +1 -0
- package/dist/types-dir/api/translationStatus.d.ts +9 -0
- package/dist/types-dir/api/translationStatus.js +1 -0
- package/dist/types-dir/api/uploadFiles.d.ts +44 -0
- package/dist/types-dir/api/uploadFiles.js +1 -0
- package/dist/types-dir/jsx/content.d.ts +61 -0
- package/dist/types-dir/jsx/content.js +11 -0
- package/dist/types-dir/jsx/variables.d.ts +9 -0
- package/dist/types-dir/jsx/variables.js +1 -0
- package/dist/types-dir/transformations.d.ts +8 -0
- package/dist/types-dir/transformations.js +1 -0
- package/dist/types.d.cts +2 -2
- package/dist/types.d.mts +2 -2
- package/dist/types.d.ts +129 -0
- package/dist/types.js +2 -0
- package/dist/utils/base64.d.ts +2 -0
- package/dist/utils/base64.js +28 -0
- package/dist/utils/isSupportedFileFormatTransform.d.ts +8 -0
- package/dist/utils/isSupportedFileFormatTransform.js +26 -0
- package/dist/utils/isVariable.d.ts +2 -0
- package/dist/utils/isVariable.js +22 -0
- package/dist/utils/minify.d.ts +2 -0
- package/dist/utils/minify.js +10 -0
- package/dist/utils/stableStringify.d.ts +1 -0
- package/dist/utils/stableStringify.js +40 -0
- package/package.json +3 -3
- package/dist/core-7RJsqw6c.mjs.map +0 -1
- package/dist/core-CST4J4WU.cjs.map +0 -1
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
var GT_ERROR_PREFIX = 'GT Error:';
|
|
2
|
+
export var translationTimeoutError = function (timeout) {
|
|
3
|
+
return "".concat(GT_ERROR_PREFIX, " Translation request timed out after ").concat(timeout, "ms.");
|
|
4
|
+
};
|
|
5
|
+
export var translationRequestFailedError = function (error) {
|
|
6
|
+
return "".concat(GT_ERROR_PREFIX, " Translation request failed. Error: ").concat(error);
|
|
7
|
+
};
|
|
8
|
+
export var apiError = function (status, statusText, error) {
|
|
9
|
+
return "".concat(GT_ERROR_PREFIX, " API returned error status. Status: ").concat(status, ", Status Text: ").concat(statusText, ", Error: ").concat(error);
|
|
10
|
+
};
|
|
11
|
+
export var invalidAuthError = "".concat(GT_ERROR_PREFIX, " Invalid authentication.");
|
|
12
|
+
export var noTargetLocaleProvidedError = function (functionName) {
|
|
13
|
+
return "".concat(GT_ERROR_PREFIX, " Cannot call `").concat(functionName, "` without a specified locale. Either pass a locale to the `").concat(functionName, "` function or specify a targetLocale in the GT constructor.");
|
|
14
|
+
};
|
|
15
|
+
export var noSourceLocaleProvidedError = function (functionName) {
|
|
16
|
+
return "".concat(GT_ERROR_PREFIX, " Cannot call `").concat(functionName, "` without a specified locale. Either pass a locale to the `").concat(functionName, "` function or specify a sourceLocale in the GT constructor.");
|
|
17
|
+
};
|
|
18
|
+
export var noProjectIdProvidedError = function (functionName) {
|
|
19
|
+
return "".concat(GT_ERROR_PREFIX, " Cannot call `").concat(functionName, "` without a specified project ID. Either pass a project ID to the `").concat(functionName, "` function or specify a projectId in the GT constructor.");
|
|
20
|
+
};
|
|
21
|
+
export var noApiKeyProvidedError = function (functionName) {
|
|
22
|
+
return "".concat(GT_ERROR_PREFIX, " Cannot call `").concat(functionName, "` without a specified API key. Either pass an API key to the `").concat(functionName, "` function or specify an apiKey in the GT constructor.");
|
|
23
|
+
};
|
|
24
|
+
export var invalidLocaleError = function (locale) {
|
|
25
|
+
return "".concat(GT_ERROR_PREFIX, " Invalid locale: ").concat(locale, ".");
|
|
26
|
+
};
|
|
27
|
+
export var invalidLocalesError = function (locales) {
|
|
28
|
+
return "".concat(GT_ERROR_PREFIX, " Invalid locales: ").concat(locales.join(', '), ".");
|
|
29
|
+
};
|
|
@@ -0,0 +1,121 @@
|
|
|
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 type LogMetadataValue = string | number | boolean | null | undefined | Date | Error | LogMetadataValue[] | {
|
|
7
|
+
[key: string]: LogMetadataValue;
|
|
8
|
+
};
|
|
9
|
+
export type LogMetadata = Record<string, LogMetadataValue>;
|
|
10
|
+
export interface LogEntry {
|
|
11
|
+
level: LogLevel;
|
|
12
|
+
message: string;
|
|
13
|
+
timestamp: Date;
|
|
14
|
+
context?: string;
|
|
15
|
+
metadata?: LogMetadata;
|
|
16
|
+
}
|
|
17
|
+
export interface LoggerConfig {
|
|
18
|
+
/** Minimum log level to output. */
|
|
19
|
+
level: LogLevel;
|
|
20
|
+
/** Whether to include timestamps in log output. */
|
|
21
|
+
includeTimestamp: boolean;
|
|
22
|
+
/** Whether to include context information. */
|
|
23
|
+
includeContext: boolean;
|
|
24
|
+
/** Custom prefix for all log messages. */
|
|
25
|
+
prefix?: string;
|
|
26
|
+
/** Whether to output to console (default: true) */
|
|
27
|
+
enableConsole: boolean;
|
|
28
|
+
/** Custom log handlers. */
|
|
29
|
+
handlers?: LogHandler[];
|
|
30
|
+
}
|
|
31
|
+
export interface LogHandler {
|
|
32
|
+
handle(entry: LogEntry): void;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Console log handler that outputs formatted messages to console
|
|
36
|
+
*/
|
|
37
|
+
export declare class ConsoleLogHandler implements LogHandler {
|
|
38
|
+
private config;
|
|
39
|
+
constructor(config: LoggerConfig);
|
|
40
|
+
handle(entry: LogEntry): void;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Main Logger class providing structured logging capabilities.
|
|
44
|
+
*/
|
|
45
|
+
export declare class Logger {
|
|
46
|
+
private config;
|
|
47
|
+
private handlers;
|
|
48
|
+
constructor(config?: Partial<LoggerConfig>);
|
|
49
|
+
/**
|
|
50
|
+
* Add a custom log handler
|
|
51
|
+
*/
|
|
52
|
+
addHandler(handler: LogHandler): void;
|
|
53
|
+
/**
|
|
54
|
+
* Remove a log handler
|
|
55
|
+
*/
|
|
56
|
+
removeHandler(handler: LogHandler): void;
|
|
57
|
+
/**
|
|
58
|
+
* Update logger configuration
|
|
59
|
+
*/
|
|
60
|
+
configure(config: Partial<LoggerConfig>): void;
|
|
61
|
+
/**
|
|
62
|
+
* Check if a log level should be output based on current configuration
|
|
63
|
+
*/
|
|
64
|
+
private shouldLog;
|
|
65
|
+
/**
|
|
66
|
+
* Internal logging method that creates log entries and passes them to handlers
|
|
67
|
+
*/
|
|
68
|
+
private log;
|
|
69
|
+
/**
|
|
70
|
+
* Log a debug message
|
|
71
|
+
* Used for detailed diagnostic information, typically of interest only when diagnosing problems
|
|
72
|
+
*/
|
|
73
|
+
debug(message: string, context?: string, metadata?: LogMetadata): void;
|
|
74
|
+
/**
|
|
75
|
+
* Log an info message
|
|
76
|
+
* Used for general information about application operation.
|
|
77
|
+
*/
|
|
78
|
+
info(message: string, context?: string, metadata?: LogMetadata): void;
|
|
79
|
+
/**
|
|
80
|
+
* Log a warning message
|
|
81
|
+
* Used for potentially problematic situations that don't prevent operation
|
|
82
|
+
*/
|
|
83
|
+
warn(message: string, context?: string, metadata?: LogMetadata): void;
|
|
84
|
+
/**
|
|
85
|
+
* Log an error message
|
|
86
|
+
* Used for error events that might still allow the application to continue.
|
|
87
|
+
*/
|
|
88
|
+
error(message: string, context?: string, metadata?: LogMetadata): void;
|
|
89
|
+
/**
|
|
90
|
+
* Create a child logger with a specific context
|
|
91
|
+
*/
|
|
92
|
+
child(context: string): ContextLogger;
|
|
93
|
+
/**
|
|
94
|
+
* Get current logger configuration
|
|
95
|
+
*/
|
|
96
|
+
getConfig(): LoggerConfig;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Context logger that automatically includes context information.
|
|
100
|
+
*/
|
|
101
|
+
export declare class ContextLogger {
|
|
102
|
+
private logger;
|
|
103
|
+
private context;
|
|
104
|
+
constructor(logger: Logger, context: string);
|
|
105
|
+
debug(message: string, metadata?: LogMetadata): void;
|
|
106
|
+
info(message: string, metadata?: LogMetadata): void;
|
|
107
|
+
warn(message: string, metadata?: LogMetadata): void;
|
|
108
|
+
error(message: string, metadata?: LogMetadata): void;
|
|
109
|
+
child(childContext: string): ContextLogger;
|
|
110
|
+
}
|
|
111
|
+
export declare const defaultLogger: Logger;
|
|
112
|
+
export declare const debug: (message: string, context?: string, metadata?: LogMetadata) => void;
|
|
113
|
+
export declare const info: (message: string, context?: string, metadata?: LogMetadata) => void;
|
|
114
|
+
export declare const warn: (message: string, context?: string, metadata?: LogMetadata) => void;
|
|
115
|
+
export declare const error: (message: string, context?: string, metadata?: LogMetadata) => void;
|
|
116
|
+
export declare const fetchLogger: ContextLogger;
|
|
117
|
+
export declare const validationLogger: ContextLogger;
|
|
118
|
+
export declare const formattingLogger: ContextLogger;
|
|
119
|
+
export declare const localeLogger: ContextLogger;
|
|
120
|
+
export declare const gtInstanceLogger: ContextLogger;
|
|
121
|
+
export { Logger as GTLogger };
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Comprehensive logging system for the General Translation library.
|
|
3
|
+
* Provides structured logging with multiple levels and configurable output.
|
|
4
|
+
*/
|
|
5
|
+
var __assign = (this && this.__assign) || function () {
|
|
6
|
+
__assign = Object.assign || function(t) {
|
|
7
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
8
|
+
s = arguments[i];
|
|
9
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
10
|
+
t[p] = s[p];
|
|
11
|
+
}
|
|
12
|
+
return t;
|
|
13
|
+
};
|
|
14
|
+
return __assign.apply(this, arguments);
|
|
15
|
+
};
|
|
16
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
17
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
18
|
+
if (ar || !(i in from)) {
|
|
19
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
20
|
+
ar[i] = from[i];
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
24
|
+
};
|
|
25
|
+
var LOG_LEVELS = {
|
|
26
|
+
debug: 0,
|
|
27
|
+
info: 1,
|
|
28
|
+
warn: 2,
|
|
29
|
+
error: 3,
|
|
30
|
+
off: 4,
|
|
31
|
+
};
|
|
32
|
+
var LOG_COLORS = {
|
|
33
|
+
debug: '\x1b[36m', // Cyan
|
|
34
|
+
info: '\x1b[32m', // Green
|
|
35
|
+
warn: '\x1b[33m', // Yellow
|
|
36
|
+
error: '\x1b[31m', // Red
|
|
37
|
+
off: '', // No color needed since 'off' level logs are never displayed
|
|
38
|
+
};
|
|
39
|
+
var RESET_COLOR = '\x1b[0m';
|
|
40
|
+
/**
|
|
41
|
+
* Get the configured log level from environment variable or default to 'warn'
|
|
42
|
+
*/
|
|
43
|
+
function getConfiguredLogLevel() {
|
|
44
|
+
var _a;
|
|
45
|
+
if (typeof process !== 'undefined' && ((_a = process.env) === null || _a === void 0 ? void 0 : _a._GT_LOG_LEVEL)) {
|
|
46
|
+
var envLevel = process.env._GT_LOG_LEVEL.toLowerCase();
|
|
47
|
+
if (envLevel in LOG_LEVELS) {
|
|
48
|
+
return envLevel;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return 'warn';
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Console log handler that outputs formatted messages to console
|
|
55
|
+
*/
|
|
56
|
+
var ConsoleLogHandler = /** @class */ (function () {
|
|
57
|
+
function ConsoleLogHandler(config) {
|
|
58
|
+
this.config = config;
|
|
59
|
+
}
|
|
60
|
+
ConsoleLogHandler.prototype.handle = function (entry) {
|
|
61
|
+
var parts = [];
|
|
62
|
+
// Add timestamp if enabled
|
|
63
|
+
if (this.config.includeTimestamp) {
|
|
64
|
+
parts.push("[".concat(entry.timestamp.toISOString(), "]"));
|
|
65
|
+
}
|
|
66
|
+
// Add level with color
|
|
67
|
+
var colorCode = LOG_COLORS[entry.level];
|
|
68
|
+
var levelText = "[".concat(entry.level.toUpperCase(), "]");
|
|
69
|
+
parts.push("".concat(colorCode).concat(levelText).concat(RESET_COLOR));
|
|
70
|
+
// Add prefix if configured
|
|
71
|
+
if (this.config.prefix) {
|
|
72
|
+
parts.push("[".concat(this.config.prefix, "]"));
|
|
73
|
+
}
|
|
74
|
+
// Add context if available and enabled.
|
|
75
|
+
if (this.config.includeContext && entry.context) {
|
|
76
|
+
parts.push("[".concat(entry.context, "]"));
|
|
77
|
+
}
|
|
78
|
+
// Add the main message
|
|
79
|
+
parts.push(entry.message);
|
|
80
|
+
// Format metadata if available.
|
|
81
|
+
if (entry.metadata && Object.keys(entry.metadata).length > 0) {
|
|
82
|
+
parts.push("\n Metadata: ".concat(JSON.stringify(entry.metadata, null, 2)));
|
|
83
|
+
}
|
|
84
|
+
var formattedMessage = parts.join(' ');
|
|
85
|
+
// Output to appropriate console method based on level
|
|
86
|
+
switch (entry.level) {
|
|
87
|
+
case 'debug':
|
|
88
|
+
// eslint-disable-next-line no-console
|
|
89
|
+
console.debug(formattedMessage);
|
|
90
|
+
break;
|
|
91
|
+
case 'info':
|
|
92
|
+
// eslint-disable-next-line no-console
|
|
93
|
+
console.info(formattedMessage);
|
|
94
|
+
break;
|
|
95
|
+
case 'warn':
|
|
96
|
+
console.warn(formattedMessage);
|
|
97
|
+
break;
|
|
98
|
+
case 'error':
|
|
99
|
+
console.error(formattedMessage);
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
return ConsoleLogHandler;
|
|
104
|
+
}());
|
|
105
|
+
export { ConsoleLogHandler };
|
|
106
|
+
/**
|
|
107
|
+
* Main Logger class providing structured logging capabilities.
|
|
108
|
+
*/
|
|
109
|
+
var Logger = /** @class */ (function () {
|
|
110
|
+
function Logger(config) {
|
|
111
|
+
if (config === void 0) { config = {}; }
|
|
112
|
+
this.config = __assign({ level: getConfiguredLogLevel(), includeTimestamp: true, includeContext: true, enableConsole: true, handlers: [] }, config);
|
|
113
|
+
this.handlers = __spreadArray([], (this.config.handlers || []), true);
|
|
114
|
+
// Add console handler if enabled
|
|
115
|
+
if (this.config.enableConsole) {
|
|
116
|
+
this.handlers.push(new ConsoleLogHandler(this.config));
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Add a custom log handler
|
|
121
|
+
*/
|
|
122
|
+
Logger.prototype.addHandler = function (handler) {
|
|
123
|
+
this.handlers.push(handler);
|
|
124
|
+
};
|
|
125
|
+
/**
|
|
126
|
+
* Remove a log handler
|
|
127
|
+
*/
|
|
128
|
+
Logger.prototype.removeHandler = function (handler) {
|
|
129
|
+
var index = this.handlers.indexOf(handler);
|
|
130
|
+
if (index > -1) {
|
|
131
|
+
this.handlers.splice(index, 1);
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
/**
|
|
135
|
+
* Update logger configuration
|
|
136
|
+
*/
|
|
137
|
+
Logger.prototype.configure = function (config) {
|
|
138
|
+
this.config = __assign(__assign({}, this.config), config);
|
|
139
|
+
};
|
|
140
|
+
/**
|
|
141
|
+
* Check if a log level should be output based on current configuration
|
|
142
|
+
*/
|
|
143
|
+
Logger.prototype.shouldLog = function (level) {
|
|
144
|
+
return LOG_LEVELS[level] >= LOG_LEVELS[this.config.level];
|
|
145
|
+
};
|
|
146
|
+
/**
|
|
147
|
+
* Internal logging method that creates log entries and passes them to handlers
|
|
148
|
+
*/
|
|
149
|
+
Logger.prototype.log = function (level, message, context, metadata) {
|
|
150
|
+
if (!this.shouldLog(level)) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
var entry = {
|
|
154
|
+
level: level,
|
|
155
|
+
message: message,
|
|
156
|
+
timestamp: new Date(),
|
|
157
|
+
context: context,
|
|
158
|
+
metadata: metadata,
|
|
159
|
+
};
|
|
160
|
+
// Pass to all handlers
|
|
161
|
+
this.handlers.forEach(function (handler) {
|
|
162
|
+
try {
|
|
163
|
+
handler.handle(entry);
|
|
164
|
+
}
|
|
165
|
+
catch (error) {
|
|
166
|
+
// Prevent logging errors from breaking the application
|
|
167
|
+
console.error('Error in log handler:', error);
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
};
|
|
171
|
+
/**
|
|
172
|
+
* Log a debug message
|
|
173
|
+
* Used for detailed diagnostic information, typically of interest only when diagnosing problems
|
|
174
|
+
*/
|
|
175
|
+
Logger.prototype.debug = function (message, context, metadata) {
|
|
176
|
+
this.log('debug', message, context, metadata);
|
|
177
|
+
};
|
|
178
|
+
/**
|
|
179
|
+
* Log an info message
|
|
180
|
+
* Used for general information about application operation.
|
|
181
|
+
*/
|
|
182
|
+
Logger.prototype.info = function (message, context, metadata) {
|
|
183
|
+
this.log('info', message, context, metadata);
|
|
184
|
+
};
|
|
185
|
+
/**
|
|
186
|
+
* Log a warning message
|
|
187
|
+
* Used for potentially problematic situations that don't prevent operation
|
|
188
|
+
*/
|
|
189
|
+
Logger.prototype.warn = function (message, context, metadata) {
|
|
190
|
+
this.log('warn', message, context, metadata);
|
|
191
|
+
};
|
|
192
|
+
/**
|
|
193
|
+
* Log an error message
|
|
194
|
+
* Used for error events that might still allow the application to continue.
|
|
195
|
+
*/
|
|
196
|
+
Logger.prototype.error = function (message, context, metadata) {
|
|
197
|
+
this.log('error', message, context, metadata);
|
|
198
|
+
};
|
|
199
|
+
/**
|
|
200
|
+
* Create a child logger with a specific context
|
|
201
|
+
*/
|
|
202
|
+
Logger.prototype.child = function (context) {
|
|
203
|
+
return new ContextLogger(this, context);
|
|
204
|
+
};
|
|
205
|
+
/**
|
|
206
|
+
* Get current logger configuration
|
|
207
|
+
*/
|
|
208
|
+
Logger.prototype.getConfig = function () {
|
|
209
|
+
return __assign({}, this.config);
|
|
210
|
+
};
|
|
211
|
+
return Logger;
|
|
212
|
+
}());
|
|
213
|
+
export { Logger };
|
|
214
|
+
/**
|
|
215
|
+
* Context logger that automatically includes context information.
|
|
216
|
+
*/
|
|
217
|
+
var ContextLogger = /** @class */ (function () {
|
|
218
|
+
function ContextLogger(logger, context) {
|
|
219
|
+
this.logger = logger;
|
|
220
|
+
this.context = context;
|
|
221
|
+
}
|
|
222
|
+
ContextLogger.prototype.debug = function (message, metadata) {
|
|
223
|
+
this.logger.debug(message, this.context, metadata);
|
|
224
|
+
};
|
|
225
|
+
ContextLogger.prototype.info = function (message, metadata) {
|
|
226
|
+
this.logger.info(message, this.context, metadata);
|
|
227
|
+
};
|
|
228
|
+
ContextLogger.prototype.warn = function (message, metadata) {
|
|
229
|
+
this.logger.warn(message, this.context, metadata);
|
|
230
|
+
};
|
|
231
|
+
ContextLogger.prototype.error = function (message, metadata) {
|
|
232
|
+
this.logger.error(message, this.context, metadata);
|
|
233
|
+
};
|
|
234
|
+
ContextLogger.prototype.child = function (childContext) {
|
|
235
|
+
return new ContextLogger(this.logger, "".concat(this.context, ":").concat(childContext));
|
|
236
|
+
};
|
|
237
|
+
return ContextLogger;
|
|
238
|
+
}());
|
|
239
|
+
export { ContextLogger };
|
|
240
|
+
// Default logger instance.
|
|
241
|
+
export var defaultLogger = new Logger({
|
|
242
|
+
level: getConfiguredLogLevel(),
|
|
243
|
+
includeTimestamp: true,
|
|
244
|
+
includeContext: true,
|
|
245
|
+
prefix: 'GT',
|
|
246
|
+
});
|
|
247
|
+
// Convenience functions using the default logger.
|
|
248
|
+
export var debug = function (message, context, metadata) { return defaultLogger.debug(message, context, metadata); };
|
|
249
|
+
export var info = function (message, context, metadata) { return defaultLogger.info(message, context, metadata); };
|
|
250
|
+
export var warn = function (message, context, metadata) { return defaultLogger.warn(message, context, metadata); };
|
|
251
|
+
export var error = function (message, context, metadata) { return defaultLogger.error(message, context, metadata); };
|
|
252
|
+
// Create context-specific loggers for different parts of the system
|
|
253
|
+
export var fetchLogger = defaultLogger.child('fetch');
|
|
254
|
+
export var validationLogger = defaultLogger.child('validation');
|
|
255
|
+
export var formattingLogger = defaultLogger.child('formatting');
|
|
256
|
+
export var localeLogger = defaultLogger.child('locale');
|
|
257
|
+
export var gtInstanceLogger = defaultLogger.child('GT instance');
|
|
258
|
+
// Export types and classes
|
|
259
|
+
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 _formatMessageICU 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 _formatMessageICU for current ICU message format support.";
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export var formatI18nextWarning = 'Warning: formatI18next is not currently supported but will be implemented in a future version. Use _formatMessageICU for current ICU message format support.';
|
|
2
|
+
export var formatJsxWarning = 'Warning: formatJsx is not currently supported but will be implemented in a future version. Use _formatMessageICU for current ICU message format support.';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
12
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
import { defaultBaseUrl } from '../settings/settingsUrls';
|
|
38
|
+
import fetchWithTimeout from '../translate/utils/fetchWithTimeout';
|
|
39
|
+
import { defaultTimeout } from '../settings/settings';
|
|
40
|
+
import validateResponse from '../translate/utils/validateResponse';
|
|
41
|
+
import handleFetchError from '../translate/utils/handleFetchError';
|
|
42
|
+
import generateRequestHeaders from '../translate/utils/generateRequestHeaders';
|
|
43
|
+
/**
|
|
44
|
+
* @internal
|
|
45
|
+
* Gets the project data for a given project ID.
|
|
46
|
+
* @param projectId - The project ID to get the project data for
|
|
47
|
+
* @param options - The options for the API call.
|
|
48
|
+
* @param config - The configuration for the request.
|
|
49
|
+
* @returns The project data for the given project ID.
|
|
50
|
+
*/
|
|
51
|
+
export default function _getProjectData(projectId, options, config) {
|
|
52
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
53
|
+
var baseUrl, timeout, url, response, error_1, result;
|
|
54
|
+
return __generator(this, function (_a) {
|
|
55
|
+
switch (_a.label) {
|
|
56
|
+
case 0:
|
|
57
|
+
baseUrl = config.baseUrl;
|
|
58
|
+
timeout = options.timeout ? options.timeout : defaultTimeout;
|
|
59
|
+
url = "".concat(baseUrl || defaultBaseUrl, "/v2/project/info/").concat(encodeURIComponent(projectId));
|
|
60
|
+
_a.label = 1;
|
|
61
|
+
case 1:
|
|
62
|
+
_a.trys.push([1, 3, , 4]);
|
|
63
|
+
return [4 /*yield*/, fetchWithTimeout(url, {
|
|
64
|
+
method: 'GET',
|
|
65
|
+
headers: generateRequestHeaders(config),
|
|
66
|
+
}, timeout)];
|
|
67
|
+
case 2:
|
|
68
|
+
response = _a.sent();
|
|
69
|
+
return [3 /*break*/, 4];
|
|
70
|
+
case 3:
|
|
71
|
+
error_1 = _a.sent();
|
|
72
|
+
handleFetchError(error_1, timeout);
|
|
73
|
+
return [3 /*break*/, 4];
|
|
74
|
+
case 4:
|
|
75
|
+
// Validate the response
|
|
76
|
+
return [4 /*yield*/, validateResponse(response)];
|
|
77
|
+
case 5:
|
|
78
|
+
// Validate the response
|
|
79
|
+
_a.sent();
|
|
80
|
+
return [4 /*yield*/, response.json()];
|
|
81
|
+
case 6:
|
|
82
|
+
result = _a.sent();
|
|
83
|
+
return [2 /*return*/, result];
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const API_VERSION = "2026-03-06.v1";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export var API_VERSION = '2026-03-06.v1';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { JobStatus } from './checkJobStatus';
|
|
2
|
+
export type AwaitJobsOptions = {
|
|
3
|
+
/** Polling interval in seconds. Defaults to 5. */
|
|
4
|
+
pollingIntervalSeconds?: number;
|
|
5
|
+
/** Timeout in seconds. Defaults to 600 (10 minutes). If reached, resolves with whatever status is current. */
|
|
6
|
+
timeoutSeconds?: number;
|
|
7
|
+
};
|
|
8
|
+
export type JobResult = {
|
|
9
|
+
jobId: string;
|
|
10
|
+
status: JobStatus;
|
|
11
|
+
error?: {
|
|
12
|
+
message: string;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
export type AwaitJobsResult = {
|
|
16
|
+
/** Whether all jobs completed (none still in progress). */
|
|
17
|
+
complete: boolean;
|
|
18
|
+
jobs: JobResult[];
|
|
19
|
+
};
|