@twin.org/tools-core 0.0.3-next.8 → 0.0.3

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 (138) hide show
  1. package/README.md +2 -2
  2. package/dist/es/index.js +21 -11
  3. package/dist/es/index.js.map +1 -1
  4. package/dist/es/models/ITypeScriptToSchemaContext.js +2 -0
  5. package/dist/es/models/ITypeScriptToSchemaContext.js.map +1 -0
  6. package/dist/es/models/ITypeScriptToSchemaDiagnostics.js +4 -0
  7. package/dist/es/models/ITypeScriptToSchemaDiagnostics.js.map +1 -0
  8. package/dist/es/models/ITypeScriptToSchemaOptions.js +4 -0
  9. package/dist/es/models/ITypeScriptToSchemaOptions.js.map +1 -0
  10. package/dist/es/models/embeddedSchemaMode.js +17 -0
  11. package/dist/es/models/embeddedSchemaMode.js.map +1 -0
  12. package/dist/es/utils/constants.js +43 -0
  13. package/dist/es/utils/constants.js.map +1 -0
  14. package/dist/es/utils/diagnosticReporter.js +32 -0
  15. package/dist/es/utils/diagnosticReporter.js.map +1 -0
  16. package/dist/es/utils/disallowedTypeGuard.js +151 -0
  17. package/dist/es/utils/disallowedTypeGuard.js.map +1 -0
  18. package/dist/es/utils/enum.js +152 -0
  19. package/dist/es/utils/enum.js.map +1 -0
  20. package/dist/es/utils/fileUtils.js +132 -0
  21. package/dist/es/utils/fileUtils.js.map +1 -0
  22. package/dist/es/utils/importTypeQuerySchemaResolver.js +363 -0
  23. package/dist/es/utils/importTypeQuerySchemaResolver.js.map +1 -0
  24. package/dist/es/utils/indexSignaturePatternResolver.js +94 -0
  25. package/dist/es/utils/indexSignaturePatternResolver.js.map +1 -0
  26. package/dist/es/utils/intersectionSchemaMerger.js +85 -0
  27. package/dist/es/utils/intersectionSchemaMerger.js.map +1 -0
  28. package/dist/es/utils/jsDoc.js +138 -0
  29. package/dist/es/utils/jsDoc.js.map +1 -0
  30. package/dist/es/utils/jsonSchemaBuilder.js +3415 -0
  31. package/dist/es/utils/jsonSchemaBuilder.js.map +1 -0
  32. package/dist/es/utils/mappedTypeSchemaResolver.js +265 -0
  33. package/dist/es/utils/mappedTypeSchemaResolver.js.map +1 -0
  34. package/dist/es/utils/objectTransformer.js +161 -0
  35. package/dist/es/utils/objectTransformer.js.map +1 -0
  36. package/dist/es/utils/regEx.js +128 -0
  37. package/dist/es/utils/regEx.js.map +1 -0
  38. package/dist/es/utils/resolver.js +177 -0
  39. package/dist/es/utils/resolver.js.map +1 -0
  40. package/dist/es/utils/templateLiteralPatternBuilder.js +94 -0
  41. package/dist/es/utils/templateLiteralPatternBuilder.js.map +1 -0
  42. package/dist/es/utils/typeScriptToSchema.js +319 -0
  43. package/dist/es/utils/typeScriptToSchema.js.map +1 -0
  44. package/dist/es/utils/utilityTypeSchemaMapper.js +475 -0
  45. package/dist/es/utils/utilityTypeSchemaMapper.js.map +1 -0
  46. package/dist/types/index.d.ts +21 -11
  47. package/dist/types/models/ITypeScriptToSchemaContext.d.ts +71 -0
  48. package/dist/types/models/ITypeScriptToSchemaDiagnostics.d.ts +31 -0
  49. package/dist/types/models/ITypeScriptToSchemaOptions.d.ts +22 -0
  50. package/dist/types/models/embeddedSchemaMode.d.ts +17 -0
  51. package/dist/types/utils/constants.d.ts +13 -0
  52. package/dist/types/utils/diagnosticReporter.d.ts +17 -0
  53. package/dist/types/utils/disallowedTypeGuard.d.ts +16 -0
  54. package/dist/types/utils/enum.d.ts +42 -0
  55. package/dist/types/utils/fileUtils.d.ts +66 -0
  56. package/dist/types/utils/importTypeQuerySchemaResolver.d.ts +87 -0
  57. package/dist/types/utils/indexSignaturePatternResolver.d.ts +21 -0
  58. package/dist/types/utils/intersectionSchemaMerger.d.ts +16 -0
  59. package/dist/types/utils/jsDoc.d.ts +53 -0
  60. package/dist/types/utils/jsonSchemaBuilder.d.ts +671 -0
  61. package/dist/types/utils/mappedTypeSchemaResolver.d.ts +81 -0
  62. package/dist/types/utils/objectTransformer.d.ts +33 -0
  63. package/dist/types/utils/regEx.d.ts +24 -0
  64. package/dist/types/utils/resolver.d.ts +22 -0
  65. package/dist/types/utils/templateLiteralPatternBuilder.d.ts +12 -0
  66. package/dist/types/utils/typeScriptToSchema.d.ts +92 -0
  67. package/dist/types/utils/utilityTypeSchemaMapper.d.ts +141 -0
  68. package/docs/changelog.md +343 -39
  69. package/docs/examples.md +87 -1
  70. package/docs/reference/classes/Constants.md +29 -0
  71. package/docs/reference/classes/DiagnosticReporter.md +49 -0
  72. package/docs/reference/classes/DisallowedTypeGuard.md +35 -0
  73. package/docs/reference/classes/Enum.md +93 -0
  74. package/docs/reference/classes/FileUtils.md +237 -0
  75. package/docs/reference/classes/ImportTypeQuerySchemaResolver.md +109 -0
  76. package/docs/reference/classes/IndexSignaturePatternResolver.md +69 -0
  77. package/docs/reference/classes/IntersectionSchemaMerger.md +48 -0
  78. package/docs/reference/classes/JsDoc.md +169 -0
  79. package/docs/reference/classes/JsonSchemaBuilder.md +2578 -0
  80. package/docs/reference/classes/MappedTypeSchemaResolver.md +275 -0
  81. package/docs/reference/classes/ObjectTransformer.md +119 -0
  82. package/docs/reference/classes/RegEx.md +99 -0
  83. package/docs/reference/classes/Resolver.md +52 -0
  84. package/docs/reference/classes/TemplateLiteralPatternBuilder.md +35 -0
  85. package/docs/reference/classes/TypeScriptToSchema.md +91 -0
  86. package/docs/reference/classes/UtilityTypeSchemaMapper.md +343 -0
  87. package/docs/reference/index.md +25 -11
  88. package/docs/reference/interfaces/ITypeScriptToSchemaContext.md +125 -0
  89. package/docs/reference/interfaces/ITypeScriptToSchemaDiagnostics.md +55 -0
  90. package/docs/reference/interfaces/ITypeScriptToSchemaOptions.md +44 -0
  91. package/docs/reference/type-aliases/EmbeddedSchemaMode.md +5 -0
  92. package/docs/reference/variables/EmbeddedSchemaMode.md +19 -0
  93. package/locales/en.json +32 -1
  94. package/package.json +8 -7
  95. package/dist/es/models/IJsonSchema.js +0 -2
  96. package/dist/es/models/IJsonSchema.js.map +0 -1
  97. package/dist/es/models/IOpenApi.js +0 -2
  98. package/dist/es/models/IOpenApi.js.map +0 -1
  99. package/dist/es/models/IOpenApiExample.js +0 -4
  100. package/dist/es/models/IOpenApiExample.js.map +0 -1
  101. package/dist/es/models/IOpenApiHeader.js +0 -4
  102. package/dist/es/models/IOpenApiHeader.js.map +0 -1
  103. package/dist/es/models/IOpenApiPathMethod.js +0 -2
  104. package/dist/es/models/IOpenApiPathMethod.js.map +0 -1
  105. package/dist/es/models/IOpenApiResponse.js +0 -2
  106. package/dist/es/models/IOpenApiResponse.js.map +0 -1
  107. package/dist/es/models/IOpenApiSecurityScheme.js +0 -4
  108. package/dist/es/models/IOpenApiSecurityScheme.js.map +0 -1
  109. package/dist/es/models/IPackageJson.js +0 -4
  110. package/dist/es/models/IPackageJson.js.map +0 -1
  111. package/dist/es/models/jsonTypeName.js +0 -2
  112. package/dist/es/models/jsonTypeName.js.map +0 -1
  113. package/dist/es/utils/jsonSchemaHelper.js +0 -258
  114. package/dist/es/utils/jsonSchemaHelper.js.map +0 -1
  115. package/dist/es/utils/openApiHelper.js +0 -12
  116. package/dist/es/utils/openApiHelper.js.map +0 -1
  117. package/dist/types/models/IJsonSchema.d.ts +0 -5
  118. package/dist/types/models/IOpenApi.d.ts +0 -54
  119. package/dist/types/models/IOpenApiExample.d.ts +0 -13
  120. package/dist/types/models/IOpenApiHeader.d.ts +0 -19
  121. package/dist/types/models/IOpenApiPathMethod.d.ts +0 -65
  122. package/dist/types/models/IOpenApiResponse.d.ts +0 -32
  123. package/dist/types/models/IOpenApiSecurityScheme.d.ts +0 -25
  124. package/dist/types/models/IPackageJson.d.ts +0 -15
  125. package/dist/types/models/jsonTypeName.d.ts +0 -5
  126. package/dist/types/utils/jsonSchemaHelper.d.ts +0 -78
  127. package/dist/types/utils/openApiHelper.d.ts +0 -9
  128. package/docs/reference/classes/JsonSchemaHelper.md +0 -233
  129. package/docs/reference/classes/OpenApiHelper.md +0 -21
  130. package/docs/reference/interfaces/IOpenApi.md +0 -103
  131. package/docs/reference/interfaces/IOpenApiExample.md +0 -19
  132. package/docs/reference/interfaces/IOpenApiHeader.md +0 -31
  133. package/docs/reference/interfaces/IOpenApiPathMethod.md +0 -119
  134. package/docs/reference/interfaces/IOpenApiResponse.md +0 -35
  135. package/docs/reference/interfaces/IOpenApiSecurityScheme.md +0 -43
  136. package/docs/reference/interfaces/IPackageJson.md +0 -23
  137. package/docs/reference/type-aliases/IJsonSchema.md +0 -5
  138. package/docs/reference/type-aliases/JsonTypeName.md +0 -5
