gtx-cli 2.3.6-alpha.2 → 2.3.6

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.
Files changed (192) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/api/checkFileTranslations.d.ts +23 -0
  3. package/dist/api/checkFileTranslations.js +236 -0
  4. package/dist/api/downloadFileBatch.d.ts +20 -0
  5. package/dist/api/downloadFileBatch.js +113 -0
  6. package/dist/api/sendFiles.d.ts +17 -0
  7. package/dist/api/sendFiles.js +115 -0
  8. package/dist/api/uploadFiles.d.ts +27 -0
  9. package/dist/api/uploadFiles.js +40 -0
  10. package/dist/cli/base.d.ts +32 -0
  11. package/dist/cli/base.js +335 -0
  12. package/dist/cli/commands/stage.d.ts +5 -0
  13. package/dist/cli/commands/stage.js +100 -0
  14. package/dist/cli/commands/translate.d.ts +6 -0
  15. package/dist/cli/commands/translate.js +63 -0
  16. package/dist/cli/flags.d.ts +3 -0
  17. package/dist/cli/flags.js +38 -0
  18. package/dist/cli/next.d.ts +11 -0
  19. package/dist/cli/next.js +20 -0
  20. package/dist/cli/react.d.ts +18 -0
  21. package/dist/cli/react.js +175 -0
  22. package/dist/config/generateSettings.d.ts +9 -0
  23. package/dist/config/generateSettings.js +176 -0
  24. package/dist/config/optionPresets.d.ts +2 -0
  25. package/dist/config/optionPresets.js +56 -0
  26. package/dist/config/resolveConfig.d.ts +4 -0
  27. package/dist/config/resolveConfig.js +19 -0
  28. package/dist/config/utils.d.ts +2 -0
  29. package/dist/config/utils.js +4 -0
  30. package/dist/config/validateSettings.d.ts +3 -0
  31. package/dist/config/validateSettings.js +32 -0
  32. package/dist/console/colors.d.ts +5 -0
  33. package/dist/console/colors.js +16 -0
  34. package/dist/console/index.d.ts +21 -0
  35. package/dist/console/index.js +24 -0
  36. package/dist/console/logging.d.ts +53 -0
  37. package/dist/console/logging.js +185 -0
  38. package/dist/formats/files/fileMapping.d.ts +11 -0
  39. package/dist/formats/files/fileMapping.js +82 -0
  40. package/dist/formats/files/save.d.ts +5 -0
  41. package/dist/formats/files/save.js +17 -0
  42. package/dist/formats/files/supportedFiles.d.ts +10 -0
  43. package/dist/formats/files/supportedFiles.js +18 -0
  44. package/dist/formats/files/translate.d.ts +4 -0
  45. package/dist/formats/files/translate.js +119 -0
  46. package/dist/formats/files/upload.d.ts +13 -0
  47. package/dist/formats/files/upload.js +136 -0
  48. package/dist/formats/gt/save.d.ts +9 -0
  49. package/dist/formats/gt/save.js +26 -0
  50. package/dist/formats/json/flattenJson.d.ts +14 -0
  51. package/dist/formats/json/flattenJson.js +64 -0
  52. package/dist/formats/json/mergeJson.d.ts +13 -0
  53. package/dist/formats/json/mergeJson.js +257 -0
  54. package/dist/formats/json/parseJson.d.ts +2 -0
  55. package/dist/formats/json/parseJson.js +108 -0
  56. package/dist/formats/json/utils.d.ts +47 -0
  57. package/dist/formats/json/utils.js +149 -0
  58. package/dist/formats/utils.d.ts +2 -0
  59. package/dist/formats/utils.js +24 -0
  60. package/dist/formats/yaml/mergeYaml.d.ts +5 -0
  61. package/dist/formats/yaml/mergeYaml.js +55 -0
  62. package/dist/formats/yaml/parseYaml.d.ts +5 -0
  63. package/dist/formats/yaml/parseYaml.js +23 -0
  64. package/dist/formats/yaml/utils.d.ts +2 -0
  65. package/dist/formats/yaml/utils.js +22 -0
  66. package/dist/fs/config/loadConfig.d.ts +1 -0
  67. package/dist/fs/config/loadConfig.js +9 -0
  68. package/dist/fs/config/parseFilesConfig.d.ts +27 -0
  69. package/dist/fs/config/parseFilesConfig.js +129 -0
  70. package/dist/fs/config/setupConfig.d.ts +17 -0
  71. package/dist/fs/config/setupConfig.js +50 -0
  72. package/dist/fs/config/updateConfig.d.ts +10 -0
  73. package/dist/fs/config/updateConfig.js +36 -0
  74. package/dist/fs/config/updateVersions.d.ts +10 -0
  75. package/dist/fs/config/updateVersions.js +30 -0
  76. package/dist/fs/copyFile.d.ts +7 -0
  77. package/dist/fs/copyFile.js +39 -0
  78. package/dist/fs/createLoadTranslationsFile.d.ts +1 -0
  79. package/dist/fs/createLoadTranslationsFile.js +36 -0
  80. package/dist/fs/determineFramework.d.ts +5 -0
  81. package/dist/fs/determineFramework.js +46 -0
  82. package/dist/fs/findFilepath.d.ts +36 -0
  83. package/dist/fs/findFilepath.js +89 -0
  84. package/dist/fs/getPackageResource.d.ts +1 -0
  85. package/dist/fs/getPackageResource.js +6 -0
  86. package/dist/fs/index.d.ts +1 -0
  87. package/dist/fs/index.js +1 -0
  88. package/dist/fs/loadJSON.d.ts +6 -0
  89. package/dist/fs/loadJSON.js +17 -0
  90. package/dist/fs/matchFiles.d.ts +1 -0
  91. package/dist/fs/matchFiles.js +8 -0
  92. package/dist/fs/saveJSON.d.ts +1 -0
  93. package/dist/fs/saveJSON.js +7 -0
  94. package/dist/fs/utils.d.ts +1 -0
  95. package/dist/fs/utils.js +16 -0
  96. package/dist/hooks/postProcess.d.ts +4 -0
  97. package/dist/hooks/postProcess.js +110 -0
  98. package/dist/index.d.ts +4 -0
  99. package/dist/index.js +20 -0
  100. package/dist/main.d.ts +2 -0
  101. package/dist/main.js +9 -0
  102. package/dist/next/config/parseNextConfig.d.ts +10 -0
  103. package/dist/next/config/parseNextConfig.js +53 -0
  104. package/dist/next/jsx/utils.d.ts +7 -0
  105. package/dist/next/jsx/utils.js +42 -0
  106. package/dist/next/parse/handleInitGT.d.ts +7 -0
  107. package/dist/next/parse/handleInitGT.js +208 -0
  108. package/dist/next/parse/wrapContent.d.ts +11 -0
  109. package/dist/next/parse/wrapContent.js +163 -0
  110. package/dist/react/config/createESBuildConfig.d.ts +2 -0
  111. package/dist/react/config/createESBuildConfig.js +119 -0
  112. package/dist/react/data-_gt/addGTIdentifierToSyntaxTree.d.ts +8 -0
  113. package/dist/react/data-_gt/addGTIdentifierToSyntaxTree.js +111 -0
  114. package/dist/react/jsx/evaluateJsx.d.ts +17 -0
  115. package/dist/react/jsx/evaluateJsx.js +85 -0
  116. package/dist/react/jsx/trimJsxStringChildren.d.ts +7 -0
  117. package/dist/react/jsx/trimJsxStringChildren.js +95 -0
  118. package/dist/react/jsx/utils/constants.d.ts +10 -0
  119. package/dist/react/jsx/utils/constants.js +31 -0
  120. package/dist/react/jsx/utils/parseAst.d.ts +30 -0
  121. package/dist/react/jsx/utils/parseAst.js +277 -0
  122. package/dist/react/jsx/utils/parseJsx.d.ts +21 -0
  123. package/dist/react/jsx/utils/parseJsx.js +244 -0
  124. package/dist/react/jsx/utils/parseStringFunction.d.ts +16 -0
  125. package/dist/react/jsx/utils/parseStringFunction.js +411 -0
  126. package/dist/react/jsx/utils/validateStringFunction.d.ts +7 -0
  127. package/dist/react/jsx/utils/validateStringFunction.js +31 -0
  128. package/dist/react/jsx/wrapJsx.d.ts +51 -0
  129. package/dist/react/jsx/wrapJsx.js +387 -0
  130. package/dist/react/parse/createDictionaryUpdates.d.ts +3 -0
  131. package/dist/react/parse/createDictionaryUpdates.js +169 -0
  132. package/dist/react/parse/createInlineUpdates.d.ts +6 -0
  133. package/dist/react/parse/createInlineUpdates.js +122 -0
  134. package/dist/react/parse/wrapContent.d.ts +11 -0
  135. package/dist/react/parse/wrapContent.js +162 -0
  136. package/dist/react/utils/flattenDictionary.d.ts +20 -0
  137. package/dist/react/utils/flattenDictionary.js +75 -0
  138. package/dist/react/utils/getEntryAndMetadata.d.ts +5 -0
  139. package/dist/react/utils/getEntryAndMetadata.js +11 -0
  140. package/dist/react/utils/getVariableName.d.ts +25 -0
  141. package/dist/react/utils/getVariableName.js +37 -0
  142. package/dist/setup/userInput.d.ts +4 -0
  143. package/dist/setup/userInput.js +29 -0
  144. package/dist/setup/wizard.d.ts +2 -0
  145. package/dist/setup/wizard.js +127 -0
  146. package/dist/translation/parse.d.ts +15 -0
  147. package/dist/translation/parse.js +76 -0
  148. package/dist/translation/stage.d.ts +2 -0
  149. package/dist/translation/stage.js +44 -0
  150. package/dist/translation/validate.d.ts +2 -0
  151. package/dist/translation/validate.js +50 -0
  152. package/dist/types/data/json.d.ts +6 -0
  153. package/dist/types/data/json.js +1 -0
  154. package/dist/types/data.d.ts +30 -0
  155. package/dist/types/data.js +1 -0
  156. package/dist/types/files.d.ts +1 -0
  157. package/dist/types/files.js +1 -0
  158. package/dist/types/index.d.ts +173 -0
  159. package/dist/types/index.js +1 -0
  160. package/dist/utils/addExplicitAnchorIds.d.ts +24 -0
  161. package/dist/utils/addExplicitAnchorIds.js +260 -0
  162. package/dist/utils/constants.d.ts +2 -0
  163. package/dist/utils/constants.js +2 -0
  164. package/dist/utils/credentials.d.ts +12 -0
  165. package/dist/utils/credentials.js +119 -0
  166. package/dist/utils/flattenJsonFiles.d.ts +2 -0
  167. package/dist/utils/flattenJsonFiles.js +36 -0
  168. package/dist/utils/gt.d.ts +2 -0
  169. package/dist/utils/gt.js +2 -0
  170. package/dist/utils/hash.d.ts +6 -0
  171. package/dist/utils/hash.js +11 -0
  172. package/dist/utils/headers.d.ts +1 -0
  173. package/dist/utils/headers.js +14 -0
  174. package/dist/utils/installPackage.d.ts +3 -0
  175. package/dist/utils/installPackage.js +77 -0
  176. package/dist/utils/localizeStaticImports.d.ts +15 -0
  177. package/dist/utils/localizeStaticImports.js +341 -0
  178. package/dist/utils/localizeStaticUrls.d.ts +19 -0
  179. package/dist/utils/localizeStaticUrls.js +432 -0
  180. package/dist/utils/packageInfo.d.ts +3 -0
  181. package/dist/utils/packageInfo.js +17 -0
  182. package/dist/utils/packageJson.d.ts +6 -0
  183. package/dist/utils/packageJson.js +76 -0
  184. package/dist/utils/packageManager.d.ts +28 -0
  185. package/dist/utils/packageManager.js +269 -0
  186. package/dist/utils/processAnchorIds.d.ts +6 -0
  187. package/dist/utils/processAnchorIds.js +47 -0
  188. package/dist/utils/sanitizeFileContent.d.ts +6 -0
  189. package/dist/utils/sanitizeFileContent.js +29 -0
  190. package/dist/utils/validateMdx.d.ts +10 -0
  191. package/dist/utils/validateMdx.js +25 -0
  192. package/package.json +3 -3
