@twin.org/tools-core 0.0.3-next.14 → 0.0.3-next.16

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 (133) hide show
  1. package/README.md +2 -2
  2. package/dist/es/index.js +20 -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/utils/constants.js +43 -0
  11. package/dist/es/utils/constants.js.map +1 -0
  12. package/dist/es/utils/diagnosticReporter.js +32 -0
  13. package/dist/es/utils/diagnosticReporter.js.map +1 -0
  14. package/dist/es/utils/disallowedTypeGuard.js +151 -0
  15. package/dist/es/utils/disallowedTypeGuard.js.map +1 -0
  16. package/dist/es/utils/enum.js +152 -0
  17. package/dist/es/utils/enum.js.map +1 -0
  18. package/dist/es/utils/fileUtils.js +130 -0
  19. package/dist/es/utils/fileUtils.js.map +1 -0
  20. package/dist/es/utils/importTypeQuerySchemaResolver.js +328 -0
  21. package/dist/es/utils/importTypeQuerySchemaResolver.js.map +1 -0
  22. package/dist/es/utils/indexSignaturePatternResolver.js +94 -0
  23. package/dist/es/utils/indexSignaturePatternResolver.js.map +1 -0
  24. package/dist/es/utils/intersectionSchemaMerger.js +85 -0
  25. package/dist/es/utils/intersectionSchemaMerger.js.map +1 -0
  26. package/dist/es/utils/jsonSchemaBuilder.js +3189 -0
  27. package/dist/es/utils/jsonSchemaBuilder.js.map +1 -0
  28. package/dist/es/utils/mappedTypeSchemaResolver.js +231 -0
  29. package/dist/es/utils/mappedTypeSchemaResolver.js.map +1 -0
  30. package/dist/es/utils/objectTransformer.js +162 -0
  31. package/dist/es/utils/objectTransformer.js.map +1 -0
  32. package/dist/es/utils/regEx.js +128 -0
  33. package/dist/es/utils/regEx.js.map +1 -0
  34. package/dist/es/utils/resolver.js +164 -0
  35. package/dist/es/utils/resolver.js.map +1 -0
  36. package/dist/es/utils/templateLiteralPatternBuilder.js +94 -0
  37. package/dist/es/utils/templateLiteralPatternBuilder.js.map +1 -0
  38. package/dist/es/utils/typeScriptToSchema.js +102 -0
  39. package/dist/es/utils/typeScriptToSchema.js.map +1 -0
  40. package/dist/es/utils/utility.js +134 -0
  41. package/dist/es/utils/utility.js.map +1 -0
  42. package/dist/es/utils/utilityTypeSchemaMapper.js +412 -0
  43. package/dist/es/utils/utilityTypeSchemaMapper.js.map +1 -0
  44. package/dist/types/index.d.ts +20 -11
  45. package/dist/types/models/ITypeScriptToSchemaContext.d.ts +64 -0
  46. package/dist/types/models/ITypeScriptToSchemaDiagnostics.d.ts +31 -0
  47. package/dist/types/models/ITypeScriptToSchemaOptions.d.ts +22 -0
  48. package/dist/types/utils/constants.d.ts +13 -0
  49. package/dist/types/utils/diagnosticReporter.d.ts +17 -0
  50. package/dist/types/utils/disallowedTypeGuard.d.ts +16 -0
  51. package/dist/types/utils/enum.d.ts +42 -0
  52. package/dist/types/utils/fileUtils.d.ts +66 -0
  53. package/dist/types/utils/importTypeQuerySchemaResolver.d.ts +52 -0
  54. package/dist/types/utils/indexSignaturePatternResolver.d.ts +21 -0
  55. package/dist/types/utils/intersectionSchemaMerger.d.ts +16 -0
  56. package/dist/types/utils/jsonSchemaBuilder.d.ts +721 -0
  57. package/dist/types/utils/mappedTypeSchemaResolver.d.ts +46 -0
  58. package/dist/types/utils/objectTransformer.d.ts +33 -0
  59. package/dist/types/utils/regEx.d.ts +24 -0
  60. package/dist/types/utils/resolver.d.ts +16 -0
  61. package/dist/types/utils/templateLiteralPatternBuilder.d.ts +12 -0
  62. package/dist/types/utils/typeScriptToSchema.d.ts +31 -0
  63. package/dist/types/utils/utility.d.ts +58 -0
  64. package/dist/types/utils/utilityTypeSchemaMapper.d.ts +92 -0
  65. package/docs/changelog.md +22 -1
  66. package/docs/examples.md +87 -1
  67. package/docs/reference/classes/Constants.md +29 -0
  68. package/docs/reference/classes/DiagnosticReporter.md +49 -0
  69. package/docs/reference/classes/DisallowedTypeGuard.md +35 -0
  70. package/docs/reference/classes/Enum.md +93 -0
  71. package/docs/reference/classes/FileUtils.md +237 -0
  72. package/docs/reference/classes/ImportTypeQuerySchemaResolver.md +87 -0
  73. package/docs/reference/classes/IndexSignaturePatternResolver.md +69 -0
  74. package/docs/reference/classes/IntersectionSchemaMerger.md +48 -0
  75. package/docs/reference/classes/JsonSchemaBuilder.md +2772 -0
  76. package/docs/reference/classes/MappedTypeSchemaResolver.md +211 -0
  77. package/docs/reference/classes/ObjectTransformer.md +119 -0
  78. package/docs/reference/classes/RegEx.md +99 -0
  79. package/docs/reference/classes/Resolver.md +41 -0
  80. package/docs/reference/classes/TemplateLiteralPatternBuilder.md +35 -0
  81. package/docs/reference/classes/TypeScriptToSchema.md +91 -0
  82. package/docs/reference/classes/Utility.md +164 -0
  83. package/docs/reference/classes/UtilityTypeSchemaMapper.md +341 -0
  84. package/docs/reference/index.md +20 -14
  85. package/docs/reference/interfaces/ITypeScriptToSchemaContext.md +113 -0
  86. package/docs/reference/interfaces/ITypeScriptToSchemaDiagnostics.md +55 -0
  87. package/docs/reference/interfaces/ITypeScriptToSchemaOptions.md +44 -0
  88. package/locales/en.json +30 -1
  89. package/package.json +4 -3
  90. package/dist/es/models/IJsonSchema.js +0 -2
  91. package/dist/es/models/IJsonSchema.js.map +0 -1
  92. package/dist/es/models/IOpenApi.js +0 -2
  93. package/dist/es/models/IOpenApi.js.map +0 -1
  94. package/dist/es/models/IOpenApiExample.js +0 -4
  95. package/dist/es/models/IOpenApiExample.js.map +0 -1
  96. package/dist/es/models/IOpenApiHeader.js +0 -4
  97. package/dist/es/models/IOpenApiHeader.js.map +0 -1
  98. package/dist/es/models/IOpenApiPathMethod.js +0 -2
  99. package/dist/es/models/IOpenApiPathMethod.js.map +0 -1
  100. package/dist/es/models/IOpenApiResponse.js +0 -2
  101. package/dist/es/models/IOpenApiResponse.js.map +0 -1
  102. package/dist/es/models/IOpenApiSecurityScheme.js +0 -4
  103. package/dist/es/models/IOpenApiSecurityScheme.js.map +0 -1
  104. package/dist/es/models/IPackageJson.js +0 -4
  105. package/dist/es/models/IPackageJson.js.map +0 -1
  106. package/dist/es/models/jsonTypeName.js +0 -2
  107. package/dist/es/models/jsonTypeName.js.map +0 -1
  108. package/dist/es/utils/jsonSchemaHelper.js +0 -282
  109. package/dist/es/utils/jsonSchemaHelper.js.map +0 -1
  110. package/dist/es/utils/openApiHelper.js +0 -12
  111. package/dist/es/utils/openApiHelper.js.map +0 -1
  112. package/dist/types/models/IJsonSchema.d.ts +0 -5
  113. package/dist/types/models/IOpenApi.d.ts +0 -54
  114. package/dist/types/models/IOpenApiExample.d.ts +0 -13
  115. package/dist/types/models/IOpenApiHeader.d.ts +0 -19
  116. package/dist/types/models/IOpenApiPathMethod.d.ts +0 -65
  117. package/dist/types/models/IOpenApiResponse.d.ts +0 -32
  118. package/dist/types/models/IOpenApiSecurityScheme.d.ts +0 -25
  119. package/dist/types/models/IPackageJson.d.ts +0 -15
  120. package/dist/types/models/jsonTypeName.d.ts +0 -5
  121. package/dist/types/utils/jsonSchemaHelper.d.ts +0 -78
  122. package/dist/types/utils/openApiHelper.d.ts +0 -9
  123. package/docs/reference/classes/JsonSchemaHelper.md +0 -233
  124. package/docs/reference/classes/OpenApiHelper.md +0 -21
  125. package/docs/reference/interfaces/IOpenApi.md +0 -103
  126. package/docs/reference/interfaces/IOpenApiExample.md +0 -19
  127. package/docs/reference/interfaces/IOpenApiHeader.md +0 -31
  128. package/docs/reference/interfaces/IOpenApiPathMethod.md +0 -119
  129. package/docs/reference/interfaces/IOpenApiResponse.md +0 -35
  130. package/docs/reference/interfaces/IOpenApiSecurityScheme.md +0 -43
  131. package/docs/reference/interfaces/IPackageJson.md +0 -23
  132. package/docs/reference/type-aliases/IJsonSchema.md +0 -5
  133. package/docs/reference/type-aliases/JsonTypeName.md +0 -5