@@ -0,0 +1,132 @@
1
+ // Copyright 2026 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ import { existsSync, readFileSync } from "node:fs";
4
+ import path from "node:path";
5
+ import { globSync } from "glob";
6
+ /**
7
+ * Utility helpers for TypeScript file and directory paths.
8
+ */
9
+ export class FileUtils {
10
+ /**
11
+ * Does the file exist.
12
+ * @param filePath The file path.
13
+ * @returns True if the file exists.
14
+ */
15
+ static fileExists(filePath) {
16
+ return existsSync(filePath);
17
+ }
18
+ /**
19
+ * Read the file.
20
+ * @param filePath The file path.
21
+ * @returns The file contents.
22
+ */
23
+ static readFile(filePath) {
24
+ return readFileSync(filePath, "utf-8");
25
+ }
26
+ /**
27
+ * Resolve a path.
28
+ * @param filePath The file path.
29
+ * @returns The resolved path.
30
+ */
31
+ static resolvePath(filePath) {
32
+ return path.resolve(filePath);
33
+ }
34
+ /**
35
+ * Get the current working directory.
36
+ * @returns The current working directory.
37
+ */
38
+ static getCurrentWorkingDirectory() {
39
+ return process.cwd();
40
+ }
41
+ /**
42
+ * Normalize path separators for consistent comparisons.
43
+ * @param filePath The file path.
44
+ * @returns The normalized file path.
45
+ */
46
+ static normalizeFilePath(filePath) {
47
+ return filePath.replaceAll("\\", "/");
48
+ }
49
+ /**
50
+ * Get the directory portion of a file path.
51
+ * @param filePath The file path.
52
+ * @returns The directory path.
53
+ */
54
+ static getDirectoryPath(filePath) {
55
+ const normalizedPath = FileUtils.normalizeFilePath(filePath);
56
+ const lastSeparatorIndex = normalizedPath.lastIndexOf("/");
57
+ return lastSeparatorIndex > -1 ? normalizedPath.slice(0, lastSeparatorIndex) : normalizedPath;
58
+ }
59
+ /**
60
+ * Resolve a relative path against a base directory.
61
+ * @param baseDirectory The base directory.
62
+ * @param relativePath The relative path.
63
+ * @returns The resolved path.
64
+ */
65
+ static resolveRelativePath(baseDirectory, relativePath) {
66
+ const normalizedRelative = FileUtils.normalizeFilePath(relativePath);
67
+ // Return absolute paths unchanged (Windows drive letter or POSIX root)
68
+ if (path.isAbsolute(normalizedRelative)) {
69
+ return normalizedRelative;
70
+ }
71
+ const normalizedBase = FileUtils.normalizeFilePath(baseDirectory);
72
+ if (path.isAbsolute(normalizedBase)) {
73
+ return FileUtils.normalizeFilePath(path.resolve(baseDirectory, relativePath));
74
+ }
75
+ // Base was relative — resolve to absolute then express relative to CWD to preserve relative form
76
+ return FileUtils.normalizeFilePath(path.relative(process.cwd(), path.resolve(baseDirectory, relativePath)));
77
+ }
78
+ /**
79
+ * Resolve a local import specifier to a TypeScript source file path.
80
+ * @param sourceFilePath The importing source file path.
81
+ * @param importPath The import specifier.
82
+ * @returns The resolved source file path.
83
+ */
84
+ static resolveImportSourceFilePath(sourceFilePath, importPath) {
85
+ const sourceDirectory = FileUtils.getDirectoryPath(sourceFilePath);
86
+ const resolvedBase = FileUtils.resolveRelativePath(sourceDirectory, importPath);
87
+ const baseWithoutExtension = resolvedBase.replace(/\.(c|m)?js$/u, "");
88
+ const candidates = [
89
+ resolvedBase,
90
+ `${resolvedBase}.ts`,
91
+ `${resolvedBase}.d.ts`,
92
+ `${resolvedBase}/index.ts`,
93
+ `${resolvedBase}/index.d.ts`,
94
+ `${baseWithoutExtension}.ts`,
95
+ `${baseWithoutExtension}/index.ts`,
96
+ `${baseWithoutExtension}.d.ts`,
97
+ `${baseWithoutExtension}/index.d.ts`
98
+ ];
99
+ for (const candidate of candidates) {
100
+ if (FileUtils.fileExists(candidate)) {
101
+ return candidate;
102
+ }
103
+ }
104
+ return undefined;
105
+ }
106
+ /**
107
+ * Determine if the provided path includes glob pattern tokens.
108
+ * @param sourceFileOrGlob The direct source file path or glob pattern.
109
+ * @returns True if the value is a glob pattern.
110
+ */
111
+ static isGlobPattern(sourceFileOrGlob) {
112
+ return /[*?[\]{}]/u.test(sourceFileOrGlob);
113
+ }
114
+ /**
115
+ * Resolve source files from a direct path or a glob pattern.
116
+ * @param sourceFileOrGlob The direct source file path or glob pattern.
117
+ * @returns The resolved source file paths.
118
+ */
119
+ static resolveSourceFiles(sourceFileOrGlob) {
120
+ if (!FileUtils.isGlobPattern(sourceFileOrGlob)) {
121
+ return FileUtils.fileExists(sourceFileOrGlob) ? [sourceFileOrGlob] : [];
122
+ }
123
+ const sourceFiles = globSync(sourceFileOrGlob, {
124
+ windowsPathsNoEscape: true,
125
+ withFileTypes: false
126
+ });
127
+ return sourceFiles
128
+ .filter(sourceFile => /\.(ts|tsx|mts|cts)$/u.test(sourceFile) && FileUtils.fileExists(sourceFile))
129
+ .sort((sourceFileA, sourceFileB) => sourceFileA.localeCompare(sourceFileB));
130
+ }
131
+ }
132
+ //# sourceMappingURL=fileUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fileUtils.js","sourceRoot":"","sources":["../../../src/utils/fileUtils.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAEhC;;GAEG;AACH,MAAM,OAAO,SAAS;IACrB;;;;OAIG;IACI,MAAM,CAAC,UAAU,CAAC,QAAgB;QACxC,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC;IAC7B,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,QAAQ,CAAC,QAAgB;QACtC,OAAO,YAAY,CAAC,QAAQ,EAAE,OAAO,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,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACzE,CAAC;QAED,MAAM,WAAW,GAAG,QAAQ,CAAC,gBAAgB,EAAE;YAC9C,oBAAoB,EAAE,IAAI;YAC1B,aAAa,EAAE,KAAK;SACpB,CAAC,CAAC;QAEH,OAAO,WAAW;aAChB,MAAM,CACN,UAAU,CAAC,EAAE,CAAC,sBAAsB,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,SAAS,CAAC,UAAU,CAAC,UAAU,CAAC,CACzF;aACA,IAAI,CAAC,CAAC,WAAW,EAAE,WAAW,EAAE,EAAE,CAAC,WAAW,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC,CAAC;IAC9E,CAAC;CACD","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { existsSync, readFileSync } from \"node:fs\";\nimport path from \"node:path\";\nimport { globSync } from \"glob\";\n\n/**\n * Utility helpers for TypeScript file and directory paths.\n */\nexport class FileUtils {\n\t/**\n\t * Does the file exist.\n\t * @param filePath The file path.\n\t * @returns True if the file exists.\n\t */\n\tpublic static fileExists(filePath: string): boolean {\n\t\treturn existsSync(filePath);\n\t}\n\n\t/**\n\t * Read the file.\n\t * @param filePath The file path.\n\t * @returns The file contents.\n\t */\n\tpublic static readFile(filePath: string): string {\n\t\treturn readFileSync(filePath, \"utf-8\");\n\t}\n\n\t/**\n\t * Resolve a path.\n\t * @param filePath The file path.\n\t * @returns The resolved path.\n\t */\n\tpublic static resolvePath(filePath: string): string {\n\t\treturn path.resolve(filePath);\n\t}\n\n\t/**\n\t * Get the current working directory.\n\t * @returns The current working directory.\n\t */\n\tpublic static getCurrentWorkingDirectory(): string {\n\t\treturn process.cwd();\n\t}\n\n\t/**\n\t * Normalize path separators for consistent comparisons.\n\t * @param filePath The file path.\n\t * @returns The normalized file path.\n\t */\n\tpublic static normalizeFilePath(filePath: string): string {\n\t\treturn filePath.replaceAll(\"\\\\\", \"/\");\n\t}\n\n\t/**\n\t * Get the directory portion of a file path.\n\t * @param filePath The file path.\n\t * @returns The directory path.\n\t */\n\tpublic static getDirectoryPath(filePath: string): string {\n\t\tconst normalizedPath = FileUtils.normalizeFilePath(filePath);\n\t\tconst lastSeparatorIndex = normalizedPath.lastIndexOf(\"/\");\n\t\treturn lastSeparatorIndex > -1 ? normalizedPath.slice(0, lastSeparatorIndex) : normalizedPath;\n\t}\n\n\t/**\n\t * Resolve a relative path against a base directory.\n\t * @param baseDirectory The base directory.\n\t * @param relativePath The relative path.\n\t * @returns The resolved path.\n\t */\n\tpublic static resolveRelativePath(baseDirectory: string, relativePath: string): string {\n\t\tconst normalizedRelative = FileUtils.normalizeFilePath(relativePath);\n\n\t\t// Return absolute paths unchanged (Windows drive letter or POSIX root)\n\t\tif (path.isAbsolute(normalizedRelative)) {\n\t\t\treturn normalizedRelative;\n\t\t}\n\n\t\tconst normalizedBase = FileUtils.normalizeFilePath(baseDirectory);\n\n\t\tif (path.isAbsolute(normalizedBase)) {\n\t\t\treturn FileUtils.normalizeFilePath(path.resolve(baseDirectory, relativePath));\n\t\t}\n\n\t\t// Base was relative — resolve to absolute then express relative to CWD to preserve relative form\n\t\treturn FileUtils.normalizeFilePath(\n\t\t\tpath.relative(process.cwd(), path.resolve(baseDirectory, relativePath))\n\t\t);\n\t}\n\n\t/**\n\t * Resolve a local import specifier to a TypeScript source file path.\n\t * @param sourceFilePath The importing source file path.\n\t * @param importPath The import specifier.\n\t * @returns The resolved source file path.\n\t */\n\tpublic static resolveImportSourceFilePath(\n\t\tsourceFilePath: string,\n\t\timportPath: string\n\t): string | undefined {\n\t\tconst sourceDirectory = FileUtils.getDirectoryPath(sourceFilePath);\n\t\tconst resolvedBase = FileUtils.resolveRelativePath(sourceDirectory, importPath);\n\t\tconst baseWithoutExtension = resolvedBase.replace(/\\.(c|m)?js$/u, \"\");\n\t\tconst candidates = [\n\t\t\tresolvedBase,\n\t\t\t`${resolvedBase}.ts`,\n\t\t\t`${resolvedBase}.d.ts`,\n\t\t\t`${resolvedBase}/index.ts`,\n\t\t\t`${resolvedBase}/index.d.ts`,\n\t\t\t`${baseWithoutExtension}.ts`,\n\t\t\t`${baseWithoutExtension}/index.ts`,\n\t\t\t`${baseWithoutExtension}.d.ts`,\n\t\t\t`${baseWithoutExtension}/index.d.ts`\n\t\t];\n\n\t\tfor (const candidate of candidates) {\n\t\t\tif (FileUtils.fileExists(candidate)) {\n\t\t\t\treturn candidate;\n\t\t\t}\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Determine if the provided path includes glob pattern tokens.\n\t * @param sourceFileOrGlob The direct source file path or glob pattern.\n\t * @returns True if the value is a glob pattern.\n\t */\n\tpublic static isGlobPattern(sourceFileOrGlob: string): boolean {\n\t\treturn /[*?[\\]{}]/u.test(sourceFileOrGlob);\n\t}\n\n\t/**\n\t * Resolve source files from a direct path or a glob pattern.\n\t * @param sourceFileOrGlob The direct source file path or glob pattern.\n\t * @returns The resolved source file paths.\n\t */\n\tpublic static resolveSourceFiles(sourceFileOrGlob: string): string[] {\n\t\tif (!FileUtils.isGlobPattern(sourceFileOrGlob)) {\n\t\t\treturn FileUtils.fileExists(sourceFileOrGlob) ? [sourceFileOrGlob] : [];\n\t\t}\n\n\t\tconst sourceFiles = globSync(sourceFileOrGlob, {\n\t\t\twindowsPathsNoEscape: true,\n\t\t\twithFileTypes: false\n\t\t});\n\n\t\treturn sourceFiles\n\t\t\t.filter(\n\t\t\t\tsourceFile => /\\.(ts|tsx|mts|cts)$/u.test(sourceFile) && FileUtils.fileExists(sourceFile)\n\t\t\t)\n\t\t\t.sort((sourceFileA, sourceFileB) => sourceFileA.localeCompare(sourceFileB));\n\t}\n}\n"]}
@@ -0,0 +1,363 @@
1
+ // Copyright 2026 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ import { Is, StringHelper } from "@twin.org/core";
4
+ import * as ts from "typescript";
5
+ import { DiagnosticReporter } from "./diagnosticReporter.js";
6
+ import { FileUtils } from "./fileUtils.js";
7
+ import { JsonSchemaBuilder } from "./jsonSchemaBuilder.js";
8
+ import { Resolver } from "./resolver.js";
9
+ /**
10
+ * Static helpers for import type and type query schema resolution.
11
+ */
12
+ export class ImportTypeQuerySchemaResolver {
13
+ /**
14
+ * Map import type nodes (e.g. import("pkg").Type) to schema references.
15
+ * @param context The generation context.
16
+ * @param typeNode The import type node.
17
+ * @returns The mapped schema.
18
+ */
19
+ static mapImportTypeNodeToSchema(context, typeNode) {
20
+ if (typeNode.isTypeOf ||
21
+ !ts.isLiteralTypeNode(typeNode.argument) ||
22
+ !ts.isStringLiteral(typeNode.argument.literal)) {
23
+ DiagnosticReporter.report(context, typeNode, "jsonSchemaBuilder.diagnostic.unsupportedImportTypeForm", { argument: typeNode.getText() });
24
+ return {};
25
+ }
26
+ const moduleSpecifier = typeNode.argument.literal.text;
27
+ const typeName = ImportTypeQuerySchemaResolver.extractImportTypeName(typeNode.qualifier);
28
+ if (!typeName) {
29
+ DiagnosticReporter.report(context, typeNode, "jsonSchemaBuilder.diagnostic.unresolvedImportTypeQualifier", { argument: moduleSpecifier });
30
+ return {};
31
+ }
32
+ const title = StringHelper.stripPrefix(typeName);
33
+ const existingSchemaId = JsonSchemaBuilder.findExistingSchemaIdByTitle(context, title);
34
+ const resolvedSchemaId = existingSchemaId ??
35
+ ImportTypeQuerySchemaResolver.resolveImportTypeReferenceSchemaId(context, moduleSpecifier, typeName, title);
36
+ return {
37
+ $ref: resolvedSchemaId ?? `${context.namespace}${title}`
38
+ };
39
+ }
40
+ /**
41
+ * Map a type query node (typeof expr) to schema by resolving the referenced variable.
42
+ * @param context The generation context.
43
+ * @param typeNode The type query node.
44
+ * @returns The mapped schema.
45
+ */
46
+ static mapTypeQueryNodeToSchema(context, typeNode) {
47
+ if (ts.isQualifiedName(typeNode.exprName) && ts.isIdentifier(typeNode.exprName.left)) {
48
+ const localValue = JsonSchemaBuilder.resolveLocalConstObjectProperty(context, typeNode.exprName.left.text, typeNode.exprName.right.text);
49
+ if (localValue !== undefined) {
50
+ return { const: localValue };
51
+ }
52
+ const importedValue = ImportTypeQuerySchemaResolver.resolveConstObjectProperty(context, typeNode.exprName.left.text, typeNode.exprName.right.text);
53
+ if (importedValue !== undefined) {
54
+ return { const: importedValue };
55
+ }
56
+ DiagnosticReporter.report(context, typeNode, "jsonSchemaBuilder.diagnostic.unresolvedTypeQueryTarget", { target: typeNode.getText() });
57
+ return {};
58
+ }
59
+ const exprName = ts.isIdentifier(typeNode.exprName) ? typeNode.exprName.text : undefined;
60
+ if (!exprName || !context.activeSourceFile) {
61
+ DiagnosticReporter.report(context, typeNode, "jsonSchemaBuilder.diagnostic.unresolvedTypeQueryTarget", { target: typeNode.getText() });
62
+ return {};
63
+ }
64
+ const localDeclaration = JsonSchemaBuilder.findVariableDeclaration(context.activeSourceFile, exprName);
65
+ if (localDeclaration) {
66
+ if (localDeclaration.type) {
67
+ return JsonSchemaBuilder.mapTypeNodeToSchema(context, localDeclaration.type) ?? {};
68
+ }
69
+ if (localDeclaration.initializer) {
70
+ return JsonSchemaBuilder.inferSchemaFromExpression(context, localDeclaration.initializer);
71
+ }
72
+ }
73
+ const importedTypeQuerySchema = JsonSchemaBuilder.resolveImportedTypeQuerySchema(context, exprName);
74
+ if (importedTypeQuerySchema) {
75
+ return importedTypeQuerySchema;
76
+ }
77
+ DiagnosticReporter.report(context, typeNode, "jsonSchemaBuilder.diagnostic.unresolvedTypeQueryTarget", { target: exprName });
78
+ return {};
79
+ }
80
+ /**
81
+ * Resolve import-type references to local or external schema ids.
82
+ * @param context The generation context.
83
+ * @param moduleSpecifier The import module specifier.
84
+ * @param typeName The imported type name.
85
+ * @param title The stripped schema title.
86
+ * @returns The resolved schema id.
87
+ */
88
+ static resolveImportTypeReferenceSchemaId(context, moduleSpecifier, typeName, title) {
89
+ const mappedReference = JsonSchemaBuilder.resolveReferenceMappingTarget(context, moduleSpecifier, typeName);
90
+ if (moduleSpecifier.startsWith(".")) {
91
+ if (mappedReference?.schemaId) {
92
+ return mappedReference.schemaId;
93
+ }
94
+ const activeFilePath = context.activeSourceFile?.fileName;
95
+ if (!activeFilePath) {
96
+ return undefined;
97
+ }
98
+ const resolvedImportPath = FileUtils.resolveImportSourceFilePath(activeFilePath, moduleSpecifier);
99
+ if (!resolvedImportPath) {
100
+ return undefined;
101
+ }
102
+ const importedSource = FileUtils.readFile(resolvedImportPath);
103
+ if (!importedSource) {
104
+ return undefined;
105
+ }
106
+ JsonSchemaBuilder.parseAllObjectSchemas(context, resolvedImportPath, importedSource, []);
107
+ return context.schemas[context.packageName]?.[title]?.$id;
108
+ }
109
+ const cachedSchemaId = context.schemas[moduleSpecifier]?.[title]?.$id;
110
+ if (cachedSchemaId) {
111
+ return cachedSchemaId;
112
+ }
113
+ const declarationResult = Resolver.resolveTypeDeclarationAst(moduleSpecifier, typeName, context.activeSourceFile?.fileName);
114
+ if (!declarationResult) {
115
+ return mappedReference?.schemaId;
116
+ }
117
+ const externalContext = {
118
+ namespace: mappedReference?.namespace ?? context.namespace,
119
+ packageName: moduleSpecifier,
120
+ schemas: context.schemas,
121
+ activeSourceFile: context.activeSourceFile,
122
+ embeddedSchemaModes: context.embeddedSchemaModes,
123
+ options: context.options
124
+ };
125
+ JsonSchemaBuilder.parseAllObjectSchemas(externalContext, declarationResult.sourceFile.fileName, declarationResult.sourceFile.getFullText(), []);
126
+ return context.schemas[moduleSpecifier]?.[title]?.$id ?? mappedReference?.schemaId;
127
+ }
128
+ /**
129
+ * Resolve a property value from a const object declaration in an imported source file.
130
+ * @param context The generation context.
131
+ * @param objectName The imported object symbol name.
132
+ * @param propertyName The property name to resolve from the object.
133
+ * @returns The resolved literal property value.
134
+ */
135
+ static resolveConstObjectProperty(context, objectName, propertyName) {
136
+ if (!context.activeSourceFile) {
137
+ return undefined;
138
+ }
139
+ const importReference = ImportTypeQuerySchemaResolver.findImportedValueReference(context.activeSourceFile, objectName);
140
+ if (!importReference) {
141
+ return undefined;
142
+ }
143
+ const resolvedPath = ImportTypeQuerySchemaResolver.resolveImportDeclarationSourceFile(context.activeSourceFile.fileName, importReference.moduleSpecifier);
144
+ if (!resolvedPath) {
145
+ return undefined;
146
+ }
147
+ const importedSource = FileUtils.readFile(resolvedPath);
148
+ if (!importedSource) {
149
+ return undefined;
150
+ }
151
+ const importedSourceFile = ts.createSourceFile(resolvedPath, importedSource, ts.ScriptTarget.Latest, true);
152
+ let objDecl = importedSourceFile.statements
153
+ .filter((stmt) => ts.isVariableStatement(stmt))
154
+ .flatMap(stmt => [...stmt.declarationList.declarations])
155
+ .find(decl => ts.isIdentifier(decl.name) && decl.name.text === importReference.importedName);
156
+ objDecl ??= ImportTypeQuerySchemaResolver.findVariableDeclarationInModuleGraph(resolvedPath, importReference.importedName, new Set());
157
+ if (!objDecl) {
158
+ return undefined;
159
+ }
160
+ const valueFromInitializer = ImportTypeQuerySchemaResolver.extractConstObjectPropertyFromDeclarationInitializer(objDecl, propertyName);
161
+ if (valueFromInitializer !== undefined) {
162
+ return valueFromInitializer;
163
+ }
164
+ if (objDecl.type) {
165
+ return ImportTypeQuerySchemaResolver.extractConstObjectPropertyFromDeclarationType(objDecl.type, propertyName);
166
+ }
167
+ return undefined;
168
+ }
169
+ /**
170
+ * Find a variable declaration by traversing import and export chains.
171
+ * @param sourceFilePath The source file path to inspect.
172
+ * @param variableName The variable name to find.
173
+ * @param visitedFiles The set of visited files to prevent recursion cycles.
174
+ * @returns The matched variable declaration.
175
+ */
176
+ static findVariableDeclarationInModuleGraph(sourceFilePath, variableName, visitedFiles) {
177
+ const normalizedSourceFilePath = FileUtils.normalizeFilePath(sourceFilePath);
178
+ if (visitedFiles.has(normalizedSourceFilePath)) {
179
+ return undefined;
180
+ }
181
+ visitedFiles.add(normalizedSourceFilePath);
182
+ const source = FileUtils.readFile(sourceFilePath);
183
+ if (!source) {
184
+ return undefined;
185
+ }
186
+ const sourceFile = ts.createSourceFile(sourceFilePath, source, ts.ScriptTarget.Latest, true);
187
+ const declaration = sourceFile.statements
188
+ .filter((stmt) => ts.isVariableStatement(stmt))
189
+ .flatMap(stmt => [...stmt.declarationList.declarations])
190
+ .find(decl => ts.isIdentifier(decl.name) && decl.name.text === variableName);
191
+ if (declaration) {
192
+ return declaration;
193
+ }
194
+ const compilerOptions = {
195
+ module: ts.ModuleKind.NodeNext,
196
+ moduleResolution: ts.ModuleResolutionKind.NodeNext,
197
+ target: ts.ScriptTarget.ESNext,
198
+ skipLibCheck: true
199
+ };
200
+ const moduleSpecifiers = sourceFile.statements
201
+ .filter(statement => ts.isExportDeclaration(statement) || ts.isImportDeclaration(statement))
202
+ .flatMap(statement => {
203
+ const moduleSpecifier = statement.moduleSpecifier;
204
+ return moduleSpecifier && ts.isStringLiteral(moduleSpecifier) ? [moduleSpecifier.text] : [];
205
+ });
206
+ for (const moduleSpecifier of moduleSpecifiers) {
207
+ const resolvedModulePath = ts.resolveModuleName(moduleSpecifier, sourceFilePath, compilerOptions, ts.sys).resolvedModule?.resolvedFileName;
208
+ if (resolvedModulePath) {
209
+ const declarationInModule = ImportTypeQuerySchemaResolver.findVariableDeclarationInModuleGraph(resolvedModulePath, variableName, visitedFiles);
210
+ if (declarationInModule) {
211
+ return declarationInModule;
212
+ }
213
+ }
214
+ }
215
+ return undefined;
216
+ }
217
+ /**
218
+ * Find an imported symbol reference by local identifier name.
219
+ * @param sourceFile The active source file.
220
+ * @param localName The local identifier name.
221
+ * @returns The imported symbol reference.
222
+ */
223
+ static findImportedValueReference(sourceFile, localName) {
224
+ for (const statement of sourceFile.statements) {
225
+ if (ts.isImportDeclaration(statement) && ts.isStringLiteral(statement.moduleSpecifier)) {
226
+ const bindings = statement.importClause?.namedBindings;
227
+ if (bindings && ts.isNamedImports(bindings)) {
228
+ const importElement = bindings.elements.find(el => el.name.text === localName);
229
+ if (importElement) {
230
+ return {
231
+ moduleSpecifier: statement.moduleSpecifier.text,
232
+ importedName: importElement.propertyName?.text ?? importElement.name.text
233
+ };
234
+ }
235
+ }
236
+ }
237
+ }
238
+ return undefined;
239
+ }
240
+ /**
241
+ * Resolve an import declaration module specifier to a source file.
242
+ * @param containingSourceFilePath The path of the file containing the import declaration.
243
+ * @param moduleSpecifier The module specifier to resolve.
244
+ * @returns The resolved source file path.
245
+ */
246
+ static resolveImportDeclarationSourceFile(containingSourceFilePath, moduleSpecifier) {
247
+ const resolvedContainingSourceFilePath = FileUtils.resolvePath(containingSourceFilePath);
248
+ if (moduleSpecifier.startsWith(".")) {
249
+ return (FileUtils.resolveImportSourceFilePath(resolvedContainingSourceFilePath, moduleSpecifier) ??
250
+ (moduleSpecifier.endsWith(".js")
251
+ ? FileUtils.resolveImportSourceFilePath(resolvedContainingSourceFilePath, `${moduleSpecifier.slice(0, -3)}.ts`)
252
+ : undefined));
253
+ }
254
+ const compilerOptions = {
255
+ module: ts.ModuleKind.NodeNext,
256
+ moduleResolution: ts.ModuleResolutionKind.NodeNext,
257
+ target: ts.ScriptTarget.ESNext,
258
+ skipLibCheck: true
259
+ };
260
+ return ts.resolveModuleName(moduleSpecifier, resolvedContainingSourceFilePath, compilerOptions, ts.sys).resolvedModule?.resolvedFileName;
261
+ }
262
+ /**
263
+ * Extract a const-object property value from a declaration initializer.
264
+ * @param objectDeclaration The variable declaration containing the object initializer.
265
+ * @param propertyName The property name to resolve.
266
+ * @returns The extracted literal property value.
267
+ */
268
+ static extractConstObjectPropertyFromDeclarationInitializer(objectDeclaration, propertyName) {
269
+ if (!objectDeclaration.initializer) {
270
+ return undefined;
271
+ }
272
+ let objLiteral;
273
+ if (ts.isObjectLiteralExpression(objectDeclaration.initializer)) {
274
+ objLiteral = objectDeclaration.initializer;
275
+ }
276
+ else if (ts.isAsExpression(objectDeclaration.initializer) &&
277
+ ts.isObjectLiteralExpression(objectDeclaration.initializer.expression)) {
278
+ objLiteral = objectDeclaration.initializer.expression;
279
+ }
280
+ if (!objLiteral) {
281
+ return undefined;
282
+ }
283
+ const prop = objLiteral.properties
284
+ .filter((p) => ts.isPropertyAssignment(p))
285
+ .find(p => ts.isIdentifier(p.name) && p.name.text === propertyName);
286
+ if (!prop) {
287
+ return undefined;
288
+ }
289
+ if (ts.isStringLiteral(prop.initializer)) {
290
+ return prop.initializer.text;
291
+ }
292
+ if (ts.isNumericLiteral(prop.initializer)) {
293
+ return Number(prop.initializer.text);
294
+ }
295
+ return undefined;
296
+ }
297
+ /**
298
+ * Extract a const-object property value from a declaration type annotation.
299
+ * @param declarationTypeNode The declaration type node to inspect.
300
+ * @param propertyName The property name to resolve.
301
+ * @returns The extracted literal property value.
302
+ */
303
+ static extractConstObjectPropertyFromDeclarationType(declarationTypeNode, propertyName) {
304
+ if (ts.isParenthesizedTypeNode(declarationTypeNode)) {
305
+ return ImportTypeQuerySchemaResolver.extractConstObjectPropertyFromDeclarationType(declarationTypeNode.type, propertyName);
306
+ }
307
+ if (ts.isTypeOperatorNode(declarationTypeNode) &&
308
+ declarationTypeNode.operator === ts.SyntaxKind.ReadonlyKeyword) {
309
+ return ImportTypeQuerySchemaResolver.extractConstObjectPropertyFromDeclarationType(declarationTypeNode.type, propertyName);
310
+ }
311
+ if (ts.isTypeReferenceNode(declarationTypeNode) &&
312
+ ts.isIdentifier(declarationTypeNode.typeName) &&
313
+ declarationTypeNode.typeName.text === "Readonly" &&
314
+ Is.arrayValue(declarationTypeNode.typeArguments)) {
315
+ return ImportTypeQuerySchemaResolver.extractConstObjectPropertyFromDeclarationType(declarationTypeNode.typeArguments[0], propertyName);
316
+ }
317
+ if (ts.isTypeLiteralNode(declarationTypeNode)) {
318
+ const propertySignature = declarationTypeNode.members.find((member) => {
319
+ if (!ts.isPropertySignature(member) || !member.name) {
320
+ return false;
321
+ }
322
+ return ((ts.isIdentifier(member.name) && member.name.text === propertyName) ||
323
+ (ts.isStringLiteral(member.name) && member.name.text === propertyName) ||
324
+ (ts.isNumericLiteral(member.name) && member.name.text === propertyName));
325
+ });
326
+ if (propertySignature?.type) {
327
+ return ImportTypeQuerySchemaResolver.extractLiteralValueFromTypeNode(propertySignature.type);
328
+ }
329
+ }
330
+ return undefined;
331
+ }
332
+ /**
333
+ * Extract a literal value from a type node when possible.
334
+ * @param typeNode The type node to inspect.
335
+ * @returns The extracted literal value.
336
+ */
337
+ static extractLiteralValueFromTypeNode(typeNode) {
338
+ if (ts.isLiteralTypeNode(typeNode)) {
339
+ if (ts.isStringLiteral(typeNode.literal)) {
340
+ return typeNode.literal.text;
341
+ }
342
+ if (ts.isNumericLiteral(typeNode.literal)) {
343
+ return Number(typeNode.literal.text);
344
+ }
345
+ }
346
+ return undefined;
347
+ }
348
+ /**
349
+ * Extract a referenced type name from an import type qualifier.
350
+ * @param qualifier The import type qualifier.
351
+ * @returns The extracted type name.
352
+ */
353
+ static extractImportTypeName(qualifier) {
354
+ if (!qualifier) {
355
+ return undefined;
356
+ }
357
+ if (ts.isIdentifier(qualifier)) {
358
+ return qualifier.text;
359
+ }
360
+ return qualifier.right.text;
361
+ }
362
+ }
363
+ //# sourceMappingURL=importTypeQuerySchemaResolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"importTypeQuerySchemaResolver.js","sourceRoot":"","sources":["../../../src/utils/importTypeQuerySchemaResolver.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,EAAE,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAElD,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAGzC;;GAEG;AACH,MAAM,OAAO,6BAA6B;IACzC;;;;;OAKG;IACI,MAAM,CAAC,yBAAyB,CACtC,OAAmC,EACnC,QAA2B;QAE3B,IACC,QAAQ,CAAC,QAAQ;YACjB,CAAC,EAAE,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AAQ,CAAC,EAAE,CAAC;YACpC,IAAI,EAAE,CAAC,eAAe,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;gBAC1C,OAAO,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC;YAC9B,CAAC;YAED,IAAI,EAAE,CAAC,gBAAgB,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;gBAC3C,OAAO,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YACtC,CAAC;QACF,CAAC;QAED,OAAO,SAAS,CAAC;IAClB,CAAC;IAED;;;;OAIG;IACK,MAAM,CAAC,qBAAqB,CAAC,SAAoC;QACxE,IAAI,CAAC,SAAS,EAAE,CAAC;YAChB,OAAO,SAAS,CAAC;QAClB,CAAC;QAED,IAAI,EAAE,CAAC,YAAY,CAAC,SAAS,CAAC,EAAE,CAAC;YAChC,OAAO,SAAS,CAAC,IAAI,CAAC;QACvB,CAAC;QAED,OAAO,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC;IAC7B,CAAC;CACD","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { Is, StringHelper } from \"@twin.org/core\";\nimport type { IJsonSchema } from \"@twin.org/tools-models\";\nimport * as ts from \"typescript\";\nimport { DiagnosticReporter } from \"./diagnosticReporter.js\";\nimport { FileUtils } from \"./fileUtils.js\";\nimport { JsonSchemaBuilder } from \"./jsonSchemaBuilder.js\";\nimport { Resolver } from \"./resolver.js\";\nimport type { ITypeScriptToSchemaContext } from \"../models/ITypeScriptToSchemaContext.js\";\n\n/**\n * Static helpers for import type and type query schema resolution.\n */\nexport class ImportTypeQuerySchemaResolver {\n\t/**\n\t * Map import type nodes (e.g. import(\"pkg\").Type) to schema references.\n\t * @param context The generation context.\n\t * @param typeNode The import type node.\n\t * @returns The mapped schema.\n\t */\n\tpublic static mapImportTypeNodeToSchema(\n\t\tcontext: ITypeScriptToSchemaContext,\n\t\ttypeNode: ts.ImportTypeNode\n\t): IJsonSchema | undefined {\n\t\tif (\n\t\t\ttypeNode.isTypeOf ||\n\t\t\t!ts.isLiteralTypeNode(typeNode.argument) ||\n\t\t\t!ts.isStringLiteral(typeNode.argument.literal)\n\t\t) {\n\t\t\tDiagnosticReporter.report(\n\t\t\t\tcontext,\n\t\t\t\ttypeNode,\n\t\t\t\t\"jsonSchemaBuilder.diagnostic.unsupportedImportTypeForm\",\n\t\t\t\t{ argument: typeNode.getText() }\n\t\t\t);\n\t\t\treturn {};\n\t\t}\n\n\t\tconst moduleSpecifier = typeNode.argument.literal.text;\n\t\tconst typeName = ImportTypeQuerySchemaResolver.extractImportTypeName(typeNode.qualifier);\n\t\tif (!typeName) {\n\t\t\tDiagnosticReporter.report(\n\t\t\t\tcontext,\n\t\t\t\ttypeNode,\n\t\t\t\t\"jsonSchemaBuilder.diagnostic.unresolvedImportTypeQualifier\",\n\t\t\t\t{ argument: moduleSpecifier }\n\t\t\t);\n\t\t\treturn {};\n\t\t}\n\n\t\tconst title = StringHelper.stripPrefix(typeName);\n\t\tconst existingSchemaId = JsonSchemaBuilder.findExistingSchemaIdByTitle(context, title);\n\t\tconst resolvedSchemaId =\n\t\t\texistingSchemaId ??\n\t\t\tImportTypeQuerySchemaResolver.resolveImportTypeReferenceSchemaId(\n\t\t\t\tcontext,\n\t\t\t\tmoduleSpecifier,\n\t\t\t\ttypeName,\n\t\t\t\ttitle\n\t\t\t);\n\n\t\treturn {\n\t\t\t$ref: resolvedSchemaId ?? `${context.namespace}${title}`\n\t\t};\n\t}\n\n\t/**\n\t * Map a type query node (typeof expr) to schema by resolving the referenced variable.\n\t * @param context The generation context.\n\t * @param typeNode The type query node.\n\t * @returns The mapped schema.\n\t */\n\tpublic static mapTypeQueryNodeToSchema(\n\t\tcontext: ITypeScriptToSchemaContext,\n\t\ttypeNode: ts.TypeQueryNode\n\t): IJsonSchema {\n\t\tif (ts.isQualifiedName(typeNode.exprName) && ts.isIdentifier(typeNode.exprName.left)) {\n\t\t\tconst localValue = JsonSchemaBuilder.resolveLocalConstObjectProperty(\n\t\t\t\tcontext,\n\t\t\t\ttypeNode.exprName.left.text,\n\t\t\t\ttypeNode.exprName.right.text\n\t\t\t);\n\t\t\tif (localValue !== undefined) {\n\t\t\t\treturn { const: localValue };\n\t\t\t}\n\n\t\t\tconst importedValue = ImportTypeQuerySchemaResolver.resolveConstObjectProperty(\n\t\t\t\tcontext,\n\t\t\t\ttypeNode.exprName.left.text,\n\t\t\t\ttypeNode.exprName.right.text\n\t\t\t);\n\t\t\tif (importedValue !== undefined) {\n\t\t\t\treturn { const: importedValue };\n\t\t\t}\n\n\t\t\tDiagnosticReporter.report(\n\t\t\t\tcontext,\n\t\t\t\ttypeNode,\n\t\t\t\t\"jsonSchemaBuilder.diagnostic.unresolvedTypeQueryTarget\",\n\t\t\t\t{ target: typeNode.getText() }\n\t\t\t);\n\t\t\treturn {};\n\t\t}\n\n\t\tconst exprName = ts.isIdentifier(typeNode.exprName) ? typeNode.exprName.text : undefined;\n\t\tif (!exprName || !context.activeSourceFile) {\n\t\t\tDiagnosticReporter.report(\n\t\t\t\tcontext,\n\t\t\t\ttypeNode,\n\t\t\t\t\"jsonSchemaBuilder.diagnostic.unresolvedTypeQueryTarget\",\n\t\t\t\t{ target: typeNode.getText() }\n\t\t\t);\n\t\t\treturn {};\n\t\t}\n\n\t\tconst localDeclaration = JsonSchemaBuilder.findVariableDeclaration(\n\t\t\tcontext.activeSourceFile,\n\t\t\texprName\n\t\t);\n\t\tif (localDeclaration) {\n\t\t\tif (localDeclaration.type) {\n\t\t\t\treturn JsonSchemaBuilder.mapTypeNodeToSchema(context, localDeclaration.type) ?? {};\n\t\t\t}\n\t\t\tif (localDeclaration.initializer) {\n\t\t\t\treturn JsonSchemaBuilder.inferSchemaFromExpression(context, localDeclaration.initializer);\n\t\t\t}\n\t\t}\n\n\t\tconst importedTypeQuerySchema = JsonSchemaBuilder.resolveImportedTypeQuerySchema(\n\t\t\tcontext,\n\t\t\texprName\n\t\t);\n\t\tif (importedTypeQuerySchema) {\n\t\t\treturn importedTypeQuerySchema;\n\t\t}\n\n\t\tDiagnosticReporter.report(\n\t\t\tcontext,\n\t\t\ttypeNode,\n\t\t\t\"jsonSchemaBuilder.diagnostic.unresolvedTypeQueryTarget\",\n\t\t\t{ target: exprName }\n\t\t);\n\n\t\treturn {};\n\t}\n\n\t/**\n\t * Resolve import-type references to local or external schema ids.\n\t * @param context The generation context.\n\t * @param moduleSpecifier The import module specifier.\n\t * @param typeName The imported type name.\n\t * @param title The stripped schema title.\n\t * @returns The resolved schema id.\n\t */\n\tpublic static resolveImportTypeReferenceSchemaId(\n\t\tcontext: ITypeScriptToSchemaContext,\n\t\tmoduleSpecifier: string,\n\t\ttypeName: string,\n\t\ttitle: string\n\t): string | undefined {\n\t\tconst mappedReference = JsonSchemaBuilder.resolveReferenceMappingTarget(\n\t\t\tcontext,\n\t\t\tmoduleSpecifier,\n\t\t\ttypeName\n\t\t);\n\n\t\tif (moduleSpecifier.startsWith(\".\")) {\n\t\t\tif (mappedReference?.schemaId) {\n\t\t\t\treturn mappedReference.schemaId;\n\t\t\t}\n\n\t\t\tconst activeFilePath = context.activeSourceFile?.fileName;\n\t\t\tif (!activeFilePath) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tconst resolvedImportPath = FileUtils.resolveImportSourceFilePath(\n\t\t\t\tactiveFilePath,\n\t\t\t\tmoduleSpecifier\n\t\t\t);\n\t\t\tif (!resolvedImportPath) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tconst importedSource = FileUtils.readFile(resolvedImportPath);\n\t\t\tif (!importedSource) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tJsonSchemaBuilder.parseAllObjectSchemas(context, resolvedImportPath, importedSource, []);\n\t\t\treturn context.schemas[context.packageName]?.[title]?.$id;\n\t\t}\n\n\t\tconst cachedSchemaId = context.schemas[moduleSpecifier]?.[title]?.$id;\n\t\tif (cachedSchemaId) {\n\t\t\treturn cachedSchemaId;\n\t\t}\n\n\t\tconst declarationResult = Resolver.resolveTypeDeclarationAst(\n\t\t\tmoduleSpecifier,\n\t\t\ttypeName,\n\t\t\tcontext.activeSourceFile?.fileName\n\t\t);\n\t\tif (!declarationResult) {\n\t\t\treturn mappedReference?.schemaId;\n\t\t}\n\n\t\tconst externalContext: ITypeScriptToSchemaContext = {\n\t\t\tnamespace: mappedReference?.namespace ?? context.namespace,\n\t\t\tpackageName: moduleSpecifier,\n\t\t\tschemas: context.schemas,\n\t\t\tactiveSourceFile: context.activeSourceFile,\n\t\t\tembeddedSchemaModes: context.embeddedSchemaModes,\n\t\t\toptions: context.options\n\t\t};\n\n\t\tJsonSchemaBuilder.parseAllObjectSchemas(\n\t\t\texternalContext,\n\t\t\tdeclarationResult.sourceFile.fileName,\n\t\t\tdeclarationResult.sourceFile.getFullText(),\n\t\t\t[]\n\t\t);\n\n\t\treturn context.schemas[moduleSpecifier]?.[title]?.$id ?? mappedReference?.schemaId;\n\t}\n\n\t/**\n\t * Resolve a property value from a const object declaration in an imported source file.\n\t * @param context The generation context.\n\t * @param objectName The imported object symbol name.\n\t * @param propertyName The property name to resolve from the object.\n\t * @returns The resolved literal property value.\n\t */\n\tprivate static resolveConstObjectProperty(\n\t\tcontext: ITypeScriptToSchemaContext,\n\t\tobjectName: string,\n\t\tpropertyName: string\n\t): string | number | undefined {\n\t\tif (!context.activeSourceFile) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst importReference = ImportTypeQuerySchemaResolver.findImportedValueReference(\n\t\t\tcontext.activeSourceFile,\n\t\t\tobjectName\n\t\t);\n\t\tif (!importReference) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst resolvedPath = ImportTypeQuerySchemaResolver.resolveImportDeclarationSourceFile(\n\t\t\tcontext.activeSourceFile.fileName,\n\t\t\timportReference.moduleSpecifier\n\t\t);\n\t\tif (!resolvedPath) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst importedSource = FileUtils.readFile(resolvedPath);\n\t\tif (!importedSource) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst importedSourceFile = ts.createSourceFile(\n\t\t\tresolvedPath,\n\t\t\timportedSource,\n\t\t\tts.ScriptTarget.Latest,\n\t\t\ttrue\n\t\t);\n\n\t\tlet objDecl = importedSourceFile.statements\n\t\t\t.filter((stmt): stmt is ts.VariableStatement => ts.isVariableStatement(stmt))\n\t\t\t.flatMap(stmt => [...stmt.declarationList.declarations])\n\t\t\t.find(decl => ts.isIdentifier(decl.name) && decl.name.text === importReference.importedName);\n\n\t\tobjDecl ??= ImportTypeQuerySchemaResolver.findVariableDeclarationInModuleGraph(\n\t\t\tresolvedPath,\n\t\t\timportReference.importedName,\n\t\t\tnew Set<string>()\n\t\t);\n\n\t\tif (!objDecl) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst valueFromInitializer =\n\t\t\tImportTypeQuerySchemaResolver.extractConstObjectPropertyFromDeclarationInitializer(\n\t\t\t\tobjDecl,\n\t\t\t\tpropertyName\n\t\t\t);\n\t\tif (valueFromInitializer !== undefined) {\n\t\t\treturn valueFromInitializer;\n\t\t}\n\n\t\tif (objDecl.type) {\n\t\t\treturn ImportTypeQuerySchemaResolver.extractConstObjectPropertyFromDeclarationType(\n\t\t\t\tobjDecl.type,\n\t\t\t\tpropertyName\n\t\t\t);\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Find a variable declaration by traversing import and export chains.\n\t * @param sourceFilePath The source file path to inspect.\n\t * @param variableName The variable name to find.\n\t * @param visitedFiles The set of visited files to prevent recursion cycles.\n\t * @returns The matched variable declaration.\n\t */\n\tprivate static findVariableDeclarationInModuleGraph(\n\t\tsourceFilePath: string,\n\t\tvariableName: string,\n\t\tvisitedFiles: Set<string>\n\t): ts.VariableDeclaration | undefined {\n\t\tconst normalizedSourceFilePath = FileUtils.normalizeFilePath(sourceFilePath);\n\t\tif (visitedFiles.has(normalizedSourceFilePath)) {\n\t\t\treturn undefined;\n\t\t}\n\t\tvisitedFiles.add(normalizedSourceFilePath);\n\n\t\tconst source = FileUtils.readFile(sourceFilePath);\n\t\tif (!source) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst sourceFile = ts.createSourceFile(sourceFilePath, source, ts.ScriptTarget.Latest, true);\n\n\t\tconst declaration = sourceFile.statements\n\t\t\t.filter((stmt): stmt is ts.VariableStatement => ts.isVariableStatement(stmt))\n\t\t\t.flatMap(stmt => [...stmt.declarationList.declarations])\n\t\t\t.find(decl => ts.isIdentifier(decl.name) && decl.name.text === variableName);\n\t\tif (declaration) {\n\t\t\treturn declaration;\n\t\t}\n\n\t\tconst compilerOptions: ts.CompilerOptions = {\n\t\t\tmodule: ts.ModuleKind.NodeNext,\n\t\t\tmoduleResolution: ts.ModuleResolutionKind.NodeNext,\n\t\t\ttarget: ts.ScriptTarget.ESNext,\n\t\t\tskipLibCheck: true\n\t\t};\n\n\t\tconst moduleSpecifiers = sourceFile.statements\n\t\t\t.filter(statement => ts.isExportDeclaration(statement) || ts.isImportDeclaration(statement))\n\t\t\t.flatMap(statement => {\n\t\t\t\tconst moduleSpecifier = statement.moduleSpecifier;\n\t\t\t\treturn moduleSpecifier && ts.isStringLiteral(moduleSpecifier) ? [moduleSpecifier.text] : [];\n\t\t\t});\n\n\t\tfor (const moduleSpecifier of moduleSpecifiers) {\n\t\t\tconst resolvedModulePath = ts.resolveModuleName(\n\t\t\t\tmoduleSpecifier,\n\t\t\t\tsourceFilePath,\n\t\t\t\tcompilerOptions,\n\t\t\t\tts.sys\n\t\t\t).resolvedModule?.resolvedFileName;\n\n\t\t\tif (resolvedModulePath) {\n\t\t\t\tconst declarationInModule =\n\t\t\t\t\tImportTypeQuerySchemaResolver.findVariableDeclarationInModuleGraph(\n\t\t\t\t\t\tresolvedModulePath,\n\t\t\t\t\t\tvariableName,\n\t\t\t\t\t\tvisitedFiles\n\t\t\t\t\t);\n\t\t\t\tif (declarationInModule) {\n\t\t\t\t\treturn declarationInModule;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Find an imported symbol reference by local identifier name.\n\t * @param sourceFile The active source file.\n\t * @param localName The local identifier name.\n\t * @returns The imported symbol reference.\n\t */\n\tprivate static findImportedValueReference(\n\t\tsourceFile: ts.SourceFile,\n\t\tlocalName: string\n\t):\n\t\t| {\n\t\t\t\tmoduleSpecifier: string;\n\t\t\t\timportedName: string;\n\t\t }\n\t\t| undefined {\n\t\tfor (const statement of sourceFile.statements) {\n\t\t\tif (ts.isImportDeclaration(statement) && ts.isStringLiteral(statement.moduleSpecifier)) {\n\t\t\t\tconst bindings = statement.importClause?.namedBindings;\n\t\t\t\tif (bindings && ts.isNamedImports(bindings)) {\n\t\t\t\t\tconst importElement = bindings.elements.find(el => el.name.text === localName);\n\t\t\t\t\tif (importElement) {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tmoduleSpecifier: statement.moduleSpecifier.text,\n\t\t\t\t\t\t\timportedName: importElement.propertyName?.text ?? importElement.name.text\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Resolve an import declaration module specifier to a source file.\n\t * @param containingSourceFilePath The path of the file containing the import declaration.\n\t * @param moduleSpecifier The module specifier to resolve.\n\t * @returns The resolved source file path.\n\t */\n\tprivate static resolveImportDeclarationSourceFile(\n\t\tcontainingSourceFilePath: string,\n\t\tmoduleSpecifier: string\n\t): string | undefined {\n\t\tconst resolvedContainingSourceFilePath = FileUtils.resolvePath(containingSourceFilePath);\n\n\t\tif (moduleSpecifier.startsWith(\".\")) {\n\t\t\treturn (\n\t\t\t\tFileUtils.resolveImportSourceFilePath(resolvedContainingSourceFilePath, moduleSpecifier) ??\n\t\t\t\t(moduleSpecifier.endsWith(\".js\")\n\t\t\t\t\t? FileUtils.resolveImportSourceFilePath(\n\t\t\t\t\t\t\tresolvedContainingSourceFilePath,\n\t\t\t\t\t\t\t`${moduleSpecifier.slice(0, -3)}.ts`\n\t\t\t\t\t\t)\n\t\t\t\t\t: undefined)\n\t\t\t);\n\t\t}\n\n\t\tconst compilerOptions: ts.CompilerOptions = {\n\t\t\tmodule: ts.ModuleKind.NodeNext,\n\t\t\tmoduleResolution: ts.ModuleResolutionKind.NodeNext,\n\t\t\ttarget: ts.ScriptTarget.ESNext,\n\t\t\tskipLibCheck: true\n\t\t};\n\n\t\treturn ts.resolveModuleName(\n\t\t\tmoduleSpecifier,\n\t\t\tresolvedContainingSourceFilePath,\n\t\t\tcompilerOptions,\n\t\t\tts.sys\n\t\t).resolvedModule?.resolvedFileName;\n\t}\n\n\t/**\n\t * Extract a const-object property value from a declaration initializer.\n\t * @param objectDeclaration The variable declaration containing the object initializer.\n\t * @param propertyName The property name to resolve.\n\t * @returns The extracted literal property value.\n\t */\n\tprivate static extractConstObjectPropertyFromDeclarationInitializer(\n\t\tobjectDeclaration: ts.VariableDeclaration,\n\t\tpropertyName: string\n\t): string | number | undefined {\n\t\tif (!objectDeclaration.initializer) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tlet objLiteral: ts.ObjectLiteralExpression | undefined;\n\t\tif (ts.isObjectLiteralExpression(objectDeclaration.initializer)) {\n\t\t\tobjLiteral = objectDeclaration.initializer;\n\t\t} else if (\n\t\t\tts.isAsExpression(objectDeclaration.initializer) &&\n\t\t\tts.isObjectLiteralExpression(objectDeclaration.initializer.expression)\n\t\t) {\n\t\t\tobjLiteral = objectDeclaration.initializer.expression;\n\t\t}\n\n\t\tif (!objLiteral) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst prop = objLiteral.properties\n\t\t\t.filter((p): p is ts.PropertyAssignment => ts.isPropertyAssignment(p))\n\t\t\t.find(p => ts.isIdentifier(p.name) && p.name.text === propertyName);\n\n\t\tif (!prop) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tif (ts.isStringLiteral(prop.initializer)) {\n\t\t\treturn prop.initializer.text;\n\t\t}\n\t\tif (ts.isNumericLiteral(prop.initializer)) {\n\t\t\treturn Number(prop.initializer.text);\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Extract a const-object property value from a declaration type annotation.\n\t * @param declarationTypeNode The declaration type node to inspect.\n\t * @param propertyName The property name to resolve.\n\t * @returns The extracted literal property value.\n\t */\n\tprivate static extractConstObjectPropertyFromDeclarationType(\n\t\tdeclarationTypeNode: ts.TypeNode,\n\t\tpropertyName: string\n\t): string | number | undefined {\n\t\tif (ts.isParenthesizedTypeNode(declarationTypeNode)) {\n\t\t\treturn ImportTypeQuerySchemaResolver.extractConstObjectPropertyFromDeclarationType(\n\t\t\t\tdeclarationTypeNode.type,\n\t\t\t\tpropertyName\n\t\t\t);\n\t\t}\n\n\t\tif (\n\t\t\tts.isTypeOperatorNode(declarationTypeNode) &&\n\t\t\tdeclarationTypeNode.operator === ts.SyntaxKind.ReadonlyKeyword\n\t\t) {\n\t\t\treturn ImportTypeQuerySchemaResolver.extractConstObjectPropertyFromDeclarationType(\n\t\t\t\tdeclarationTypeNode.type,\n\t\t\t\tpropertyName\n\t\t\t);\n\t\t}\n\n\t\tif (\n\t\t\tts.isTypeReferenceNode(declarationTypeNode) &&\n\t\t\tts.isIdentifier(declarationTypeNode.typeName) &&\n\t\t\tdeclarationTypeNode.typeName.text === \"Readonly\" &&\n\t\t\tIs.arrayValue(declarationTypeNode.typeArguments)\n\t\t) {\n\t\t\treturn ImportTypeQuerySchemaResolver.extractConstObjectPropertyFromDeclarationType(\n\t\t\t\tdeclarationTypeNode.typeArguments[0],\n\t\t\t\tpropertyName\n\t\t\t);\n\t\t}\n\n\t\tif (ts.isTypeLiteralNode(declarationTypeNode)) {\n\t\t\tconst propertySignature = declarationTypeNode.members.find(\n\t\t\t\t(member): member is ts.PropertySignature => {\n\t\t\t\t\tif (!ts.isPropertySignature(member) || !member.name) {\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn (\n\t\t\t\t\t\t(ts.isIdentifier(member.name) && member.name.text === propertyName) ||\n\t\t\t\t\t\t(ts.isStringLiteral(member.name) && member.name.text === propertyName) ||\n\t\t\t\t\t\t(ts.isNumericLiteral(member.name) && member.name.text === propertyName)\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tif (propertySignature?.type) {\n\t\t\t\treturn ImportTypeQuerySchemaResolver.extractLiteralValueFromTypeNode(\n\t\t\t\t\tpropertySignature.type\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Extract a literal value from a type node when possible.\n\t * @param typeNode The type node to inspect.\n\t * @returns The extracted literal value.\n\t */\n\tprivate static extractLiteralValueFromTypeNode(\n\t\ttypeNode: ts.TypeNode\n\t): string | number | undefined {\n\t\tif (ts.isLiteralTypeNode(typeNode)) {\n\t\t\tif (ts.isStringLiteral(typeNode.literal)) {\n\t\t\t\treturn typeNode.literal.text;\n\t\t\t}\n\n\t\t\tif (ts.isNumericLiteral(typeNode.literal)) {\n\t\t\t\treturn Number(typeNode.literal.text);\n\t\t\t}\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Extract a referenced type name from an import type qualifier.\n\t * @param qualifier The import type qualifier.\n\t * @returns The extracted type name.\n\t */\n\tprivate static extractImportTypeName(qualifier: ts.EntityName | undefined): string | undefined {\n\t\tif (!qualifier) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tif (ts.isIdentifier(qualifier)) {\n\t\t\treturn qualifier.text;\n\t\t}\n\n\t\treturn qualifier.right.text;\n\t}\n}\n"]}