gt 2.27.3 → 2.28.1

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 (37) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/api/collectUserEditDiffs.js +77 -2
  3. package/dist/api/collectUserEditDiffs.js.map +1 -1
  4. package/dist/cli/base.d.ts +2 -0
  5. package/dist/cli/base.js +9 -5
  6. package/dist/cli/base.js.map +1 -1
  7. package/dist/cli/commands/setupProject.js +2 -0
  8. package/dist/cli/commands/setupProject.js.map +1 -1
  9. package/dist/cli/commands/stage.js +2 -0
  10. package/dist/cli/commands/stage.js.map +1 -1
  11. package/dist/cli/commands/upload.js +2 -0
  12. package/dist/cli/commands/upload.js.map +1 -1
  13. package/dist/generated/version.d.ts +1 -1
  14. package/dist/generated/version.js +1 -1
  15. package/dist/generated/version.js.map +1 -1
  16. package/dist/locadex/setupFlow.js +1 -1
  17. package/dist/locadex/setupFlow.js.map +1 -1
  18. package/dist/paraglide/collectParaglideContext.d.ts +5 -0
  19. package/dist/paraglide/collectParaglideContext.js +43 -0
  20. package/dist/paraglide/collectParaglideContext.js.map +1 -0
  21. package/dist/setup/developmentCredentials.d.ts +3 -1
  22. package/dist/setup/developmentCredentials.js +6 -2
  23. package/dist/setup/developmentCredentials.js.map +1 -1
  24. package/dist/setup/onboarding.d.ts +6 -2
  25. package/dist/setup/onboarding.js +8 -4
  26. package/dist/setup/onboarding.js.map +1 -1
  27. package/dist/setup/wizard.d.ts +8 -2
  28. package/dist/setup/wizard.js +26 -1
  29. package/dist/setup/wizard.js.map +1 -1
  30. package/dist/types/index.d.ts +2 -2
  31. package/dist/types/index.js.map +1 -1
  32. package/dist/types/parsing.d.ts +8 -1
  33. package/dist/types/parsing.js.map +1 -1
  34. package/dist/utils/resolveMintlifyRefs.d.ts +5 -0
  35. package/dist/utils/resolveMintlifyRefs.js +26 -8
  36. package/dist/utils/resolveMintlifyRefs.js.map +1 -1
  37. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../src/types/index.ts"],"sourcesContent":["import type { CustomMapping } from '@generaltranslation/format/types';\nimport type { UserTokenProvider } from 'generaltranslation/api';\nimport type { ModelProvider } from 'generaltranslation/internal';\nimport type { FileFormat } from 'generaltranslation/types';\nimport { SUPPORTED_FILE_EXTENSIONS } from '../formats/files/supportedFiles.js';\nimport {\n ParsingConfigOptions,\n GTParsingFlags,\n BaseParsingFlags,\n ParseFlagsByFileType,\n} from './parsing.js';\nimport { Libraries, InlineLibrary } from './libraries.js';\n\nexport type { Updates } from 'generaltranslation/types';\n\nexport type Options = {\n config: string;\n apiKey?: string;\n projectId?: string;\n versionId?: string;\n jsconfig?: string;\n dictionary?: string;\n src?: string[];\n defaultLocale?: string;\n locales?: string[];\n baseUrl: string;\n inline?: boolean;\n ignoreErrors: boolean;\n suppressWarnings: boolean;\n dryRun: boolean;\n timeout: number;\n force?: boolean;\n stageTranslations?: boolean;\n experimentalLocalizeStaticUrls?: boolean;\n experimentalHideDefaultLocale?: boolean;\n experimentalFlattenJsonFiles?: boolean;\n experimentalLocalizeStaticImports?: boolean;\n experimentalLocalizeRelativeAssets?: boolean;\n experimentalAddHeaderAnchorIds?: 'mintlify' | 'default';\n docsImportRewrites?: Array<{\n match: string;\n replace: string;\n }>;\n};\n\nexport type OpenApiConfig = {\n files: string[];\n translateFields?: string[];\n};\n\nexport type MintlifyOptions = {\n openapi?: OpenApiConfig;\n inferTitleFromFilename?: boolean;\n localizeRedirects?: boolean; // add localized redirects for pages renamed or removed in a translate run\n};\n\nexport type SharedFlags = {\n config?: string;\n apiKey?: string;\n projectId?: string;\n};\n\nexport type TranslateFlags = SharedFlags & {\n versionId?: string;\n jsconfig?: string;\n dictionary?: string;\n defaultLocale?: string;\n locales?: string[];\n ignoreErrors?: boolean;\n src?: string[];\n timeout: number;\n dryRun: boolean;\n saveLocal?: boolean;\n stageTranslations?: boolean;\n setupProject?: boolean; // if true, skip enqueue step\n publish?: boolean;\n force?: boolean;\n forceDownload?: boolean;\n tag?: string;\n message?: string;\n experimentalLocalizeStaticUrls?: boolean;\n experimentalHideDefaultLocale?: boolean;\n experimentalFlattenJsonFiles?: boolean;\n experimentalLocalizeStaticImports?: boolean;\n experimentalLocalizeRelativeAssets?: boolean;\n experimentalAddHeaderAnchorIds?: 'mintlify' | 'default';\n omitConfigIds?: boolean;\n excludeStaticUrls?: string[];\n excludeStaticImports?: string[];\n docsImportRewrites?: Array<{\n match: string;\n replace: string;\n }>;\n};\n\nexport type WrapOptions = {\n src?: string[];\n config: string;\n skipTs: boolean;\n disableIds: boolean;\n disableFormatting: boolean;\n addGTProvider: boolean;\n};\n\nexport type SetupOptions = {\n src?: string[];\n config: string;\n};\n\nexport type GenerateSourceOptions = {\n src?: string[];\n config: string;\n defaultLocale: string;\n dictionary?: string;\n jsconfig?: string;\n inline?: boolean;\n ignoreErrors: boolean;\n suppressWarnings: boolean;\n};\n\nexport type Framework =\n | typeof Libraries.GT_NEXT\n | typeof Libraries.GT_REACT\n | typeof Libraries.GT_REACT_NATIVE\n | typeof Libraries.GT_TANSTACK_START;\n\nexport const SUPPORTED_REACT_FRAMEWORKS = [\n 'next-app',\n 'next-pages',\n 'vite',\n 'gatsby',\n 'react',\n 'redwood',\n 'tanstack-start',\n 'react-router',\n] as const;\n\nexport type FrameworkObject =\n | {\n name: 'mintlify';\n type?: undefined;\n }\n | {\n name: (typeof SUPPORTED_REACT_FRAMEWORKS)[number];\n type: 'react';\n };\nexport type ReactFrameworkObject = Extract<FrameworkObject, { type: 'react' }>;\n/** Detected so setup can stop; the wizard cannot set React Native up yet. */\nexport type ReactNativeFrameworkObject = {\n name: 'react-native';\n type: 'react-native';\n};\n\nexport type FrameworkType = FrameworkObject['type'];\n\nexport type SupportedFrameworks = FrameworkObject['name'];\nexport type SupportedReactFrameworks = Extract<\n FrameworkObject,\n { type: 'react' }\n>['name'];\n\nexport type SupportedLibraries =\n | InlineLibrary\n | 'next-intl'\n | 'react-i18next'\n | 'next-i18next'\n | 'i18next'\n | 'i18next-icu'\n | 'base';\n\nexport interface ContentScanner {\n scanForContent(\n options: WrapOptions,\n framework: Framework\n ): Promise<{\n errors: string[];\n filesUpdated: string[];\n warnings: string[];\n }>;\n}\n\n// Create a type based on the supported file extensions\nexport type SupportedFileExtension = (typeof SUPPORTED_FILE_EXTENSIONS)[number];\n\n// Update ResolvedFiles to use the dynamic keys\nexport type ResolvedFiles = {\n [K in SupportedFileExtension]?: string[];\n} & {\n gt?: string; // Output glob: /path/[locale].json\n};\n\nexport type TransformOption = {\n match?: string; // regex to match strings, supports capture groups\n replace: string; // string or regex pattern to replace the match with\n // Special placeholders:\n // -> if used in the match string, they will be replaced with the corresponding default locale property value\n // -> if used in the replace string, they will be replaced with the corresponding target locale property value\n // {locale} -> will be replaced with the locale code\n // And any other property from getLocaleProperties()\n};\n\nexport type TransformFiles = {\n [K in SupportedFileExtension]?: TransformOption | string | TransformOption[]; // if a string, only transform the file name\n};\n\nexport type TransformFormats = {\n [K in SupportedFileExtension]?: FileFormat;\n};\n\n// Include patterns can be plain strings or objects with a publish flag\nexport type IncludePattern = string | { pattern: string; publish?: boolean };\n\n// Review requirement for matched files: a boolean applies to all files of the\n// type; the object form opts path groups in/out with globs. exclude wins over\n// include; files matching neither inherit the top-level requiresReview default.\nexport type RequiresReviewConfig =\n | boolean\n | {\n include?: string[];\n exclude?: string[];\n };\n\n// Update FilesOptions to fix the error\nexport type FilesOptions = {\n [K in SupportedFileExtension]?: {\n include: IncludePattern[];\n exclude?: string[];\n transform?: string | TransformOption | TransformOption[];\n transformationFormat?: FileFormat;\n parsingFlags?: BaseParsingFlags; // Flags for parsing inline content\n requiresReview?: RequiresReviewConfig; // Whether translated versions of matched files require approval before use\n };\n} & {\n gt?: {\n output: string; // Output glob: /path/[locale].json\n publish?: boolean; // if true, publish gtjson translations to the CDN\n parsingFlags?: Partial<GTParsingFlags>; // Flags for parsing inline content\n /**\n * @deprecated\n * use `files.gt.parsingFlags.includeSourceCodeContext` instead\n */\n includeSourceCodeContext?: boolean; // Include surrounding source code lines as context for translations (default: false)\n };\n};\n\n// Shared settings between all API-related commands\nexport type FontsConfig = {\n include: string[]; // globs of .ttf/.otf files\n exclude?: string[];\n};\n\nexport type Settings = {\n config: string;\n configDirectory: string;\n baseUrl: string;\n dashboardUrl: string;\n apiKey?: string;\n userTokenProvider?: UserTokenProvider;\n projectId?: string;\n defaultLocale: string;\n locales: string[];\n customMapping?: CustomMapping;\n files: {\n resolvedPaths: ResolvedFiles; // Absolute resolved paths for the default locale\n placeholderPaths: ResolvedFiles; // Absolute placeholder paths for all locales containing [locale]\n transformPaths: TransformFiles; // Absolute transform paths for all locales containing [locale]\n transformFormats: TransformFormats; // Output file format transforms keyed by config file type\n publishPaths: Set<string>; // Absolute paths explicitly opted IN to publishing\n unpublishPaths: Set<string>; // Absolute paths explicitly opted OUT of publishing\n requiresReviewPaths: Set<string>; // Absolute paths whose effective requiresReview policy is true\n parsingFlags: ParseFlagsByFileType;\n gtJson: {\n publish?: boolean; // if true, publish gtjson translations to the CDN\n parsingFlags: GTParsingFlags; // Flags for parsing inline content\n /**\n * @deprecated\n * use {@link files.gt.GTParsingFlags.parsingFlags.includeSourceCodeContext} instead\n */\n includeSourceCodeContext?: boolean; // Include surrounding source code lines as context for translations (default: false)\n };\n };\n stageTranslations: boolean; // if true, always stage the project during translate command\n requiresReview?: boolean; // top-level default: translated artifacts require approval before the client uses them\n publish?: boolean; // if true, publish the translations to the CDN; undefined means no global publish intent\n omitConfigIds?: boolean; // if true, do not write _versionId or _branchId to gt.config.json\n _versionId?: string; // internal use only\n _branchId?: string; // internal use only\n version?: string; // for specifying a custom version id to use. Should be unique\n description?: string;\n src?: string[]; // list of glob patterns for source file scanning\n fonts?: FontsConfig; // fonts to sync to the API before translating\n framework?: SupportedFrameworks;\n options?: AdditionalOptions;\n modelProvider?: ModelProvider;\n tag?: string;\n tagMessage?: string;\n parsingOptions: ParsingConfigOptions;\n branchOptions: BranchOptions;\n // Optional shared static assets config\n sharedStaticAssets?: SharedStaticAssetsConfig;\n};\n\nexport type StaticLocalizationFiles = Pick<\n Settings['files'],\n 'placeholderPaths' | 'resolvedPaths'\n> &\n Partial<Pick<Settings['files'], 'transformPaths' | 'transformFormats'>>;\n\nexport type StaticLocalizationSettings = Pick<\n Settings,\n 'defaultLocale' | 'locales' | 'options'\n> & {\n files?: StaticLocalizationFiles | null;\n};\n\nexport type BranchOptions = {\n currentBranch?: string;\n autoDetectBranches?: boolean;\n remoteName: string; // default 'origin'. The name of the remote to use for auto-detection.\n enabled: boolean; // if true, branching is enabled for the project\n};\n\nexport type AdditionalOptions = {\n // Optional schema to follow while translating JSON files\n jsonSchema?: {\n [fileGlob: string]: JsonSchema;\n };\n // Optional schema to follow while translating YAML files\n yamlSchema?: {\n [fileGlob: string]: YamlSchema;\n };\n // Skip pre-parse validation checks for specific file types\n skipFileValidation?: {\n json?: boolean;\n yaml?: boolean;\n mdx?: boolean;\n };\n // Optional Mintlify-specific options container\n mintlify?: MintlifyOptions;\n docsUrlPattern?: string | string[]; // eg /docs/[locale] or /[locale] for localizing static urls in markdown files; a list localizes several URL prefixes\n docsImportPattern?: string; // eg /docs/[locale]/foo.md or /[locale]/foo.md for localizing static imports in markdown files\n excludeStaticUrls?: string[]; // A list of file globs to include for static url localization\n excludeStaticImports?: string[]; // A list of file globs to include for static import localization\n docsHideDefaultLocaleImport?: boolean; // if true, hide the default locale in the import path\n copyFiles?: string[]; // array of files to copy to the target locale\n experimentalClearLocaleDirs?: boolean; // if true, clear locale directories before writing translations (default: false)\n clearLocaleDirsExclude?: string[]; // array of glob patterns with [locale] or [locales] placeholder to exclude from clearing (e.g., \"./snippets/[locale]/preserved/**\" or \"./[locales]/static/**\")\n experimentalLocalizeStaticImports?: boolean; // Inserts locale in static import paths in md/mdx files\n // Inserts locale in static url paths in md/mdx files and adds anchor IDs to\n // preserve navigation. The object form enables it with extra behavior.\n experimentalLocalizeStaticUrls?:\n | boolean\n | {\n // Keep links to source pages that have no translation\n skipUntranslatedPages?: boolean;\n // Extra JSX attribute names or globs to localize\n attributes?: string[];\n };\n experimentalLocalizeRelativeAssets?: boolean; // Rewrites relative asset URLs in translated md/mdx files to valid paths\n experimentalAddHeaderAnchorIds?: 'mintlify' | 'default'; // Format for anchor IDs: 'mintlify' for Mintlify's native {#id} on every heading, 'default' or undefined for escaped inline \\{#id\\}. Can run independently of static url localization\n experimentalHideDefaultLocale?: boolean; // Hides the default locale in the import path\n experimentalFlattenJsonFiles?: boolean; // Flattens JSON files into a single file\n baseDomain?: string; // The base http:// url where the project is hosted\n docsImportRewrites?: Array<{\n match: string; // prefix to match, e.g. '@site/docs'\n replace: string; // replacement prefix, can include [locale] or [defaultLocale]\n }>;\n experimentalCanonicalLocaleKeys?: boolean; // For composite JSON schemas with locale keys, force canonical locale even when alias provided\n saveLocal?: boolean; // if true, detect and save local edits to translated output before enqueuing translations (default: false)\n};\n\nexport type SharedStaticAssetsConfig = {\n include: string | string[];\n outDir?: string;\n publicPath?: string;\n mirrorToLocales?: boolean;\n};\n\nexport type StructuralTransform = {\n sourcePointer: string; // e.g., \"/msg\"\n destinationPointer: string; // e.g., \"/translations/en\"\n};\n\nexport type JsonSchema = {\n preset?: 'mintlify' | 'mintlify-hide-default' | 'openapi';\n structuralTransform?: StructuralTransform[];\n\n // when true, resolve $ref entries in this file before processing\n resolveRefs?: boolean;\n\n // exactly 1 of include or composite must be provided; not both\n\n // specify include if file is not composite\n // multiple target JSONs will be created for each locale,\n // with the only differing content being the specified JSONPath values\n include?: string[]; // array of JSONPaths to include\n\n // specify composite if no new JSONs should be created\n composite?: {\n // The sourceObjectPath is a JSONPath to the array or object containing\n // content in the source and target locales\n // This value is denoted as the \"sourceObject\"\n // Array elements or object sub-elements are denoted as \"sourceItem\"\n [sourceObjectPath: string]: SourceObjectOptions;\n };\n};\n\nexport type YamlSchema = {\n preset?: 'mintlify' | 'openapi';\n include?: string[];\n transform?: TransformOptions;\n};\n\nexport type SourceObjectOptions = {\n type: 'array' | 'object'; // type of the sourceObject;\n // array if the sourceObject is an array\n // -> We will simply add duplicated sourceItems for each locale\n // object if the sourceObject is an object\n // -> We will duplicate the sourceItem for each locale and set the corresponding\n // key with the locale property\n // In both cases, we search the sourceObject for the key that matches the source locale\n\n // Below, relative JSONPaths are relative to the sourceItem root, NOT the sourceObject\n\n include: string[]; // array of relative JSONPaths to include in the translated JSON\n\n // if type is array, there must be a key property in the array element\n // corresponding value should be a locale code\n key?: string; // relative jsonPath to the key to use to distinguish between source and target locales\n // if type is object, the key is simply the JSON key for the sourceItem - this is unnecessary in this case\n\n localeProperty?: string; // specific locale property to use for the key for target locales, default 'code'\n // ex: code, name, nativeName, languageCode, languageName, etc. (values returned by getLocaleProperties)\n\n // optional config for transforming specific fields in the sourceItem\n // for example, helpful for handling urls with locale-specific paths\n transform?: TransformOptions;\n\n // optional list of top-level properties to remove from generated\n // non-default-locale entries (e.g. Mintlify's `default: true` flag on the\n // default language entry, which must not be cloned into other locales)\n omitProperties?: string[];\n\n // optional sorting behavior for array sourceObjects. When set to 'locale',\n // the array will be ordered to match the locales array provided to mergeJson\n // When set to 'localesAlphabetical', the default locale will be placed first\n // and the remaining locales will be ordered alphabetically by locale code\n experimentalSort?: 'locales' | 'localesAlphabetical';\n\n // when true, non-default keyed entries in this composite array are extracted\n // into separate files (using the key value as the directory name) and replaced\n // with $ref pointers. Keeps the source file compact.\n splitEntries?: boolean;\n};\n\nexport type TransformOptions = {\n // relative jsonPath to content to mutate\n [transformPath: string]: TransformOption;\n};\n"],"mappings":";AA8HA,MAAa,6BAA6B;CACxC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/types/index.ts"],"sourcesContent":["import type { CustomMapping } from '@generaltranslation/format/types';\nimport type { UserTokenProvider } from 'generaltranslation/api';\nimport type { ModelProvider } from 'generaltranslation/internal';\nimport type { FileFormat } from 'generaltranslation/types';\nimport { SUPPORTED_FILE_EXTENSIONS } from '../formats/files/supportedFiles.js';\nimport {\n ParsingConfigOptions,\n GTParsingFlags,\n ParsingFlagsFor,\n ParseFlagsByFileType,\n} from './parsing.js';\nimport { Libraries, InlineLibrary } from './libraries.js';\n\nexport type { Updates } from 'generaltranslation/types';\n\nexport type Options = {\n config: string;\n apiKey?: string;\n projectId?: string;\n versionId?: string;\n jsconfig?: string;\n dictionary?: string;\n src?: string[];\n defaultLocale?: string;\n locales?: string[];\n baseUrl: string;\n inline?: boolean;\n ignoreErrors: boolean;\n suppressWarnings: boolean;\n dryRun: boolean;\n timeout: number;\n force?: boolean;\n stageTranslations?: boolean;\n experimentalLocalizeStaticUrls?: boolean;\n experimentalHideDefaultLocale?: boolean;\n experimentalFlattenJsonFiles?: boolean;\n experimentalLocalizeStaticImports?: boolean;\n experimentalLocalizeRelativeAssets?: boolean;\n experimentalAddHeaderAnchorIds?: 'mintlify' | 'default';\n docsImportRewrites?: Array<{\n match: string;\n replace: string;\n }>;\n};\n\nexport type OpenApiConfig = {\n files: string[];\n translateFields?: string[];\n};\n\nexport type MintlifyOptions = {\n openapi?: OpenApiConfig;\n inferTitleFromFilename?: boolean;\n localizeRedirects?: boolean; // add localized redirects for pages renamed or removed in a translate run\n};\n\nexport type SharedFlags = {\n config?: string;\n apiKey?: string;\n projectId?: string;\n};\n\nexport type TranslateFlags = SharedFlags & {\n versionId?: string;\n jsconfig?: string;\n dictionary?: string;\n defaultLocale?: string;\n locales?: string[];\n ignoreErrors?: boolean;\n src?: string[];\n timeout: number;\n dryRun: boolean;\n saveLocal?: boolean;\n stageTranslations?: boolean;\n setupProject?: boolean; // if true, skip enqueue step\n publish?: boolean;\n force?: boolean;\n forceDownload?: boolean;\n tag?: string;\n message?: string;\n experimentalLocalizeStaticUrls?: boolean;\n experimentalHideDefaultLocale?: boolean;\n experimentalFlattenJsonFiles?: boolean;\n experimentalLocalizeStaticImports?: boolean;\n experimentalLocalizeRelativeAssets?: boolean;\n experimentalAddHeaderAnchorIds?: 'mintlify' | 'default';\n omitConfigIds?: boolean;\n excludeStaticUrls?: string[];\n excludeStaticImports?: string[];\n docsImportRewrites?: Array<{\n match: string;\n replace: string;\n }>;\n};\n\nexport type WrapOptions = {\n src?: string[];\n config: string;\n skipTs: boolean;\n disableIds: boolean;\n disableFormatting: boolean;\n addGTProvider: boolean;\n};\n\nexport type SetupOptions = {\n src?: string[];\n config: string;\n};\n\nexport type GenerateSourceOptions = {\n src?: string[];\n config: string;\n defaultLocale: string;\n dictionary?: string;\n jsconfig?: string;\n inline?: boolean;\n ignoreErrors: boolean;\n suppressWarnings: boolean;\n};\n\nexport type Framework =\n | typeof Libraries.GT_NEXT\n | typeof Libraries.GT_REACT\n | typeof Libraries.GT_REACT_NATIVE\n | typeof Libraries.GT_TANSTACK_START;\n\nexport const SUPPORTED_REACT_FRAMEWORKS = [\n 'next-app',\n 'next-pages',\n 'vite',\n 'gatsby',\n 'react',\n 'redwood',\n 'tanstack-start',\n 'react-router',\n] as const;\n\nexport type FrameworkObject =\n | {\n name: 'mintlify';\n type?: undefined;\n }\n | {\n name: (typeof SUPPORTED_REACT_FRAMEWORKS)[number];\n type: 'react';\n };\nexport type ReactFrameworkObject = Extract<FrameworkObject, { type: 'react' }>;\n/** Detected so setup can stop; the wizard cannot set React Native up yet. */\nexport type ReactNativeFrameworkObject = {\n name: 'react-native';\n type: 'react-native';\n};\n\nexport type FrameworkType = FrameworkObject['type'];\n\nexport type SupportedFrameworks = FrameworkObject['name'];\nexport type SupportedReactFrameworks = Extract<\n FrameworkObject,\n { type: 'react' }\n>['name'];\n\nexport type SupportedLibraries =\n | InlineLibrary\n | 'next-intl'\n | 'react-i18next'\n | 'next-i18next'\n | 'i18next'\n | 'i18next-icu'\n | 'base';\n\nexport interface ContentScanner {\n scanForContent(\n options: WrapOptions,\n framework: Framework\n ): Promise<{\n errors: string[];\n filesUpdated: string[];\n warnings: string[];\n }>;\n}\n\n// Create a type based on the supported file extensions\nexport type SupportedFileExtension = (typeof SUPPORTED_FILE_EXTENSIONS)[number];\n\n// Update ResolvedFiles to use the dynamic keys\nexport type ResolvedFiles = {\n [K in SupportedFileExtension]?: string[];\n} & {\n gt?: string; // Output glob: /path/[locale].json\n};\n\nexport type TransformOption = {\n match?: string; // regex to match strings, supports capture groups\n replace: string; // string or regex pattern to replace the match with\n // Special placeholders:\n // -> if used in the match string, they will be replaced with the corresponding default locale property value\n // -> if used in the replace string, they will be replaced with the corresponding target locale property value\n // {locale} -> will be replaced with the locale code\n // And any other property from getLocaleProperties()\n};\n\nexport type TransformFiles = {\n [K in SupportedFileExtension]?: TransformOption | string | TransformOption[]; // if a string, only transform the file name\n};\n\nexport type TransformFormats = {\n [K in SupportedFileExtension]?: FileFormat;\n};\n\n// Include patterns can be plain strings or objects with a publish flag\nexport type IncludePattern = string | { pattern: string; publish?: boolean };\n\n// Review requirement for matched files: a boolean applies to all files of the\n// type; the object form opts path groups in/out with globs. exclude wins over\n// include; files matching neither inherit the top-level requiresReview default.\nexport type RequiresReviewConfig =\n | boolean\n | {\n include?: string[];\n exclude?: string[];\n };\n\n// Update FilesOptions to fix the error\nexport type FilesOptions = {\n [K in SupportedFileExtension]?: {\n include: IncludePattern[];\n exclude?: string[];\n transform?: string | TransformOption | TransformOption[];\n transformationFormat?: FileFormat;\n parsingFlags?: ParsingFlagsFor<K>; // Flags for parsing inline content\n requiresReview?: RequiresReviewConfig; // Whether translated versions of matched files require approval before use\n };\n} & {\n gt?: {\n output: string; // Output glob: /path/[locale].json\n publish?: boolean; // if true, publish gtjson translations to the CDN\n parsingFlags?: Partial<GTParsingFlags>; // Flags for parsing inline content\n /**\n * @deprecated\n * use `files.gt.parsingFlags.includeSourceCodeContext` instead\n */\n includeSourceCodeContext?: boolean; // Include surrounding source code lines as context for translations (default: false)\n };\n};\n\n// Shared settings between all API-related commands\nexport type FontsConfig = {\n include: string[]; // globs of .ttf/.otf files\n exclude?: string[];\n};\n\nexport type Settings = {\n config: string;\n configDirectory: string;\n baseUrl: string;\n dashboardUrl: string;\n apiKey?: string;\n userTokenProvider?: UserTokenProvider;\n projectId?: string;\n defaultLocale: string;\n locales: string[];\n customMapping?: CustomMapping;\n files: {\n resolvedPaths: ResolvedFiles; // Absolute resolved paths for the default locale\n placeholderPaths: ResolvedFiles; // Absolute placeholder paths for all locales containing [locale]\n transformPaths: TransformFiles; // Absolute transform paths for all locales containing [locale]\n transformFormats: TransformFormats; // Output file format transforms keyed by config file type\n publishPaths: Set<string>; // Absolute paths explicitly opted IN to publishing\n unpublishPaths: Set<string>; // Absolute paths explicitly opted OUT of publishing\n requiresReviewPaths: Set<string>; // Absolute paths whose effective requiresReview policy is true\n parsingFlags: ParseFlagsByFileType;\n gtJson: {\n publish?: boolean; // if true, publish gtjson translations to the CDN\n parsingFlags: GTParsingFlags; // Flags for parsing inline content\n /**\n * @deprecated\n * use {@link files.gt.GTParsingFlags.parsingFlags.includeSourceCodeContext} instead\n */\n includeSourceCodeContext?: boolean; // Include surrounding source code lines as context for translations (default: false)\n };\n };\n stageTranslations: boolean; // if true, always stage the project during translate command\n requiresReview?: boolean; // top-level default: translated artifacts require approval before the client uses them\n publish?: boolean; // if true, publish the translations to the CDN; undefined means no global publish intent\n omitConfigIds?: boolean; // if true, do not write _versionId or _branchId to gt.config.json\n _versionId?: string; // internal use only\n _branchId?: string; // internal use only\n version?: string; // for specifying a custom version id to use. Should be unique\n description?: string;\n src?: string[]; // list of glob patterns for source file scanning\n fonts?: FontsConfig; // fonts to sync to the API before translating\n framework?: SupportedFrameworks;\n options?: AdditionalOptions;\n modelProvider?: ModelProvider;\n tag?: string;\n tagMessage?: string;\n parsingOptions: ParsingConfigOptions;\n branchOptions: BranchOptions;\n // Optional shared static assets config\n sharedStaticAssets?: SharedStaticAssetsConfig;\n};\n\nexport type StaticLocalizationFiles = Pick<\n Settings['files'],\n 'placeholderPaths' | 'resolvedPaths'\n> &\n Partial<Pick<Settings['files'], 'transformPaths' | 'transformFormats'>>;\n\nexport type StaticLocalizationSettings = Pick<\n Settings,\n 'defaultLocale' | 'locales' | 'options'\n> & {\n files?: StaticLocalizationFiles | null;\n};\n\nexport type BranchOptions = {\n currentBranch?: string;\n autoDetectBranches?: boolean;\n remoteName: string; // default 'origin'. The name of the remote to use for auto-detection.\n enabled: boolean; // if true, branching is enabled for the project\n};\n\nexport type AdditionalOptions = {\n // Optional schema to follow while translating JSON files\n jsonSchema?: {\n [fileGlob: string]: JsonSchema;\n };\n // Optional schema to follow while translating YAML files\n yamlSchema?: {\n [fileGlob: string]: YamlSchema;\n };\n // Skip pre-parse validation checks for specific file types\n skipFileValidation?: {\n json?: boolean;\n yaml?: boolean;\n mdx?: boolean;\n };\n // Optional Mintlify-specific options container\n mintlify?: MintlifyOptions;\n docsUrlPattern?: string | string[]; // eg /docs/[locale] or /[locale] for localizing static urls in markdown files; a list localizes several URL prefixes\n docsImportPattern?: string; // eg /docs/[locale]/foo.md or /[locale]/foo.md for localizing static imports in markdown files\n excludeStaticUrls?: string[]; // A list of file globs to include for static url localization\n excludeStaticImports?: string[]; // A list of file globs to include for static import localization\n docsHideDefaultLocaleImport?: boolean; // if true, hide the default locale in the import path\n copyFiles?: string[]; // array of files to copy to the target locale\n experimentalClearLocaleDirs?: boolean; // if true, clear locale directories before writing translations (default: false)\n clearLocaleDirsExclude?: string[]; // array of glob patterns with [locale] or [locales] placeholder to exclude from clearing (e.g., \"./snippets/[locale]/preserved/**\" or \"./[locales]/static/**\")\n experimentalLocalizeStaticImports?: boolean; // Inserts locale in static import paths in md/mdx files\n // Inserts locale in static url paths in md/mdx files and adds anchor IDs to\n // preserve navigation. The object form enables it with extra behavior.\n experimentalLocalizeStaticUrls?:\n | boolean\n | {\n // Keep links to source pages that have no translation\n skipUntranslatedPages?: boolean;\n // Extra JSX attribute names or globs to localize\n attributes?: string[];\n };\n experimentalLocalizeRelativeAssets?: boolean; // Rewrites relative asset URLs in translated md/mdx files to valid paths\n experimentalAddHeaderAnchorIds?: 'mintlify' | 'default'; // Format for anchor IDs: 'mintlify' for Mintlify's native {#id} on every heading, 'default' or undefined for escaped inline \\{#id\\}. Can run independently of static url localization\n experimentalHideDefaultLocale?: boolean; // Hides the default locale in the import path\n experimentalFlattenJsonFiles?: boolean; // Flattens JSON files into a single file\n baseDomain?: string; // The base http:// url where the project is hosted\n docsImportRewrites?: Array<{\n match: string; // prefix to match, e.g. '@site/docs'\n replace: string; // replacement prefix, can include [locale] or [defaultLocale]\n }>;\n experimentalCanonicalLocaleKeys?: boolean; // For composite JSON schemas with locale keys, force canonical locale even when alias provided\n saveLocal?: boolean; // if true, detect and save local edits to translated output before enqueuing translations (default: false)\n};\n\nexport type SharedStaticAssetsConfig = {\n include: string | string[];\n outDir?: string;\n publicPath?: string;\n mirrorToLocales?: boolean;\n};\n\nexport type StructuralTransform = {\n sourcePointer: string; // e.g., \"/msg\"\n destinationPointer: string; // e.g., \"/translations/en\"\n};\n\nexport type JsonSchema = {\n preset?: 'mintlify' | 'mintlify-hide-default' | 'openapi';\n structuralTransform?: StructuralTransform[];\n\n // when true, resolve $ref entries in this file before processing\n resolveRefs?: boolean;\n\n // exactly 1 of include or composite must be provided; not both\n\n // specify include if file is not composite\n // multiple target JSONs will be created for each locale,\n // with the only differing content being the specified JSONPath values\n include?: string[]; // array of JSONPaths to include\n\n // specify composite if no new JSONs should be created\n composite?: {\n // The sourceObjectPath is a JSONPath to the array or object containing\n // content in the source and target locales\n // This value is denoted as the \"sourceObject\"\n // Array elements or object sub-elements are denoted as \"sourceItem\"\n [sourceObjectPath: string]: SourceObjectOptions;\n };\n};\n\nexport type YamlSchema = {\n preset?: 'mintlify' | 'openapi';\n include?: string[];\n transform?: TransformOptions;\n};\n\nexport type SourceObjectOptions = {\n type: 'array' | 'object'; // type of the sourceObject;\n // array if the sourceObject is an array\n // -> We will simply add duplicated sourceItems for each locale\n // object if the sourceObject is an object\n // -> We will duplicate the sourceItem for each locale and set the corresponding\n // key with the locale property\n // In both cases, we search the sourceObject for the key that matches the source locale\n\n // Below, relative JSONPaths are relative to the sourceItem root, NOT the sourceObject\n\n include: string[]; // array of relative JSONPaths to include in the translated JSON\n\n // if type is array, there must be a key property in the array element\n // corresponding value should be a locale code\n key?: string; // relative jsonPath to the key to use to distinguish between source and target locales\n // if type is object, the key is simply the JSON key for the sourceItem - this is unnecessary in this case\n\n localeProperty?: string; // specific locale property to use for the key for target locales, default 'code'\n // ex: code, name, nativeName, languageCode, languageName, etc. (values returned by getLocaleProperties)\n\n // optional config for transforming specific fields in the sourceItem\n // for example, helpful for handling urls with locale-specific paths\n transform?: TransformOptions;\n\n // optional list of top-level properties to remove from generated\n // non-default-locale entries (e.g. Mintlify's `default: true` flag on the\n // default language entry, which must not be cloned into other locales)\n omitProperties?: string[];\n\n // optional sorting behavior for array sourceObjects. When set to 'locale',\n // the array will be ordered to match the locales array provided to mergeJson\n // When set to 'localesAlphabetical', the default locale will be placed first\n // and the remaining locales will be ordered alphabetically by locale code\n experimentalSort?: 'locales' | 'localesAlphabetical';\n\n // when true, non-default keyed entries in this composite array are extracted\n // into separate files (using the key value as the directory name) and replaced\n // with $ref pointers. Keeps the source file compact.\n splitEntries?: boolean;\n};\n\nexport type TransformOptions = {\n // relative jsonPath to content to mutate\n [transformPath: string]: TransformOption;\n};\n"],"mappings":";AA8HA,MAAa,6BAA6B;CACxC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD"}
@@ -26,6 +26,13 @@ export type ParsingConfigOptions = {
26
26
  * - flag for extraction of git history
27
27
  */
28
28
  export type BaseParsingFlags = Record<string, unknown>;
29
+ /**
30
+ * @property {boolean} includeSourceCodeContext - Collect source code context for Paraglide JS messages. Requires `@generaltranslation/paraglide-js`.
31
+ */
32
+ export type JsonParsingFlags = BaseParsingFlags & {
33
+ includeSourceCodeContext?: boolean;
34
+ };
35
+ export type ParsingFlagsFor<K extends SupportedFileExtension> = K extends 'json' ? JsonParsingFlags : BaseParsingFlags;
29
36
  /**
30
37
  * Flags for parsing content. Not to be confused with ParsingConfig which helps us enable/disable
31
38
  * parsing features depending on the function being parsed. Parsing flags is for users to override
@@ -67,5 +74,5 @@ export declare function resolveAutoderive(value: boolean | {
67
74
  * This is really a helper type that helps us map across filetypes
68
75
  */
69
76
  export type ParseFlagsByFileType = {
70
- [K in SupportedFileExtension]?: BaseParsingFlags;
77
+ [K in SupportedFileExtension]?: ParsingFlagsFor<K>;
71
78
  };
@@ -1 +1 @@
1
- {"version":3,"file":"parsing.js","names":[],"sources":["../../src/types/parsing.ts"],"sourcesContent":["import type { VueCompilerOptions } from '@generaltranslation/vue-extractor/types';\nimport type { SupportedFileExtension } from './index.js';\n\n/**\n * For monorepo projects, checking for extra exports fields in resolved internal packages.\n * For instance, an exported path may be labeled as 'browser' or 'module' or 'default'.\n * These can resolve to different files in the compiled package. This helps us know\n * which files to check when we do resolution.\n *\n * @property conditionNames - The condition names to check for in the resolved package.\n *\n * @example\n * {\n * conditionNames: ['development', 'browser', 'module', 'import', 'require', 'default']\n * }\n */\nexport type ParsingConfigOptions = {\n conditionNames: string[];\n};\n\n/**\n * Base parsing flags for all files.\n * Currently no supported properties\n *\n * Future ideas for flags:\n * - flag for extraction of file name\n * - flag for extraction of last modified timestamp\n * - flag for extraction of git history\n */\nexport type BaseParsingFlags = Record<string, unknown>;\n\n/**\n * Flags for parsing content. Not to be confused with ParsingConfig which helps us enable/disable\n * parsing features depending on the function being parsed. Parsing flags is for users to override\n * some of these defaults or enable/disable other features.\n *\n * @property {boolean | { jsx?: boolean; strings?: boolean }} autoderive - Whether to enable autoderive. A plain boolean enables/disables both JSX and strings. An object enables selectively.\n * @property {boolean} includeSourceCodeContext - Include surrounding source code lines as context for translations.\n * @property {boolean} enableAutoJsxInjection - Whether to enable auto-jsx injection for the internal <_T> and <_Var> components.\n * @property {boolean} legacyGtReactImportSource - Whether compiler-injected gt-react imports should use gt-react/browser.\n * @property {string} viteConfigPath - Vite config used to resolve hash-affecting Vue compiler behavior.\n * @property {VueCompilerOptions} vueCompilerOptions - Hash-affecting Vue template compiler options.\n */\nexport type GTParsingFlags = BaseParsingFlags & {\n autoderive: boolean | { jsx?: boolean; strings?: boolean };\n includeSourceCodeContext: boolean;\n enableAutoJsxInjection: boolean;\n legacyGtReactImportSource: boolean;\n viteConfigPath?: string;\n vueCompilerOptions?: VueCompilerOptions;\n};\n\n/**\n * Resolves the autoderive config value into separate jsx and strings flags.\n * - `true` enables both (backward compatible)\n * - `false` disables both (backward compatible)\n * - `{ jsx?: boolean; strings?: boolean }` enables selectively (missing keys default to false)\n */\nexport function resolveAutoderive(\n value: boolean | { jsx?: boolean; strings?: boolean } | undefined\n): { jsx: boolean; strings: boolean } {\n if (value === undefined || typeof value === 'boolean') {\n return { jsx: !!value, strings: !!value };\n }\n return { jsx: value.jsx ?? false, strings: value.strings ?? false };\n}\n\n/**\n * Flags for parsing content with each filetype having its own flags\n * This is really a helper type that helps us map across filetypes\n */\nexport type ParseFlagsByFileType = {\n [K in SupportedFileExtension]?: BaseParsingFlags;\n};\n"],"mappings":";;;;;;;AA0DA,SAAgB,kBACd,OACoC;AACpC,KAAI,UAAU,KAAA,KAAa,OAAO,UAAU,UAC1C,QAAO;EAAE,KAAK,CAAC,CAAC;EAAO,SAAS,CAAC,CAAC;EAAO;AAE3C,QAAO;EAAE,KAAK,MAAM,OAAO;EAAO,SAAS,MAAM,WAAW;EAAO"}
1
+ {"version":3,"file":"parsing.js","names":[],"sources":["../../src/types/parsing.ts"],"sourcesContent":["import type { VueCompilerOptions } from '@generaltranslation/vue-extractor/types';\nimport type { SupportedFileExtension } from './index.js';\n\n/**\n * For monorepo projects, checking for extra exports fields in resolved internal packages.\n * For instance, an exported path may be labeled as 'browser' or 'module' or 'default'.\n * These can resolve to different files in the compiled package. This helps us know\n * which files to check when we do resolution.\n *\n * @property conditionNames - The condition names to check for in the resolved package.\n *\n * @example\n * {\n * conditionNames: ['development', 'browser', 'module', 'import', 'require', 'default']\n * }\n */\nexport type ParsingConfigOptions = {\n conditionNames: string[];\n};\n\n/**\n * Base parsing flags for all files.\n * Currently no supported properties\n *\n * Future ideas for flags:\n * - flag for extraction of file name\n * - flag for extraction of last modified timestamp\n * - flag for extraction of git history\n */\nexport type BaseParsingFlags = Record<string, unknown>;\n\n/**\n * @property {boolean} includeSourceCodeContext - Collect source code context for Paraglide JS messages. Requires `@generaltranslation/paraglide-js`.\n */\nexport type JsonParsingFlags = BaseParsingFlags & {\n includeSourceCodeContext?: boolean;\n};\n\nexport type ParsingFlagsFor<K extends SupportedFileExtension> = K extends 'json'\n ? JsonParsingFlags\n : BaseParsingFlags;\n\n/**\n * Flags for parsing content. Not to be confused with ParsingConfig which helps us enable/disable\n * parsing features depending on the function being parsed. Parsing flags is for users to override\n * some of these defaults or enable/disable other features.\n *\n * @property {boolean | { jsx?: boolean; strings?: boolean }} autoderive - Whether to enable autoderive. A plain boolean enables/disables both JSX and strings. An object enables selectively.\n * @property {boolean} includeSourceCodeContext - Include surrounding source code lines as context for translations.\n * @property {boolean} enableAutoJsxInjection - Whether to enable auto-jsx injection for the internal <_T> and <_Var> components.\n * @property {boolean} legacyGtReactImportSource - Whether compiler-injected gt-react imports should use gt-react/browser.\n * @property {string} viteConfigPath - Vite config used to resolve hash-affecting Vue compiler behavior.\n * @property {VueCompilerOptions} vueCompilerOptions - Hash-affecting Vue template compiler options.\n */\nexport type GTParsingFlags = BaseParsingFlags & {\n autoderive: boolean | { jsx?: boolean; strings?: boolean };\n includeSourceCodeContext: boolean;\n enableAutoJsxInjection: boolean;\n legacyGtReactImportSource: boolean;\n viteConfigPath?: string;\n vueCompilerOptions?: VueCompilerOptions;\n};\n\n/**\n * Resolves the autoderive config value into separate jsx and strings flags.\n * - `true` enables both (backward compatible)\n * - `false` disables both (backward compatible)\n * - `{ jsx?: boolean; strings?: boolean }` enables selectively (missing keys default to false)\n */\nexport function resolveAutoderive(\n value: boolean | { jsx?: boolean; strings?: boolean } | undefined\n): { jsx: boolean; strings: boolean } {\n if (value === undefined || typeof value === 'boolean') {\n return { jsx: !!value, strings: !!value };\n }\n return { jsx: value.jsx ?? false, strings: value.strings ?? false };\n}\n\n/**\n * Flags for parsing content with each filetype having its own flags\n * This is really a helper type that helps us map across filetypes\n */\nexport type ParseFlagsByFileType = {\n [K in SupportedFileExtension]?: ParsingFlagsFor<K>;\n};\n"],"mappings":";;;;;;;AAqEA,SAAgB,kBACd,OACoC;AACpC,KAAI,UAAU,KAAA,KAAa,OAAO,UAAU,UAC1C,QAAO;EAAE,KAAK,CAAC,CAAC;EAAO,SAAS,CAAC,CAAC;EAAO;AAE3C,QAAO;EAAE,KAAK,MAAM,OAAO;EAAO,SAAS,MAAM,WAAW;EAAO"}
@@ -6,9 +6,14 @@ export type RefMapEntry = {
6
6
  siblings?: Record<string, unknown>;
7
7
  };
8
8
  export type RefMap = Map<string, RefMapEntry>;
9
+ export type UnreadableRef = {
10
+ refPath: string;
11
+ pointer: string;
12
+ };
9
13
  export type ResolvedRefs = {
10
14
  resolved: unknown;
11
15
  refMap: RefMap;
16
+ unreadableRefs: UnreadableRef[];
12
17
  };
13
18
  /**
14
19
  * Resolve all Mintlify $ref references in a parsed JSON object.
@@ -13,21 +13,23 @@ import micromatch from "micromatch";
13
13
  */
14
14
  function resolveMintlifyRefs(json, filePath) {
15
15
  const refMap = /* @__PURE__ */ new Map();
16
+ const unreadableRefs = [];
16
17
  return {
17
- resolved: resolveNode(json, path.dirname(path.resolve(filePath)), "", /* @__PURE__ */ new Set(), refMap),
18
- refMap
18
+ resolved: resolveNode(json, path.dirname(path.resolve(filePath)), "", /* @__PURE__ */ new Set(), refMap, unreadableRefs),
19
+ refMap,
20
+ unreadableRefs
19
21
  };
20
22
  }
21
- function resolveNode(node, baseDir, pointer, visiting, refMap) {
23
+ function resolveNode(node, baseDir, pointer, visiting, refMap, unreadableRefs) {
22
24
  if (node === null || typeof node !== "object") return node;
23
- if (Array.isArray(node)) return node.map((item, i) => resolveNode(item, baseDir, `${pointer}/${i}`, visiting, refMap));
25
+ if (Array.isArray(node)) return node.map((item, i) => resolveNode(item, baseDir, `${pointer}/${i}`, visiting, refMap, unreadableRefs));
24
26
  const obj = node;
25
- if (typeof obj["$ref"] === "string") return resolveRef(obj, baseDir, pointer, visiting, refMap);
27
+ if (typeof obj["$ref"] === "string") return resolveRef(obj, baseDir, pointer, visiting, refMap, unreadableRefs);
26
28
  const result = {};
27
- for (const [key, value] of Object.entries(obj)) result[key] = resolveNode(value, baseDir, `${pointer}/${key}`, visiting, refMap);
29
+ for (const [key, value] of Object.entries(obj)) result[key] = resolveNode(value, baseDir, `${pointer}/${key}`, visiting, refMap, unreadableRefs);
28
30
  return result;
29
31
  }
30
- function resolveRef(obj, baseDir, pointer, visiting, refMap) {
32
+ function resolveRef(obj, baseDir, pointer, visiting, refMap, unreadableRefs) {
31
33
  const refPath = obj["$ref"];
32
34
  if (!isRelativePath(refPath)) {
33
35
  logger.warn(chalk.yellow(`Skipping non-relative $ref at ${pointer || "/"}: ${refPath}`));
@@ -37,11 +39,19 @@ function resolveRef(obj, baseDir, pointer, visiting, refMap) {
37
39
  const resolvedFilePath = path.resolve(baseDir, refPath);
38
40
  if (visiting.has(resolvedFilePath)) {
39
41
  logger.warn(chalk.yellow(`Circular $ref detected at ${pointer || "/"}: ${refPath}`));
42
+ unreadableRefs.push({
43
+ refPath,
44
+ pointer
45
+ });
40
46
  const { $ref: _, ...rest } = obj;
41
47
  return rest;
42
48
  }
43
49
  if (!fs.existsSync(resolvedFilePath)) {
44
50
  logger.warn(chalk.yellow(`$ref file not found at ${pointer || "/"}: ${refPath} (resolved to ${resolvedFilePath})`));
51
+ unreadableRefs.push({
52
+ refPath,
53
+ pointer
54
+ });
45
55
  const { $ref: _, ...rest } = obj;
46
56
  return rest;
47
57
  }
@@ -50,6 +60,10 @@ function resolveRef(obj, baseDir, pointer, visiting, refMap) {
50
60
  fileContent = fs.readFileSync(resolvedFilePath, "utf-8");
51
61
  } catch {
52
62
  logger.warn(chalk.yellow(`Failed to read $ref file: ${resolvedFilePath}`));
63
+ unreadableRefs.push({
64
+ refPath,
65
+ pointer
66
+ });
53
67
  const { $ref: _, ...rest } = obj;
54
68
  return rest;
55
69
  }
@@ -58,6 +72,10 @@ function resolveRef(obj, baseDir, pointer, visiting, refMap) {
58
72
  parsed = JSON.parse(fileContent);
59
73
  } catch {
60
74
  logger.warn(chalk.yellow(`$ref file is not valid JSON: ${resolvedFilePath}`));
75
+ unreadableRefs.push({
76
+ refPath,
77
+ pointer
78
+ });
61
79
  const { $ref: _, ...rest } = obj;
62
80
  return rest;
63
81
  }
@@ -72,7 +90,7 @@ function resolveRef(obj, baseDir, pointer, visiting, refMap) {
72
90
  const refFileDir = path.dirname(resolvedFilePath);
73
91
  const nextVisiting = new Set(visiting);
74
92
  nextVisiting.add(resolvedFilePath);
75
- const resolvedContent = resolveNode(parsed, refFileDir, pointer, nextVisiting, refMap);
93
+ const resolvedContent = resolveNode(parsed, refFileDir, pointer, nextVisiting, refMap, unreadableRefs);
76
94
  if (resolvedContent !== null && typeof resolvedContent === "object" && !Array.isArray(resolvedContent)) return {
77
95
  ...resolvedContent,
78
96
  ...siblings
@@ -1 +1 @@
1
- {"version":3,"file":"resolveMintlifyRefs.js","names":["jsonSchema"],"sources":["../../src/utils/resolveMintlifyRefs.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\nimport { logger } from '../console/logger.js';\nimport chalk from 'chalk';\nimport micromatch from 'micromatch';\n\nexport type RefMapEntry = {\n sourceFile: string;\n refPath: string;\n containingDir: string;\n originalContent: unknown;\n siblings?: Record<string, unknown>;\n};\n\nexport type RefMap = Map<string, RefMapEntry>;\n\nexport type ResolvedRefs = {\n resolved: unknown;\n refMap: RefMap;\n};\n\n/**\n * Resolve all Mintlify $ref references in a parsed JSON object.\n *\n * Returns the fully-expanded JSON and a refMap that tracks which subtrees\n * came from which files (used later to split translated output back into\n * the same file topology).\n */\nexport function resolveMintlifyRefs(\n json: unknown,\n filePath: string\n): ResolvedRefs {\n const refMap: RefMap = new Map();\n const resolved = resolveNode(\n json,\n path.dirname(path.resolve(filePath)),\n '',\n new Set<string>(),\n refMap\n );\n return { resolved, refMap };\n}\n\nfunction resolveNode(\n node: unknown,\n baseDir: string,\n pointer: string,\n visiting: Set<string>,\n refMap: RefMap\n): unknown {\n if (node === null || typeof node !== 'object') return node;\n\n if (Array.isArray(node)) {\n return node.map((item, i) =>\n resolveNode(item, baseDir, `${pointer}/${i}`, visiting, refMap)\n );\n }\n\n const obj = node as Record<string, unknown>;\n\n if (typeof obj['$ref'] === 'string') {\n return resolveRef(obj, baseDir, pointer, visiting, refMap);\n }\n\n const result: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(obj)) {\n result[key] = resolveNode(\n value,\n baseDir,\n `${pointer}/${key}`,\n visiting,\n refMap\n );\n }\n return result;\n}\n\nfunction resolveRef(\n obj: Record<string, unknown>,\n baseDir: string,\n pointer: string,\n visiting: Set<string>,\n refMap: RefMap\n): unknown {\n const refPath = obj['$ref'] as string;\n\n if (!isRelativePath(refPath)) {\n logger.warn(\n chalk.yellow(\n `Skipping non-relative $ref at ${pointer || '/'}: ${refPath}`\n )\n );\n const { $ref: _, ...rest } = obj;\n return rest;\n }\n\n const resolvedFilePath = path.resolve(baseDir, refPath);\n\n if (visiting.has(resolvedFilePath)) {\n logger.warn(\n chalk.yellow(`Circular $ref detected at ${pointer || '/'}: ${refPath}`)\n );\n const { $ref: _, ...rest } = obj;\n return rest;\n }\n\n if (!fs.existsSync(resolvedFilePath)) {\n logger.warn(\n chalk.yellow(\n `$ref file not found at ${pointer || '/'}: ${refPath} (resolved to ${resolvedFilePath})`\n )\n );\n const { $ref: _, ...rest } = obj;\n return rest;\n }\n\n let fileContent: string;\n try {\n fileContent = fs.readFileSync(resolvedFilePath, 'utf-8');\n } catch {\n logger.warn(chalk.yellow(`Failed to read $ref file: ${resolvedFilePath}`));\n const { $ref: _, ...rest } = obj;\n return rest;\n }\n\n let parsed: unknown;\n try {\n parsed = JSON.parse(fileContent);\n } catch {\n logger.warn(\n chalk.yellow(`$ref file is not valid JSON: ${resolvedFilePath}`)\n );\n const { $ref: _, ...rest } = obj;\n return rest;\n }\n\n const { $ref: _, ...siblings } = obj;\n\n // Record provenance before recursive resolution\n refMap.set(pointer, {\n sourceFile: resolvedFilePath,\n refPath,\n containingDir: baseDir,\n originalContent: parsed,\n siblings,\n });\n\n // Recursively resolve nested $ref in the referenced file\n const refFileDir = path.dirname(resolvedFilePath);\n const nextVisiting = new Set(visiting);\n nextVisiting.add(resolvedFilePath);\n\n const resolvedContent = resolveNode(\n parsed,\n refFileDir,\n pointer,\n nextVisiting,\n refMap\n );\n\n // Apply Mintlify merge rules\n if (\n resolvedContent !== null &&\n typeof resolvedContent === 'object' &&\n !Array.isArray(resolvedContent)\n ) {\n // Object: merge siblings on top (siblings take precedence)\n return { ...(resolvedContent as Record<string, unknown>), ...siblings };\n }\n\n // Non-object (array, string, number, etc.): replace entirely, drop siblings\n return resolvedContent;\n}\n\n/**\n * Check if a file should have $ref resolution applied based on the settings.\n * Returns true if the file matches a jsonSchema entry with resolveRefs: true.\n */\nexport function shouldResolveRefs(\n filePath: string,\n options?: { jsonSchema?: Record<string, unknown> }\n): boolean {\n if (!options?.jsonSchema) return false;\n\n const relative = path.relative(process.cwd(), filePath);\n for (const [glob, schema] of Object.entries(options.jsonSchema)) {\n const jsonSchema = schema as { resolveRefs?: boolean };\n if (jsonSchema.resolveRefs && micromatch.isMatch(relative, glob)) {\n return true;\n }\n }\n return false;\n}\n\nfunction isRelativePath(refPath: string): boolean {\n if (path.isAbsolute(refPath)) return false;\n if (/^[a-z]+:\\/\\//i.test(refPath)) return false;\n return true;\n}\n"],"mappings":"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"}
1
+ {"version":3,"file":"resolveMintlifyRefs.js","names":["jsonSchema"],"sources":["../../src/utils/resolveMintlifyRefs.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\nimport { logger } from '../console/logger.js';\nimport chalk from 'chalk';\nimport micromatch from 'micromatch';\n\nexport type RefMapEntry = {\n sourceFile: string;\n refPath: string;\n containingDir: string;\n originalContent: unknown;\n siblings?: Record<string, unknown>;\n};\n\nexport type RefMap = Map<string, RefMapEntry>;\n\nexport type UnreadableRef = { refPath: string; pointer: string };\n\nexport type ResolvedRefs = {\n resolved: unknown;\n refMap: RefMap;\n unreadableRefs: UnreadableRef[];\n};\n\n/**\n * Resolve all Mintlify $ref references in a parsed JSON object.\n *\n * Returns the fully-expanded JSON and a refMap that tracks which subtrees\n * came from which files (used later to split translated output back into\n * the same file topology).\n */\nexport function resolveMintlifyRefs(\n json: unknown,\n filePath: string\n): ResolvedRefs {\n const refMap: RefMap = new Map();\n const unreadableRefs: UnreadableRef[] = [];\n const resolved = resolveNode(\n json,\n path.dirname(path.resolve(filePath)),\n '',\n new Set<string>(),\n refMap,\n unreadableRefs\n );\n return { resolved, refMap, unreadableRefs };\n}\n\nfunction resolveNode(\n node: unknown,\n baseDir: string,\n pointer: string,\n visiting: Set<string>,\n refMap: RefMap,\n unreadableRefs: UnreadableRef[]\n): unknown {\n if (node === null || typeof node !== 'object') return node;\n\n if (Array.isArray(node)) {\n return node.map((item, i) =>\n resolveNode(\n item,\n baseDir,\n `${pointer}/${i}`,\n visiting,\n refMap,\n unreadableRefs\n )\n );\n }\n\n const obj = node as Record<string, unknown>;\n\n if (typeof obj['$ref'] === 'string') {\n return resolveRef(obj, baseDir, pointer, visiting, refMap, unreadableRefs);\n }\n\n const result: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(obj)) {\n result[key] = resolveNode(\n value,\n baseDir,\n `${pointer}/${key}`,\n visiting,\n refMap,\n unreadableRefs\n );\n }\n return result;\n}\n\nfunction resolveRef(\n obj: Record<string, unknown>,\n baseDir: string,\n pointer: string,\n visiting: Set<string>,\n refMap: RefMap,\n unreadableRefs: UnreadableRef[]\n): unknown {\n const refPath = obj['$ref'] as string;\n\n if (!isRelativePath(refPath)) {\n logger.warn(\n chalk.yellow(\n `Skipping non-relative $ref at ${pointer || '/'}: ${refPath}`\n )\n );\n const { $ref: _, ...rest } = obj;\n return rest;\n }\n\n const resolvedFilePath = path.resolve(baseDir, refPath);\n\n if (visiting.has(resolvedFilePath)) {\n logger.warn(\n chalk.yellow(`Circular $ref detected at ${pointer || '/'}: ${refPath}`)\n );\n unreadableRefs.push({ refPath, pointer });\n const { $ref: _, ...rest } = obj;\n return rest;\n }\n\n if (!fs.existsSync(resolvedFilePath)) {\n logger.warn(\n chalk.yellow(\n `$ref file not found at ${pointer || '/'}: ${refPath} (resolved to ${resolvedFilePath})`\n )\n );\n unreadableRefs.push({ refPath, pointer });\n const { $ref: _, ...rest } = obj;\n return rest;\n }\n\n let fileContent: string;\n try {\n fileContent = fs.readFileSync(resolvedFilePath, 'utf-8');\n } catch {\n logger.warn(chalk.yellow(`Failed to read $ref file: ${resolvedFilePath}`));\n unreadableRefs.push({ refPath, pointer });\n const { $ref: _, ...rest } = obj;\n return rest;\n }\n\n let parsed: unknown;\n try {\n parsed = JSON.parse(fileContent);\n } catch {\n logger.warn(\n chalk.yellow(`$ref file is not valid JSON: ${resolvedFilePath}`)\n );\n unreadableRefs.push({ refPath, pointer });\n const { $ref: _, ...rest } = obj;\n return rest;\n }\n\n const { $ref: _, ...siblings } = obj;\n\n // Record provenance before recursive resolution\n refMap.set(pointer, {\n sourceFile: resolvedFilePath,\n refPath,\n containingDir: baseDir,\n originalContent: parsed,\n siblings,\n });\n\n // Recursively resolve nested $ref in the referenced file\n const refFileDir = path.dirname(resolvedFilePath);\n const nextVisiting = new Set(visiting);\n nextVisiting.add(resolvedFilePath);\n\n const resolvedContent = resolveNode(\n parsed,\n refFileDir,\n pointer,\n nextVisiting,\n refMap,\n unreadableRefs\n );\n\n // Apply Mintlify merge rules\n if (\n resolvedContent !== null &&\n typeof resolvedContent === 'object' &&\n !Array.isArray(resolvedContent)\n ) {\n // Object: merge siblings on top (siblings take precedence)\n return { ...(resolvedContent as Record<string, unknown>), ...siblings };\n }\n\n // Non-object (array, string, number, etc.): replace entirely, drop siblings\n return resolvedContent;\n}\n\n/**\n * Check if a file should have $ref resolution applied based on the settings.\n * Returns true if the file matches a jsonSchema entry with resolveRefs: true.\n */\nexport function shouldResolveRefs(\n filePath: string,\n options?: { jsonSchema?: Record<string, unknown> }\n): boolean {\n if (!options?.jsonSchema) return false;\n\n const relative = path.relative(process.cwd(), filePath);\n for (const [glob, schema] of Object.entries(options.jsonSchema)) {\n const jsonSchema = schema as { resolveRefs?: boolean };\n if (jsonSchema.resolveRefs && micromatch.isMatch(relative, glob)) {\n return true;\n }\n }\n return false;\n}\n\nfunction isRelativePath(refPath: string): boolean {\n if (path.isAbsolute(refPath)) return false;\n if (/^[a-z]+:\\/\\//i.test(refPath)) return false;\n return true;\n}\n"],"mappings":"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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gt",
3
- "version": "2.27.3",
3
+ "version": "2.28.1",
4
4
  "main": "dist/index.js",
5
5
  "bin": "bin/main.js",
6
6
  "files": [