@@ -0,0 +1,76 @@
1
+ import fs from 'fs';
2
+ import { logError } from '../console/logging.js';
3
+ import loadJSON from '../fs/loadJSON.js';
4
+ import { createDictionaryUpdates } from '../react/parse/createDictionaryUpdates.js';
5
+ import { createInlineUpdates } from '../react/parse/createInlineUpdates.js';
6
+ import createESBuildConfig from '../react/config/createESBuildConfig.js';
7
+ import chalk from 'chalk';
8
+ /**
9
+ * Searches for gt-react or gt-next dictionary files and creates updates for them,
10
+ * as well as inline updates for <T> tags and useGT()/getGT() calls
11
+ *
12
+ * @param options - The options object
13
+ * @param sourceDictionary - The source dictionary file path
14
+ * @param pkg - The package name
15
+ * @returns An object containing the updates and errors
16
+ */
17
+ export async function createUpdates(options, src, sourceDictionary, pkg, validate) {
18
+ let updates = [];
19
+ let errors = [];
20
+ let warnings = [];
21
+ // Parse dictionary with esbuildConfig
22
+ if (sourceDictionary &&
23
+ fs.existsSync(sourceDictionary) &&
24
+ fs.statSync(sourceDictionary).isFile()) {
25
+ if (sourceDictionary.endsWith('.json')) {
26
+ updates = [
27
+ ...updates,
28
+ ...(await createDictionaryUpdates(sourceDictionary)),
29
+ ];
30
+ }
31
+ else {
32
+ let esbuildConfig;
33
+ if (options.jsconfig) {
34
+ const jsconfig = loadJSON(options.jsconfig);
35
+ if (!jsconfig) {
36
+ logError(`Failed to resolve jsconfig.json or tsconfig.json at provided filepath: "${options.jsconfig}"`);
37
+ process.exit(1);
38
+ }
39
+ esbuildConfig = createESBuildConfig(jsconfig);
40
+ }
41
+ else {
42
+ esbuildConfig = createESBuildConfig({});
43
+ }
44
+ updates = [
45
+ ...updates,
46
+ ...(await createDictionaryUpdates(sourceDictionary, esbuildConfig)),
47
+ ];
48
+ }
49
+ }
50
+ // Scan through project for <T> tags
51
+ const { updates: newUpdates, errors: newErrors, warnings: newWarnings, } = await createInlineUpdates(pkg, validate, src);
52
+ errors = [...errors, ...newErrors];
53
+ warnings = [...warnings, ...newWarnings];
54
+ updates = [...updates, ...newUpdates];
55
+ // Metadata addition and validation
56
+ const idHashMap = new Map();
57
+ const duplicateIds = new Set();
58
+ updates = updates.map((update) => {
59
+ if (!update.metadata.id)
60
+ return update;
61
+ const existingHash = idHashMap.get(update.metadata.id);
62
+ if (existingHash) {
63
+ if (existingHash !== update.metadata.hash) {
64
+ errors.push(`Hashes don't match on two components with the same id: ${chalk.blue(update.metadata.id)}. Check your ${chalk.green('<T>')} tags and dictionary entries and make sure you're not accidentally duplicating IDs.`);
65
+ duplicateIds.add(update.metadata.id);
66
+ }
67
+ }
68
+ else {
69
+ idHashMap.set(update.metadata.id, update.metadata.hash);
70
+ }
71
+ return update;
72
+ });
73
+ // Filter out updates with duplicate IDs
74
+ updates = updates.filter((update) => !duplicateIds.has(update.metadata.id));
75
+ return { updates, errors, warnings };
76
+ }
@@ -0,0 +1,2 @@
1
+ import { Settings, TranslateFlags, Updates } from '../types/index.js';
2
+ export declare function aggregateReactTranslations(options: TranslateFlags, settings: Settings, library: 'gt-react' | 'gt-next'): Promise<Updates>;
@@ -0,0 +1,44 @@
1
+ import { logErrorAndExit } from '../console/logging.js';
2
+ import chalk from 'chalk';
3
+ import findFilepath from '../fs/findFilepath.js';
4
+ import { logWarning, logError } from '../console/logging.js';
5
+ import { createUpdates } from './parse.js';
6
+ export async function aggregateReactTranslations(options, settings, library) {
7
+ if (!options.dictionary) {
8
+ options.dictionary = findFilepath([
9
+ './dictionary.js',
10
+ './src/dictionary.js',
11
+ './dictionary.json',
12
+ './src/dictionary.json',
13
+ './dictionary.ts',
14
+ './src/dictionary.ts',
15
+ ]);
16
+ }
17
+ // ---- CREATING UPDATES ---- //
18
+ const { updates, errors, warnings } = await createUpdates(options, settings.src, options.dictionary, library, false);
19
+ if (warnings.length > 0) {
20
+ logWarning(chalk.yellow(`CLI tool encountered ${warnings.length} warnings while scanning for translatable content.\n` +
21
+ warnings
22
+ .map((warning) => chalk.yellow('• Warning: ') + chalk.white(warning))
23
+ .join('\n')));
24
+ }
25
+ if (errors.length > 0) {
26
+ if (options.ignoreErrors) {
27
+ logWarning(chalk.yellow(`Warning: CLI tool encountered ${errors.length} syntax errors while scanning for translatable content. These components will not be translated.\n` +
28
+ errors
29
+ .map((error) => chalk.yellow('• ') + chalk.white(error) + '\n')
30
+ .join('')));
31
+ }
32
+ else {
33
+ logErrorAndExit(chalk.red(`Error: CLI tool encountered ${errors.length} syntax errors while scanning for translatable content. ${chalk.gray('To ignore these errors, re-run with --ignore-errors')}\n` +
34
+ errors
35
+ .map((error) => chalk.red('• ') + chalk.white(error) + '\n')
36
+ .join('')));
37
+ }
38
+ }
39
+ if (updates.length == 0) {
40
+ logError(chalk.red(`No in-line content or dictionaries were found for ${chalk.green(library)}. Are you sure you're running this command in the right directory?`));
41
+ return updates;
42
+ }
43
+ return updates;
44
+ }
@@ -0,0 +1,2 @@
1
+ import { Options, Settings } from '../types/index.js';
2
+ export declare function validateProject(settings: Options & Settings, pkg: 'gt-react' | 'gt-next', files?: string[]): Promise<void>;
@@ -0,0 +1,50 @@
1
+ import { logErrorAndExit, logWarning } from '../console/logging.js';
2
+ import chalk from 'chalk';
3
+ import findFilepath from '../fs/findFilepath.js';
4
+ import { logError, logSuccess } from '../console/logging.js';
5
+ import { createUpdates } from './parse.js';
6
+ import { createInlineUpdates } from '../react/parse/createInlineUpdates.js';
7
+ export async function validateProject(settings, pkg, files) {
8
+ if (files && files.length > 0) {
9
+ // Validate specific files using createInlineUpdates
10
+ const { errors, updates } = await createInlineUpdates(pkg, true, files);
11
+ if (errors.length > 0) {
12
+ logErrorAndExit(chalk.red(`Error: CLI tool encountered ${errors.length} syntax errors:\n` +
13
+ errors
14
+ .map((error) => chalk.red('• ') + chalk.white(error) + '\n')
15
+ .join('')));
16
+ }
17
+ logSuccess(chalk.green(`Success! Found ${updates.length} translatable entries.`));
18
+ return;
19
+ }
20
+ if (!settings.dictionary) {
21
+ settings.dictionary = findFilepath([
22
+ './dictionary.js',
23
+ './src/dictionary.js',
24
+ './dictionary.json',
25
+ './src/dictionary.json',
26
+ './dictionary.ts',
27
+ './src/dictionary.ts',
28
+ ]);
29
+ }
30
+ const { updates, errors, warnings } = await createUpdates(settings, settings.src, settings.dictionary, pkg, true);
31
+ if (warnings.length > 0) {
32
+ logWarning(chalk.yellow(`CLI tool encountered ${warnings.length} warnings while scanning for translatable content.`) +
33
+ '\n' +
34
+ warnings
35
+ .map((warning) => chalk.yellow('• ') + chalk.white(warning))
36
+ .join('\n'));
37
+ }
38
+ if (errors.length > 0) {
39
+ logErrorAndExit(chalk.red(`Error: CLI tool encountered ${errors.length} syntax errors while scanning for translatable content.\n` +
40
+ errors
41
+ .map((error) => chalk.red('• ') + chalk.white(error) + '\n')
42
+ .join('')));
43
+ }
44
+ if (updates.length === 0) {
45
+ logError(chalk.red(`No in-line content or dictionaries were found for ${chalk.green(pkg)}. Are you sure you're running this command in the right directory?`));
46
+ }
47
+ else {
48
+ logSuccess(chalk.green(`Success! Found ${updates.length} translatable entries for ${chalk.green(pkg)}.`));
49
+ }
50
+ }
@@ -0,0 +1,6 @@
1
+ type JSONValue = string | number | boolean | null | JSONObject | JSONArray;
2
+ export type JSONObject = {
3
+ [key: string]: JSONValue;
4
+ };
5
+ export type JSONArray = JSONValue[];
6
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,30 @@
1
+ export type Entry = string;
2
+ export type DictionaryMetadata = {
3
+ context?: string;
4
+ variablesOptions?: Record<string, any>;
5
+ [key: string]: any;
6
+ };
7
+ export type DictionaryEntry = Entry | [Entry] | [Entry, DictionaryMetadata];
8
+ export type Dictionary = {
9
+ [key: string]: Dictionary | DictionaryEntry;
10
+ };
11
+ export type FlattenedDictionary = {
12
+ [key: string]: DictionaryEntry;
13
+ };
14
+ export type JSONDictionary = {
15
+ [key: string]: string | JSONDictionary;
16
+ };
17
+ export type FlattenedJSONDictionary = {
18
+ [key: string]: string;
19
+ };
20
+ export type { FileFormat, DataFormat, FileToTranslate, } from 'generaltranslation/types';
21
+ export type JsxChildren = string | string[] | any;
22
+ export type Translations = {
23
+ [key: string]: JsxChildren;
24
+ };
25
+ export type TranslationsMetadata = {
26
+ [key: string]: {
27
+ id?: string;
28
+ hash?: string;
29
+ };
30
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export type FileMapping = Record<string, Record<string, string>>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,173 @@
1
+ import { CustomMapping } from 'generaltranslation/types';
2
+ import { SUPPORTED_FILE_EXTENSIONS } from '../formats/files/supportedFiles.js';
3
+ export type { Updates } from 'generaltranslation/types';
4
+ export type Options = {
5
+ config: string;
6
+ apiKey?: string;
7
+ projectId?: string;
8
+ versionId?: string;
9
+ jsconfig?: string;
10
+ dictionary?: string;
11
+ src?: string[];
12
+ defaultLocale?: string;
13
+ locales?: string[];
14
+ baseUrl: string;
15
+ inline?: boolean;
16
+ ignoreErrors: boolean;
17
+ suppressWarnings: boolean;
18
+ dryRun: boolean;
19
+ timeout: number;
20
+ force?: boolean;
21
+ stageTranslations?: boolean;
22
+ experimentalLocalizeStaticUrls?: boolean;
23
+ experimentalHideDefaultLocale?: boolean;
24
+ experimentalFlattenJsonFiles?: boolean;
25
+ experimentalLocalizeStaticImports?: boolean;
26
+ experimentalAddHeaderAnchorIds?: 'mintlify';
27
+ };
28
+ export type TranslateFlags = {
29
+ config?: string;
30
+ apiKey?: string;
31
+ projectId?: string;
32
+ versionId?: string;
33
+ jsconfig?: string;
34
+ dictionary?: string;
35
+ defaultLocale?: string;
36
+ locales?: string[];
37
+ ignoreErrors?: boolean;
38
+ src?: string[];
39
+ timeout: number;
40
+ dryRun: boolean;
41
+ stageTranslations?: boolean;
42
+ publish?: boolean;
43
+ force?: boolean;
44
+ experimentalLocalizeStaticUrls?: boolean;
45
+ experimentalHideDefaultLocale?: boolean;
46
+ experimentalFlattenJsonFiles?: boolean;
47
+ experimentalLocalizeStaticImports?: boolean;
48
+ experimentalAddHeaderAnchorIds?: 'mintlify';
49
+ excludeStaticUrls?: string[];
50
+ excludeStaticImports?: string[];
51
+ };
52
+ export type WrapOptions = {
53
+ src?: string[];
54
+ config: string;
55
+ skipTs: boolean;
56
+ disableIds: boolean;
57
+ disableFormatting: boolean;
58
+ addGTProvider: boolean;
59
+ };
60
+ export type SetupOptions = {
61
+ src?: string[];
62
+ config: string;
63
+ };
64
+ export type GenerateSourceOptions = {
65
+ src?: string[];
66
+ config: string;
67
+ defaultLocale: string;
68
+ dictionary?: string;
69
+ jsconfig?: string;
70
+ inline?: boolean;
71
+ ignoreErrors: boolean;
72
+ suppressWarnings: boolean;
73
+ };
74
+ export type Framework = 'gt-next' | 'gt-react';
75
+ export type SupportedFrameworks = 'next-app' | 'next-pages' | 'vite' | 'gatsby' | 'react' | 'redwood';
76
+ export type SupportedLibraries = 'gt-next' | 'gt-react' | 'next-intl' | 'react-i18next' | 'next-i18next' | 'i18next' | 'i18next-icu' | 'base';
77
+ export interface ContentScanner {
78
+ scanForContent(options: WrapOptions, framework: Framework): Promise<{
79
+ errors: string[];
80
+ filesUpdated: string[];
81
+ warnings: string[];
82
+ }>;
83
+ }
84
+ export type SupportedFileExtension = (typeof SUPPORTED_FILE_EXTENSIONS)[number];
85
+ export type ResolvedFiles = {
86
+ [K in SupportedFileExtension]?: string[];
87
+ } & {
88
+ gt?: string;
89
+ };
90
+ export type TransformOption = {
91
+ match?: string;
92
+ replace: string;
93
+ };
94
+ export type TransformFiles = {
95
+ [K in SupportedFileExtension]?: TransformOption | string;
96
+ };
97
+ export type FilesOptions = {
98
+ [K in SupportedFileExtension]?: {
99
+ include: string[];
100
+ exclude?: string[];
101
+ transform?: string | TransformOption;
102
+ };
103
+ } & {
104
+ gt?: {
105
+ output: string;
106
+ };
107
+ };
108
+ export type Settings = {
109
+ config: string;
110
+ configDirectory: string;
111
+ baseUrl: string;
112
+ dashboardUrl: string;
113
+ apiKey?: string;
114
+ projectId?: string;
115
+ defaultLocale: string;
116
+ locales: string[];
117
+ customMapping?: CustomMapping;
118
+ files: {
119
+ resolvedPaths: ResolvedFiles;
120
+ placeholderPaths: ResolvedFiles;
121
+ transformPaths: TransformFiles;
122
+ } | undefined;
123
+ stageTranslations: boolean;
124
+ publish: boolean;
125
+ _versionId?: string;
126
+ version?: string;
127
+ description?: string;
128
+ src: string[];
129
+ framework?: SupportedFrameworks;
130
+ options?: AdditionalOptions;
131
+ modelProvider?: string;
132
+ };
133
+ export type AdditionalOptions = {
134
+ jsonSchema?: {
135
+ [fileGlob: string]: JsonSchema;
136
+ };
137
+ yamlSchema?: {
138
+ [fileGlob: string]: YamlSchema;
139
+ };
140
+ docsUrlPattern?: string;
141
+ docsImportPattern?: string;
142
+ excludeStaticUrls?: string[];
143
+ excludeStaticImports?: string[];
144
+ docsHideDefaultLocaleImport?: boolean;
145
+ copyFiles?: string[];
146
+ experimentalLocalizeStaticImports?: boolean;
147
+ experimentalLocalizeStaticUrls?: boolean;
148
+ experimentalAddHeaderAnchorIds?: 'mintlify';
149
+ experimentalHideDefaultLocale?: boolean;
150
+ experimentalFlattenJsonFiles?: boolean;
151
+ baseDomain?: string;
152
+ };
153
+ export type JsonSchema = {
154
+ preset?: 'mintlify';
155
+ include?: string[];
156
+ composite?: {
157
+ [sourceObjectPath: string]: SourceObjectOptions;
158
+ };
159
+ };
160
+ export type YamlSchema = {
161
+ preset?: 'mintlify';
162
+ include?: string[];
163
+ };
164
+ export type SourceObjectOptions = {
165
+ type: 'array' | 'object';
166
+ include: string[];
167
+ key?: string;
168
+ localeProperty?: string;
169
+ transform?: TransformOptions;
170
+ };
171
+ export type TransformOptions = {
172
+ [transformPath: string]: TransformOption;
173
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Represents a heading with its position and metadata
3
+ */
4
+ export interface HeadingInfo {
5
+ text: string;
6
+ level: number;
7
+ slug: string;
8
+ position: number;
9
+ }
10
+ /**
11
+ * Extracts heading information from content (read-only, no modifications)
12
+ */
13
+ export declare function extractHeadingInfo(mdxContent: string): HeadingInfo[];
14
+ /**
15
+ * Applies anchor IDs to translated content based on source heading mapping
16
+ */
17
+ export declare function addExplicitAnchorIds(translatedContent: string, sourceHeadingMap: HeadingInfo[], settings?: any, sourcePath?: string, translatedPath?: string): {
18
+ content: string;
19
+ hasChanges: boolean;
20
+ addedIds: Array<{
21
+ heading: string;
22
+ id: string;
23
+ }>;
24
+ };