@@ -0,0 +1,237 @@
1
+ # Class: FileUtils
2
+
3
+ Utility helpers for TypeScript file and directory paths.
4
+
5
+ ## Constructors
6
+
7
+ ### Constructor
8
+
9
+ > **new FileUtils**(): `FileUtils`
10
+
11
+ #### Returns
12
+
13
+ `FileUtils`
14
+
15
+ ## Methods
16
+
17
+ ### fileExists() {#fileexists}
18
+
19
+ > `static` **fileExists**(`filePath`): `boolean`
20
+
21
+ Does the file exist.
22
+
23
+ #### Parameters
24
+
25
+ ##### filePath
26
+
27
+ `string`
28
+
29
+ The file path.
30
+
31
+ #### Returns
32
+
33
+ `boolean`
34
+
35
+ True if the file exists.
36
+
37
+ ***
38
+
39
+ ### readFile() {#readfile}
40
+
41
+ > `static` **readFile**(`filePath`): `string`
42
+
43
+ Read the file.
44
+
45
+ #### Parameters
46
+
47
+ ##### filePath
48
+
49
+ `string`
50
+
51
+ The file path.
52
+
53
+ #### Returns
54
+
55
+ `string`
56
+
57
+ The file contents.
58
+
59
+ ***
60
+
61
+ ### resolvePath() {#resolvepath}
62
+
63
+ > `static` **resolvePath**(`filePath`): `string`
64
+
65
+ Resolve a path.
66
+
67
+ #### Parameters
68
+
69
+ ##### filePath
70
+
71
+ `string`
72
+
73
+ The file path.
74
+
75
+ #### Returns
76
+
77
+ `string`
78
+
79
+ The resolved path.
80
+
81
+ ***
82
+
83
+ ### getCurrentWorkingDirectory() {#getcurrentworkingdirectory}
84
+
85
+ > `static` **getCurrentWorkingDirectory**(): `string`
86
+
87
+ Get the current working directory.
88
+
89
+ #### Returns
90
+
91
+ `string`
92
+
93
+ The current working directory.
94
+
95
+ ***
96
+
97
+ ### normalizeFilePath() {#normalizefilepath}
98
+
99
+ > `static` **normalizeFilePath**(`filePath`): `string`
100
+
101
+ Normalize path separators for consistent comparisons.
102
+
103
+ #### Parameters
104
+
105
+ ##### filePath
106
+
107
+ `string`
108
+
109
+ The file path.
110
+
111
+ #### Returns
112
+
113
+ `string`
114
+
115
+ The normalized file path.
116
+
117
+ ***
118
+
119
+ ### getDirectoryPath() {#getdirectorypath}
120
+
121
+ > `static` **getDirectoryPath**(`filePath`): `string`
122
+
123
+ Get the directory portion of a file path.
124
+
125
+ #### Parameters
126
+
127
+ ##### filePath
128
+
129
+ `string`
130
+
131
+ The file path.
132
+
133
+ #### Returns
134
+
135
+ `string`
136
+
137
+ The directory path.
138
+
139
+ ***
140
+
141
+ ### resolveRelativePath() {#resolverelativepath}
142
+
143
+ > `static` **resolveRelativePath**(`baseDirectory`, `relativePath`): `string`
144
+
145
+ Resolve a relative path against a base directory.
146
+
147
+ #### Parameters
148
+
149
+ ##### baseDirectory
150
+
151
+ `string`
152
+
153
+ The base directory.
154
+
155
+ ##### relativePath
156
+
157
+ `string`
158
+
159
+ The relative path.
160
+
161
+ #### Returns
162
+
163
+ `string`
164
+
165
+ The resolved path.
166
+
167
+ ***
168
+
169
+ ### resolveImportSourceFilePath() {#resolveimportsourcefilepath}
170
+
171
+ > `static` **resolveImportSourceFilePath**(`sourceFilePath`, `importPath`): `string` \| `undefined`
172
+
173
+ Resolve a local import specifier to a TypeScript source file path.
174
+
175
+ #### Parameters
176
+
177
+ ##### sourceFilePath
178
+
179
+ `string`
180
+
181
+ The importing source file path.
182
+
183
+ ##### importPath
184
+
185
+ `string`
186
+
187
+ The import specifier.
188
+
189
+ #### Returns
190
+
191
+ `string` \| `undefined`
192
+
193
+ The resolved source file path.
194
+
195
+ ***
196
+
197
+ ### isGlobPattern() {#isglobpattern}
198
+
199
+ > `static` **isGlobPattern**(`sourceFileOrGlob`): `boolean`
200
+
201
+ Determine if the provided path includes glob pattern tokens.
202
+
203
+ #### Parameters
204
+
205
+ ##### sourceFileOrGlob
206
+
207
+ `string`
208
+
209
+ The direct source file path or glob pattern.
210
+
211
+ #### Returns
212
+
213
+ `boolean`
214
+
215
+ True if the value is a glob pattern.
216
+
217
+ ***
218
+
219
+ ### resolveSourceFiles() {#resolvesourcefiles}
220
+
221
+ > `static` **resolveSourceFiles**(`sourceFileOrGlob`): `string`[]
222
+
223
+ Resolve source files from a direct path or a glob pattern.
224
+
225
+ #### Parameters
226
+
227
+ ##### sourceFileOrGlob
228
+
229
+ `string`
230
+
231
+ The direct source file path or glob pattern.
232
+
233
+ #### Returns
234
+
235
+ `string`[]
236
+
237
+ The resolved source file paths.
@@ -0,0 +1,87 @@
1
+ # Class: ImportTypeQuerySchemaResolver
2
+
3
+ Static helpers for import type and type query schema resolution.
4
+
5
+ ## Constructors
6
+
7
+ ### Constructor
8
+
9
+ > **new ImportTypeQuerySchemaResolver**(): `ImportTypeQuerySchemaResolver`
10
+
11
+ #### Returns
12
+
13
+ `ImportTypeQuerySchemaResolver`
14
+
15
+ ## Methods
16
+
17
+ ### mapImportTypeNodeToSchema() {#mapimporttypenodetoschema}
18
+
19
+ > `static` **mapImportTypeNodeToSchema**(`context`, `typeNode`): `IJsonSchema` \| `undefined`
20
+
21
+ Map import type nodes (e.g. import("pkg").Type) to schema references.
22
+
23
+ #### Parameters
24
+
25
+ ##### context
26
+
27
+ [`ITypeScriptToSchemaContext`](../interfaces/ITypeScriptToSchemaContext.md)
28
+
29
+ ##### typeNode
30
+
31
+ `ImportTypeNode`
32
+
33
+ #### Returns
34
+
35
+ `IJsonSchema` \| `undefined`
36
+
37
+ ***
38
+
39
+ ### mapTypeQueryNodeToSchema() {#maptypequerynodetoschema}
40
+
41
+ > `static` **mapTypeQueryNodeToSchema**(`context`, `typeNode`): `IJsonSchema`
42
+
43
+ Map a type query node (typeof expr) to schema by resolving the referenced variable.
44
+
45
+ #### Parameters
46
+
47
+ ##### context
48
+
49
+ [`ITypeScriptToSchemaContext`](../interfaces/ITypeScriptToSchemaContext.md)
50
+
51
+ ##### typeNode
52
+
53
+ `TypeQueryNode`
54
+
55
+ #### Returns
56
+
57
+ `IJsonSchema`
58
+
59
+ ***
60
+
61
+ ### resolveImportTypeReferenceSchemaId() {#resolveimporttypereferenceschemaid}
62
+
63
+ > `static` **resolveImportTypeReferenceSchemaId**(`context`, `moduleSpecifier`, `typeName`, `title`): `string` \| `undefined`
64
+
65
+ Resolve import-type references to local or external schema ids.
66
+
67
+ #### Parameters
68
+
69
+ ##### context
70
+
71
+ [`ITypeScriptToSchemaContext`](../interfaces/ITypeScriptToSchemaContext.md)
72
+
73
+ ##### moduleSpecifier
74
+
75
+ `string`
76
+
77
+ ##### typeName
78
+
79
+ `string`
80
+
81
+ ##### title
82
+
83
+ `string`
84
+
85
+ #### Returns
86
+
87
+ `string` \| `undefined`
@@ -0,0 +1,69 @@
1
+ # Class: IndexSignaturePatternResolver
2
+
3
+ Resolves regex patterns for index signature key types.
4
+
5
+ ## Constructors
6
+
7
+ ### Constructor
8
+
9
+ > **new IndexSignaturePatternResolver**(): `IndexSignaturePatternResolver`
10
+
11
+ #### Returns
12
+
13
+ `IndexSignaturePatternResolver`
14
+
15
+ ## Methods
16
+
17
+ ### isSupportedIndexSignature() {#issupportedindexsignature}
18
+
19
+ > `static` **isSupportedIndexSignature**(`member`): `boolean`
20
+
21
+ Determine whether an index signature can be represented as JSON object additionalProperties.
22
+
23
+ #### Parameters
24
+
25
+ ##### member
26
+
27
+ `IndexSignatureDeclaration`
28
+
29
+ The index signature declaration.
30
+
31
+ #### Returns
32
+
33
+ `boolean`
34
+
35
+ True if supported.
36
+
37
+ ***
38
+
39
+ ### extractIndexSignaturePattern() {#extractindexsignaturepattern}
40
+
41
+ > `static` **extractIndexSignaturePattern**(`context`, `member`, `getTypeParameterBinding`): `string` \| `undefined`
42
+
43
+ Extract a regex pattern for an index signature key type when representable.
44
+
45
+ #### Parameters
46
+
47
+ ##### context
48
+
49
+ [`ITypeScriptToSchemaContext`](../interfaces/ITypeScriptToSchemaContext.md)
50
+
51
+ The generation context.
52
+
53
+ ##### member
54
+
55
+ `IndexSignatureDeclaration`
56
+
57
+ The index signature declaration.
58
+
59
+ ##### getTypeParameterBinding
60
+
61
+ (`context`, `typeName`) => `TypeNode` \| `null` \| `undefined`
62
+
63
+ Callback for resolving generic bindings.
64
+
65
+ #### Returns
66
+
67
+ `string` \| `undefined`
68
+
69
+ The property-name pattern, if derivable.
@@ -0,0 +1,48 @@
1
+ # Class: IntersectionSchemaMerger
2
+
3
+ Merges compatible object intersections into a single JSON schema object.
4
+
5
+ ## Constructors
6
+
7
+ ### Constructor
8
+
9
+ > **new IntersectionSchemaMerger**(): `IntersectionSchemaMerger`
10
+
11
+ #### Returns
12
+
13
+ `IntersectionSchemaMerger`
14
+
15
+ ## Methods
16
+
17
+ ### mergeIntersectionObjectSchemas() {#mergeintersectionobjectschemas}
18
+
19
+ > `static` **mergeIntersectionObjectSchemas**(`context`, `schemas`, `toInlineUtilityObjectSchema`): `IJsonSchema` \| `undefined`
20
+
21
+ Merge simple object intersection parts into a single object schema.
22
+ Supports local/known object refs by expanding them before merge.
23
+
24
+ #### Parameters
25
+
26
+ ##### context
27
+
28
+ [`ITypeScriptToSchemaContext`](../interfaces/ITypeScriptToSchemaContext.md)
29
+
30
+ The generation context.
31
+
32
+ ##### schemas
33
+
34
+ `IJsonSchema`[]
35
+
36
+ The mapped intersection schemas.
37
+
38
+ ##### toInlineUtilityObjectSchema
39
+
40
+ (`schema`) => `IJsonSchema`
41
+
42
+ Callback for converting referenced schemas to inline forms.
43
+
44
+ #### Returns
45
+
46
+ `IJsonSchema` \| `undefined`
47
+
48
+ The merged schema, or undefined when merge is not safe.