@twin.org/tools-core 0.0.3-next.9 → 0.0.4-next.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.
- package/README.md +2 -2
- package/dist/es/index.js +21 -11
- package/dist/es/index.js.map +1 -1
- package/dist/es/models/ITypeScriptToSchemaContext.js +2 -0
- package/dist/es/models/ITypeScriptToSchemaContext.js.map +1 -0
- package/dist/es/models/ITypeScriptToSchemaDiagnostics.js +4 -0
- package/dist/es/models/ITypeScriptToSchemaDiagnostics.js.map +1 -0
- package/dist/es/models/ITypeScriptToSchemaOptions.js +4 -0
- package/dist/es/models/ITypeScriptToSchemaOptions.js.map +1 -0
- package/dist/es/models/embeddedSchemaMode.js +17 -0
- package/dist/es/models/embeddedSchemaMode.js.map +1 -0
- package/dist/es/utils/constants.js +43 -0
- package/dist/es/utils/constants.js.map +1 -0
- package/dist/es/utils/diagnosticReporter.js +32 -0
- package/dist/es/utils/diagnosticReporter.js.map +1 -0
- package/dist/es/utils/disallowedTypeGuard.js +151 -0
- package/dist/es/utils/disallowedTypeGuard.js.map +1 -0
- package/dist/es/utils/enum.js +152 -0
- package/dist/es/utils/enum.js.map +1 -0
- package/dist/es/utils/fileUtils.js +132 -0
- package/dist/es/utils/fileUtils.js.map +1 -0
- package/dist/es/utils/importTypeQuerySchemaResolver.js +363 -0
- package/dist/es/utils/importTypeQuerySchemaResolver.js.map +1 -0
- package/dist/es/utils/indexSignaturePatternResolver.js +94 -0
- package/dist/es/utils/indexSignaturePatternResolver.js.map +1 -0
- package/dist/es/utils/intersectionSchemaMerger.js +85 -0
- package/dist/es/utils/intersectionSchemaMerger.js.map +1 -0
- package/dist/es/utils/jsDoc.js +138 -0
- package/dist/es/utils/jsDoc.js.map +1 -0
- package/dist/es/utils/jsonSchemaBuilder.js +3416 -0
- package/dist/es/utils/jsonSchemaBuilder.js.map +1 -0
- package/dist/es/utils/mappedTypeSchemaResolver.js +265 -0
- package/dist/es/utils/mappedTypeSchemaResolver.js.map +1 -0
- package/dist/es/utils/objectTransformer.js +161 -0
- package/dist/es/utils/objectTransformer.js.map +1 -0
- package/dist/es/utils/regEx.js +128 -0
- package/dist/es/utils/regEx.js.map +1 -0
- package/dist/es/utils/resolver.js +177 -0
- package/dist/es/utils/resolver.js.map +1 -0
- package/dist/es/utils/templateLiteralPatternBuilder.js +94 -0
- package/dist/es/utils/templateLiteralPatternBuilder.js.map +1 -0
- package/dist/es/utils/typeScriptToSchema.js +319 -0
- package/dist/es/utils/typeScriptToSchema.js.map +1 -0
- package/dist/es/utils/utilityTypeSchemaMapper.js +475 -0
- package/dist/es/utils/utilityTypeSchemaMapper.js.map +1 -0
- package/dist/types/index.d.ts +21 -11
- package/dist/types/models/ITypeScriptToSchemaContext.d.ts +71 -0
- package/dist/types/models/ITypeScriptToSchemaDiagnostics.d.ts +31 -0
- package/dist/types/models/ITypeScriptToSchemaOptions.d.ts +22 -0
- package/dist/types/models/embeddedSchemaMode.d.ts +17 -0
- package/dist/types/utils/constants.d.ts +13 -0
- package/dist/types/utils/diagnosticReporter.d.ts +17 -0
- package/dist/types/utils/disallowedTypeGuard.d.ts +16 -0
- package/dist/types/utils/enum.d.ts +42 -0
- package/dist/types/utils/fileUtils.d.ts +66 -0
- package/dist/types/utils/importTypeQuerySchemaResolver.d.ts +87 -0
- package/dist/types/utils/indexSignaturePatternResolver.d.ts +21 -0
- package/dist/types/utils/intersectionSchemaMerger.d.ts +16 -0
- package/dist/types/utils/jsDoc.d.ts +53 -0
- package/dist/types/utils/jsonSchemaBuilder.d.ts +671 -0
- package/dist/types/utils/mappedTypeSchemaResolver.d.ts +81 -0
- package/dist/types/utils/objectTransformer.d.ts +33 -0
- package/dist/types/utils/regEx.d.ts +24 -0
- package/dist/types/utils/resolver.d.ts +22 -0
- package/dist/types/utils/templateLiteralPatternBuilder.d.ts +12 -0
- package/dist/types/utils/typeScriptToSchema.d.ts +92 -0
- package/dist/types/utils/utilityTypeSchemaMapper.d.ts +141 -0
- package/docs/changelog.md +383 -40
- package/docs/examples.md +87 -1
- package/docs/reference/classes/Constants.md +29 -0
- package/docs/reference/classes/DiagnosticReporter.md +49 -0
- package/docs/reference/classes/DisallowedTypeGuard.md +35 -0
- package/docs/reference/classes/Enum.md +93 -0
- package/docs/reference/classes/FileUtils.md +237 -0
- package/docs/reference/classes/ImportTypeQuerySchemaResolver.md +109 -0
- package/docs/reference/classes/IndexSignaturePatternResolver.md +69 -0
- package/docs/reference/classes/IntersectionSchemaMerger.md +48 -0
- package/docs/reference/classes/JsDoc.md +169 -0
- package/docs/reference/classes/JsonSchemaBuilder.md +2578 -0
- package/docs/reference/classes/MappedTypeSchemaResolver.md +275 -0
- package/docs/reference/classes/ObjectTransformer.md +119 -0
- package/docs/reference/classes/RegEx.md +99 -0
- package/docs/reference/classes/Resolver.md +52 -0
- package/docs/reference/classes/TemplateLiteralPatternBuilder.md +35 -0
- package/docs/reference/classes/TypeScriptToSchema.md +91 -0
- package/docs/reference/classes/UtilityTypeSchemaMapper.md +343 -0
- package/docs/reference/index.md +25 -11
- package/docs/reference/interfaces/ITypeScriptToSchemaContext.md +125 -0
- package/docs/reference/interfaces/ITypeScriptToSchemaDiagnostics.md +55 -0
- package/docs/reference/interfaces/ITypeScriptToSchemaOptions.md +44 -0
- package/docs/reference/type-aliases/EmbeddedSchemaMode.md +5 -0
- package/docs/reference/variables/EmbeddedSchemaMode.md +19 -0
- package/locales/en.json +32 -1
- package/package.json +6 -5
- package/dist/es/models/IJsonSchema.js +0 -2
- package/dist/es/models/IJsonSchema.js.map +0 -1
- package/dist/es/models/IOpenApi.js +0 -2
- package/dist/es/models/IOpenApi.js.map +0 -1
- package/dist/es/models/IOpenApiExample.js +0 -4
- package/dist/es/models/IOpenApiExample.js.map +0 -1
- package/dist/es/models/IOpenApiHeader.js +0 -4
- package/dist/es/models/IOpenApiHeader.js.map +0 -1
- package/dist/es/models/IOpenApiPathMethod.js +0 -2
- package/dist/es/models/IOpenApiPathMethod.js.map +0 -1
- package/dist/es/models/IOpenApiResponse.js +0 -2
- package/dist/es/models/IOpenApiResponse.js.map +0 -1
- package/dist/es/models/IOpenApiSecurityScheme.js +0 -4
- package/dist/es/models/IOpenApiSecurityScheme.js.map +0 -1
- package/dist/es/models/IPackageJson.js +0 -4
- package/dist/es/models/IPackageJson.js.map +0 -1
- package/dist/es/models/jsonTypeName.js +0 -2
- package/dist/es/models/jsonTypeName.js.map +0 -1
- package/dist/es/utils/jsonSchemaHelper.js +0 -258
- package/dist/es/utils/jsonSchemaHelper.js.map +0 -1
- package/dist/es/utils/openApiHelper.js +0 -12
- package/dist/es/utils/openApiHelper.js.map +0 -1
- package/dist/types/models/IJsonSchema.d.ts +0 -5
- package/dist/types/models/IOpenApi.d.ts +0 -54
- package/dist/types/models/IOpenApiExample.d.ts +0 -13
- package/dist/types/models/IOpenApiHeader.d.ts +0 -19
- package/dist/types/models/IOpenApiPathMethod.d.ts +0 -65
- package/dist/types/models/IOpenApiResponse.d.ts +0 -32
- package/dist/types/models/IOpenApiSecurityScheme.d.ts +0 -25
- package/dist/types/models/IPackageJson.d.ts +0 -15
- package/dist/types/models/jsonTypeName.d.ts +0 -5
- package/dist/types/utils/jsonSchemaHelper.d.ts +0 -78
- package/dist/types/utils/openApiHelper.d.ts +0 -9
- package/docs/reference/classes/JsonSchemaHelper.md +0 -233
- package/docs/reference/classes/OpenApiHelper.md +0 -21
- package/docs/reference/interfaces/IOpenApi.md +0 -103
- package/docs/reference/interfaces/IOpenApiExample.md +0 -19
- package/docs/reference/interfaces/IOpenApiHeader.md +0 -31
- package/docs/reference/interfaces/IOpenApiPathMethod.md +0 -119
- package/docs/reference/interfaces/IOpenApiResponse.md +0 -35
- package/docs/reference/interfaces/IOpenApiSecurityScheme.md +0 -43
- package/docs/reference/interfaces/IPackageJson.md +0 -23
- package/docs/reference/type-aliases/IJsonSchema.md +0 -5
- package/docs/reference/type-aliases/JsonTypeName.md +0 -5
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
# Class: UtilityTypeSchemaMapper
|
|
2
|
+
|
|
3
|
+
Static utility-type schema mapping helpers.
|
|
4
|
+
|
|
5
|
+
## Constructors
|
|
6
|
+
|
|
7
|
+
### Constructor
|
|
8
|
+
|
|
9
|
+
> **new UtilityTypeSchemaMapper**(): `UtilityTypeSchemaMapper`
|
|
10
|
+
|
|
11
|
+
#### Returns
|
|
12
|
+
|
|
13
|
+
`UtilityTypeSchemaMapper`
|
|
14
|
+
|
|
15
|
+
## Methods
|
|
16
|
+
|
|
17
|
+
### mapPartialUtilityType() {#mappartialutilitytype}
|
|
18
|
+
|
|
19
|
+
> `static` **mapPartialUtilityType**(`context`, `typeNode`): `IJsonSchema` \| `undefined`
|
|
20
|
+
|
|
21
|
+
Map `Partial<T>` to an object schema with no required properties.
|
|
22
|
+
|
|
23
|
+
#### Parameters
|
|
24
|
+
|
|
25
|
+
##### context
|
|
26
|
+
|
|
27
|
+
[`ITypeScriptToSchemaContext`](../interfaces/ITypeScriptToSchemaContext.md)
|
|
28
|
+
|
|
29
|
+
The generation context.
|
|
30
|
+
|
|
31
|
+
##### typeNode
|
|
32
|
+
|
|
33
|
+
`TypeReferenceNode`
|
|
34
|
+
|
|
35
|
+
The `Partial` type reference.
|
|
36
|
+
|
|
37
|
+
#### Returns
|
|
38
|
+
|
|
39
|
+
`IJsonSchema` \| `undefined`
|
|
40
|
+
|
|
41
|
+
The mapped schema.
|
|
42
|
+
|
|
43
|
+
***
|
|
44
|
+
|
|
45
|
+
### mapRequiredUtilityType() {#maprequiredutilitytype}
|
|
46
|
+
|
|
47
|
+
> `static` **mapRequiredUtilityType**(`context`, `typeNode`): `IJsonSchema` \| `undefined`
|
|
48
|
+
|
|
49
|
+
Map `Required<T>` to an object schema with all properties required.
|
|
50
|
+
|
|
51
|
+
#### Parameters
|
|
52
|
+
|
|
53
|
+
##### context
|
|
54
|
+
|
|
55
|
+
[`ITypeScriptToSchemaContext`](../interfaces/ITypeScriptToSchemaContext.md)
|
|
56
|
+
|
|
57
|
+
The generation context.
|
|
58
|
+
|
|
59
|
+
##### typeNode
|
|
60
|
+
|
|
61
|
+
`TypeReferenceNode`
|
|
62
|
+
|
|
63
|
+
The `Required` type reference.
|
|
64
|
+
|
|
65
|
+
#### Returns
|
|
66
|
+
|
|
67
|
+
`IJsonSchema` \| `undefined`
|
|
68
|
+
|
|
69
|
+
The mapped schema.
|
|
70
|
+
|
|
71
|
+
***
|
|
72
|
+
|
|
73
|
+
### mapPickUtilityType() {#mappickutilitytype}
|
|
74
|
+
|
|
75
|
+
> `static` **mapPickUtilityType**(`context`, `typeNode`): `IJsonSchema` \| `undefined`
|
|
76
|
+
|
|
77
|
+
Map `Pick<T, K>` to an object schema with selected keys preserved.
|
|
78
|
+
|
|
79
|
+
#### Parameters
|
|
80
|
+
|
|
81
|
+
##### context
|
|
82
|
+
|
|
83
|
+
[`ITypeScriptToSchemaContext`](../interfaces/ITypeScriptToSchemaContext.md)
|
|
84
|
+
|
|
85
|
+
The generation context.
|
|
86
|
+
|
|
87
|
+
##### typeNode
|
|
88
|
+
|
|
89
|
+
`TypeReferenceNode`
|
|
90
|
+
|
|
91
|
+
The Pick type reference.
|
|
92
|
+
|
|
93
|
+
#### Returns
|
|
94
|
+
|
|
95
|
+
`IJsonSchema` \| `undefined`
|
|
96
|
+
|
|
97
|
+
The mapped schema.
|
|
98
|
+
|
|
99
|
+
***
|
|
100
|
+
|
|
101
|
+
### mapOmitUtilityType() {#mapomitutilitytype}
|
|
102
|
+
|
|
103
|
+
> `static` **mapOmitUtilityType**(`context`, `typeNode`): `IJsonSchema` \| `undefined`
|
|
104
|
+
|
|
105
|
+
Map `Omit<T, K>` to an object schema with selected keys removed.
|
|
106
|
+
|
|
107
|
+
#### Parameters
|
|
108
|
+
|
|
109
|
+
##### context
|
|
110
|
+
|
|
111
|
+
[`ITypeScriptToSchemaContext`](../interfaces/ITypeScriptToSchemaContext.md)
|
|
112
|
+
|
|
113
|
+
The generation context.
|
|
114
|
+
|
|
115
|
+
##### typeNode
|
|
116
|
+
|
|
117
|
+
`TypeReferenceNode`
|
|
118
|
+
|
|
119
|
+
The `Omit` type reference.
|
|
120
|
+
|
|
121
|
+
#### Returns
|
|
122
|
+
|
|
123
|
+
`IJsonSchema` \| `undefined`
|
|
124
|
+
|
|
125
|
+
The mapped schema.
|
|
126
|
+
|
|
127
|
+
***
|
|
128
|
+
|
|
129
|
+
### mapExcludeUtilityType() {#mapexcludeutilitytype}
|
|
130
|
+
|
|
131
|
+
> `static` **mapExcludeUtilityType**(`context`, `typeNode`): `IJsonSchema` \| `undefined`
|
|
132
|
+
|
|
133
|
+
Map `Exclude<T, U>` to a schema that removes `U` members from `T`.
|
|
134
|
+
|
|
135
|
+
#### Parameters
|
|
136
|
+
|
|
137
|
+
##### context
|
|
138
|
+
|
|
139
|
+
[`ITypeScriptToSchemaContext`](../interfaces/ITypeScriptToSchemaContext.md)
|
|
140
|
+
|
|
141
|
+
The generation context.
|
|
142
|
+
|
|
143
|
+
##### typeNode
|
|
144
|
+
|
|
145
|
+
`TypeReferenceNode`
|
|
146
|
+
|
|
147
|
+
The `Exclude` type reference.
|
|
148
|
+
|
|
149
|
+
#### Returns
|
|
150
|
+
|
|
151
|
+
`IJsonSchema` \| `undefined`
|
|
152
|
+
|
|
153
|
+
The mapped schema.
|
|
154
|
+
|
|
155
|
+
***
|
|
156
|
+
|
|
157
|
+
### mapExtractUtilityType() {#mapextractutilitytype}
|
|
158
|
+
|
|
159
|
+
> `static` **mapExtractUtilityType**(`context`, `typeNode`): `IJsonSchema` \| `undefined`
|
|
160
|
+
|
|
161
|
+
Map `Extract<T, U>` to a schema that keeps `U` members from `T`.
|
|
162
|
+
|
|
163
|
+
#### Parameters
|
|
164
|
+
|
|
165
|
+
##### context
|
|
166
|
+
|
|
167
|
+
[`ITypeScriptToSchemaContext`](../interfaces/ITypeScriptToSchemaContext.md)
|
|
168
|
+
|
|
169
|
+
The generation context.
|
|
170
|
+
|
|
171
|
+
##### typeNode
|
|
172
|
+
|
|
173
|
+
`TypeReferenceNode`
|
|
174
|
+
|
|
175
|
+
The `Extract` type reference.
|
|
176
|
+
|
|
177
|
+
#### Returns
|
|
178
|
+
|
|
179
|
+
`IJsonSchema` \| `undefined`
|
|
180
|
+
|
|
181
|
+
The mapped schema.
|
|
182
|
+
|
|
183
|
+
***
|
|
184
|
+
|
|
185
|
+
### mapNonNullableUtilityType() {#mapnonnullableutilitytype}
|
|
186
|
+
|
|
187
|
+
> `static` **mapNonNullableUtilityType**(`context`, `typeNode`): `IJsonSchema` \| `undefined`
|
|
188
|
+
|
|
189
|
+
Map `NonNullable<T>` by removing `null` and `undefined` branches from `T`.
|
|
190
|
+
|
|
191
|
+
#### Parameters
|
|
192
|
+
|
|
193
|
+
##### context
|
|
194
|
+
|
|
195
|
+
[`ITypeScriptToSchemaContext`](../interfaces/ITypeScriptToSchemaContext.md)
|
|
196
|
+
|
|
197
|
+
The generation context.
|
|
198
|
+
|
|
199
|
+
##### typeNode
|
|
200
|
+
|
|
201
|
+
`TypeReferenceNode`
|
|
202
|
+
|
|
203
|
+
The `NonNullable` type reference.
|
|
204
|
+
|
|
205
|
+
#### Returns
|
|
206
|
+
|
|
207
|
+
`IJsonSchema` \| `undefined`
|
|
208
|
+
|
|
209
|
+
The mapped schema.
|
|
210
|
+
|
|
211
|
+
***
|
|
212
|
+
|
|
213
|
+
### mapRecordUtilityType() {#maprecordutilitytype}
|
|
214
|
+
|
|
215
|
+
> `static` **mapRecordUtilityType**(`context`, `typeNode`): `IJsonSchema` \| `undefined`
|
|
216
|
+
|
|
217
|
+
Map `Record<K, V>` to an object schema with key constraints where possible.
|
|
218
|
+
|
|
219
|
+
#### Parameters
|
|
220
|
+
|
|
221
|
+
##### context
|
|
222
|
+
|
|
223
|
+
[`ITypeScriptToSchemaContext`](../interfaces/ITypeScriptToSchemaContext.md)
|
|
224
|
+
|
|
225
|
+
The generation context.
|
|
226
|
+
|
|
227
|
+
##### typeNode
|
|
228
|
+
|
|
229
|
+
`TypeReferenceNode`
|
|
230
|
+
|
|
231
|
+
The `Record` type reference.
|
|
232
|
+
|
|
233
|
+
#### Returns
|
|
234
|
+
|
|
235
|
+
`IJsonSchema` \| `undefined`
|
|
236
|
+
|
|
237
|
+
The mapped schema.
|
|
238
|
+
|
|
239
|
+
***
|
|
240
|
+
|
|
241
|
+
### mapJsonLdObjectUtilityType() {#mapjsonldobjectutilitytype}
|
|
242
|
+
|
|
243
|
+
> `static` **mapJsonLdObjectUtilityType**(`context`, `typeNode`, `options`): `IJsonSchema` \| `undefined`
|
|
244
|
+
|
|
245
|
+
Map `JsonLdObject` utility types using key-removal and optional key-addition rules.
|
|
246
|
+
|
|
247
|
+
#### Parameters
|
|
248
|
+
|
|
249
|
+
##### context
|
|
250
|
+
|
|
251
|
+
[`ITypeScriptToSchemaContext`](../interfaces/ITypeScriptToSchemaContext.md)
|
|
252
|
+
|
|
253
|
+
The generation context.
|
|
254
|
+
|
|
255
|
+
##### typeNode
|
|
256
|
+
|
|
257
|
+
`TypeReferenceNode`
|
|
258
|
+
|
|
259
|
+
The `JsonLdObject` utility type reference.
|
|
260
|
+
|
|
261
|
+
##### options
|
|
262
|
+
|
|
263
|
+
The mapping options for key removal and optional key addition.
|
|
264
|
+
|
|
265
|
+
###### keysToRemove
|
|
266
|
+
|
|
267
|
+
`string`[]
|
|
268
|
+
|
|
269
|
+
The property keys to remove from the base schema.
|
|
270
|
+
|
|
271
|
+
###### keyToAdd?
|
|
272
|
+
|
|
273
|
+
`"type"` \| `"id"` \| `"@id"` \| `"@type"` \| `"@context"`
|
|
274
|
+
|
|
275
|
+
The optional key to add after removal.
|
|
276
|
+
|
|
277
|
+
###### isAddedKeyRequired?
|
|
278
|
+
|
|
279
|
+
`boolean`
|
|
280
|
+
|
|
281
|
+
True when the added key must be required.
|
|
282
|
+
|
|
283
|
+
#### Returns
|
|
284
|
+
|
|
285
|
+
`IJsonSchema` \| `undefined`
|
|
286
|
+
|
|
287
|
+
The mapped schema.
|
|
288
|
+
|
|
289
|
+
***
|
|
290
|
+
|
|
291
|
+
### mapObjectOrArrayUtilityType() {#mapobjectorarrayutilitytype}
|
|
292
|
+
|
|
293
|
+
> `static` **mapObjectOrArrayUtilityType**(`context`, `typeNode`): `IJsonSchema` \| `undefined`
|
|
294
|
+
|
|
295
|
+
Map `ObjectOrArray<T>` to a schema accepting `T` or `T[]`.
|
|
296
|
+
|
|
297
|
+
#### Parameters
|
|
298
|
+
|
|
299
|
+
##### context
|
|
300
|
+
|
|
301
|
+
[`ITypeScriptToSchemaContext`](../interfaces/ITypeScriptToSchemaContext.md)
|
|
302
|
+
|
|
303
|
+
The generation context.
|
|
304
|
+
|
|
305
|
+
##### typeNode
|
|
306
|
+
|
|
307
|
+
`TypeReferenceNode`
|
|
308
|
+
|
|
309
|
+
The `ObjectOrArray` type reference.
|
|
310
|
+
|
|
311
|
+
#### Returns
|
|
312
|
+
|
|
313
|
+
`IJsonSchema` \| `undefined`
|
|
314
|
+
|
|
315
|
+
The mapped schema.
|
|
316
|
+
|
|
317
|
+
***
|
|
318
|
+
|
|
319
|
+
### mapSingleOccurrenceArrayUtilityType() {#mapsingleoccurrencearrayutilitytype}
|
|
320
|
+
|
|
321
|
+
> `static` **mapSingleOccurrenceArrayUtilityType**(`context`, `typeNode`): `IJsonSchema` \| `undefined`
|
|
322
|
+
|
|
323
|
+
Map `SingleOccurrenceArray<T, U>` to a non-empty array containing exactly one `U`.
|
|
324
|
+
|
|
325
|
+
#### Parameters
|
|
326
|
+
|
|
327
|
+
##### context
|
|
328
|
+
|
|
329
|
+
[`ITypeScriptToSchemaContext`](../interfaces/ITypeScriptToSchemaContext.md)
|
|
330
|
+
|
|
331
|
+
The generation context.
|
|
332
|
+
|
|
333
|
+
##### typeNode
|
|
334
|
+
|
|
335
|
+
`TypeReferenceNode`
|
|
336
|
+
|
|
337
|
+
The `SingleOccurrenceArray` type reference.
|
|
338
|
+
|
|
339
|
+
#### Returns
|
|
340
|
+
|
|
341
|
+
`IJsonSchema` \| `undefined`
|
|
342
|
+
|
|
343
|
+
The mapped schema.
|
package/docs/reference/index.md
CHANGED
|
@@ -2,20 +2,34 @@
|
|
|
2
2
|
|
|
3
3
|
## Classes
|
|
4
4
|
|
|
5
|
-
- [
|
|
6
|
-
- [
|
|
5
|
+
- [Constants](classes/Constants.md)
|
|
6
|
+
- [DiagnosticReporter](classes/DiagnosticReporter.md)
|
|
7
|
+
- [DisallowedTypeGuard](classes/DisallowedTypeGuard.md)
|
|
8
|
+
- [Enum](classes/Enum.md)
|
|
9
|
+
- [FileUtils](classes/FileUtils.md)
|
|
10
|
+
- [ImportTypeQuerySchemaResolver](classes/ImportTypeQuerySchemaResolver.md)
|
|
11
|
+
- [IndexSignaturePatternResolver](classes/IndexSignaturePatternResolver.md)
|
|
12
|
+
- [IntersectionSchemaMerger](classes/IntersectionSchemaMerger.md)
|
|
13
|
+
- [JsDoc](classes/JsDoc.md)
|
|
14
|
+
- [JsonSchemaBuilder](classes/JsonSchemaBuilder.md)
|
|
15
|
+
- [MappedTypeSchemaResolver](classes/MappedTypeSchemaResolver.md)
|
|
16
|
+
- [ObjectTransformer](classes/ObjectTransformer.md)
|
|
17
|
+
- [RegEx](classes/RegEx.md)
|
|
18
|
+
- [Resolver](classes/Resolver.md)
|
|
19
|
+
- [TemplateLiteralPatternBuilder](classes/TemplateLiteralPatternBuilder.md)
|
|
20
|
+
- [TypeScriptToSchema](classes/TypeScriptToSchema.md)
|
|
21
|
+
- [UtilityTypeSchemaMapper](classes/UtilityTypeSchemaMapper.md)
|
|
7
22
|
|
|
8
23
|
## Interfaces
|
|
9
24
|
|
|
10
|
-
- [
|
|
11
|
-
- [
|
|
12
|
-
- [
|
|
13
|
-
- [IOpenApiPathMethod](interfaces/IOpenApiPathMethod.md)
|
|
14
|
-
- [IOpenApiResponse](interfaces/IOpenApiResponse.md)
|
|
15
|
-
- [IOpenApiSecurityScheme](interfaces/IOpenApiSecurityScheme.md)
|
|
16
|
-
- [IPackageJson](interfaces/IPackageJson.md)
|
|
25
|
+
- [ITypeScriptToSchemaContext](interfaces/ITypeScriptToSchemaContext.md)
|
|
26
|
+
- [ITypeScriptToSchemaDiagnostics](interfaces/ITypeScriptToSchemaDiagnostics.md)
|
|
27
|
+
- [ITypeScriptToSchemaOptions](interfaces/ITypeScriptToSchemaOptions.md)
|
|
17
28
|
|
|
18
29
|
## Type Aliases
|
|
19
30
|
|
|
20
|
-
- [
|
|
21
|
-
|
|
31
|
+
- [EmbeddedSchemaMode](type-aliases/EmbeddedSchemaMode.md)
|
|
32
|
+
|
|
33
|
+
## Variables
|
|
34
|
+
|
|
35
|
+
- [EmbeddedSchemaMode](variables/EmbeddedSchemaMode.md)
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
# Interface: ITypeScriptToSchemaContext
|
|
2
|
+
|
|
3
|
+
Context for TypeScript to JSON schema generation.
|
|
4
|
+
|
|
5
|
+
## Properties
|
|
6
|
+
|
|
7
|
+
### namespace {#namespace}
|
|
8
|
+
|
|
9
|
+
> **namespace**: `string`
|
|
10
|
+
|
|
11
|
+
The namespace for generated schema ids.
|
|
12
|
+
|
|
13
|
+
***
|
|
14
|
+
|
|
15
|
+
### packageName {#packagename}
|
|
16
|
+
|
|
17
|
+
> **packageName**: `string`
|
|
18
|
+
|
|
19
|
+
The package name for generated schema ids.
|
|
20
|
+
|
|
21
|
+
***
|
|
22
|
+
|
|
23
|
+
### schemas {#schemas}
|
|
24
|
+
|
|
25
|
+
> **schemas**: `object`
|
|
26
|
+
|
|
27
|
+
The schema cache indexed by package and title.
|
|
28
|
+
|
|
29
|
+
#### Index Signature
|
|
30
|
+
|
|
31
|
+
\[`id`: `string`\]: `object`
|
|
32
|
+
|
|
33
|
+
***
|
|
34
|
+
|
|
35
|
+
### activeSourceFile? {#activesourcefile}
|
|
36
|
+
|
|
37
|
+
> `optional` **activeSourceFile?**: `SourceFile`
|
|
38
|
+
|
|
39
|
+
The currently active source file being mapped.
|
|
40
|
+
|
|
41
|
+
***
|
|
42
|
+
|
|
43
|
+
### activeEnclosingObjectName? {#activeenclosingobjectname}
|
|
44
|
+
|
|
45
|
+
> `optional` **activeEnclosingObjectName?**: `string`
|
|
46
|
+
|
|
47
|
+
The currently active enclosing object (interface/type) being mapped.
|
|
48
|
+
|
|
49
|
+
***
|
|
50
|
+
|
|
51
|
+
### activeDisallowedType? {#activedisallowedtype}
|
|
52
|
+
|
|
53
|
+
> `optional` **activeDisallowedType?**: `object`
|
|
54
|
+
|
|
55
|
+
The first disallowed type encountered while mapping the active enclosing object.
|
|
56
|
+
|
|
57
|
+
#### disallowedTypeName
|
|
58
|
+
|
|
59
|
+
> **disallowedTypeName**: `string`
|
|
60
|
+
|
|
61
|
+
#### propertyName
|
|
62
|
+
|
|
63
|
+
> **propertyName**: `string`
|
|
64
|
+
|
|
65
|
+
#### enclosingObjectName
|
|
66
|
+
|
|
67
|
+
> **enclosingObjectName**: `string`
|
|
68
|
+
|
|
69
|
+
***
|
|
70
|
+
|
|
71
|
+
### resolvingTypeNames? {#resolvingtypenames}
|
|
72
|
+
|
|
73
|
+
> `optional` **resolvingTypeNames?**: `Set`\<`string`\>
|
|
74
|
+
|
|
75
|
+
Type names currently being resolved to avoid recursive local-type expansion loops.
|
|
76
|
+
|
|
77
|
+
***
|
|
78
|
+
|
|
79
|
+
### resolvingUtilityTypes? {#resolvingutilitytypes}
|
|
80
|
+
|
|
81
|
+
> `optional` **resolvingUtilityTypes?**: `Set`\<`string`\>
|
|
82
|
+
|
|
83
|
+
Utility type names currently being processed to avoid infinite recursion cycles
|
|
84
|
+
when encountering complex combinations of indexed access types, keyof, and utility types.
|
|
85
|
+
|
|
86
|
+
***
|
|
87
|
+
|
|
88
|
+
### resolvingImportedObjectSchemas? {#resolvingimportedobjectschemas}
|
|
89
|
+
|
|
90
|
+
> `optional` **resolvingImportedObjectSchemas?**: `Set`\<`string`\>
|
|
91
|
+
|
|
92
|
+
Imported utility base schemas currently being resolved to avoid recursive re-entry
|
|
93
|
+
while parsing module graphs for utility type application.
|
|
94
|
+
|
|
95
|
+
***
|
|
96
|
+
|
|
97
|
+
### typeParameterBindings? {#typeparameterbindings}
|
|
98
|
+
|
|
99
|
+
> `optional` **typeParameterBindings?**: `object`
|
|
100
|
+
|
|
101
|
+
Generic type parameter bindings active for the current mapping scope.
|
|
102
|
+
|
|
103
|
+
#### Index Signature
|
|
104
|
+
|
|
105
|
+
\[`id`: `string`\]: `TypeNode` \| `null`
|
|
106
|
+
|
|
107
|
+
***
|
|
108
|
+
|
|
109
|
+
### embeddedSchemaModes? {#embeddedschemamodes}
|
|
110
|
+
|
|
111
|
+
> `optional` **embeddedSchemaModes?**: `object`
|
|
112
|
+
|
|
113
|
+
Schema ids marked with
|
|
114
|
+
|
|
115
|
+
#### Index Signature
|
|
116
|
+
|
|
117
|
+
\[`id`: `string`\]: [`EmbeddedSchemaMode`](../type-aliases/EmbeddedSchemaMode.md)
|
|
118
|
+
|
|
119
|
+
***
|
|
120
|
+
|
|
121
|
+
### options? {#options}
|
|
122
|
+
|
|
123
|
+
> `optional` **options?**: [`ITypeScriptToSchemaOptions`](ITypeScriptToSchemaOptions.md)
|
|
124
|
+
|
|
125
|
+
Optional schema generation options.
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# Interface: ITypeScriptToSchemaDiagnostics
|
|
2
|
+
|
|
3
|
+
Diagnostic payload for non-fatal schema generation issues.
|
|
4
|
+
|
|
5
|
+
## Properties
|
|
6
|
+
|
|
7
|
+
### code {#code}
|
|
8
|
+
|
|
9
|
+
> **code**: `string`
|
|
10
|
+
|
|
11
|
+
Stable diagnostic code identifying the issue type.
|
|
12
|
+
|
|
13
|
+
***
|
|
14
|
+
|
|
15
|
+
### properties? {#properties}
|
|
16
|
+
|
|
17
|
+
> `optional` **properties?**: `object`
|
|
18
|
+
|
|
19
|
+
Additional structured metadata related to the diagnostic.
|
|
20
|
+
|
|
21
|
+
#### Index Signature
|
|
22
|
+
|
|
23
|
+
\[`key`: `string`\]: `unknown`
|
|
24
|
+
|
|
25
|
+
***
|
|
26
|
+
|
|
27
|
+
### path {#path}
|
|
28
|
+
|
|
29
|
+
> **path**: `string`
|
|
30
|
+
|
|
31
|
+
Schema path where the issue was detected.
|
|
32
|
+
|
|
33
|
+
***
|
|
34
|
+
|
|
35
|
+
### fileName? {#filename}
|
|
36
|
+
|
|
37
|
+
> `optional` **fileName?**: `string`
|
|
38
|
+
|
|
39
|
+
Source file where the diagnostic originated, if available.
|
|
40
|
+
|
|
41
|
+
***
|
|
42
|
+
|
|
43
|
+
### line? {#line}
|
|
44
|
+
|
|
45
|
+
> `optional` **line?**: `number`
|
|
46
|
+
|
|
47
|
+
One-based source line number, when available.
|
|
48
|
+
|
|
49
|
+
***
|
|
50
|
+
|
|
51
|
+
### column? {#column}
|
|
52
|
+
|
|
53
|
+
> `optional` **column?**: `number`
|
|
54
|
+
|
|
55
|
+
One-based source column number, when available.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Interface: ITypeScriptToSchemaOptions
|
|
2
|
+
|
|
3
|
+
Options for TypeScript to JSON schema generation.
|
|
4
|
+
|
|
5
|
+
## Properties
|
|
6
|
+
|
|
7
|
+
### externalReferences? {#externalreferences}
|
|
8
|
+
|
|
9
|
+
> `optional` **externalReferences?**: `object`
|
|
10
|
+
|
|
11
|
+
Mapping of package ids, type ids, wildcard patterns, or regex patterns to schema id prefixes
|
|
12
|
+
or replacement templates for referenced schemas.
|
|
13
|
+
|
|
14
|
+
#### Index Signature
|
|
15
|
+
|
|
16
|
+
\[`id`: `string`\]: `string`
|
|
17
|
+
|
|
18
|
+
***
|
|
19
|
+
|
|
20
|
+
### onDiagnostic? {#ondiagnostic}
|
|
21
|
+
|
|
22
|
+
> `optional` **onDiagnostic?**: (`diagnostic`) => `void`
|
|
23
|
+
|
|
24
|
+
Optional diagnostic callback for non-fatal generation issues.
|
|
25
|
+
|
|
26
|
+
#### Parameters
|
|
27
|
+
|
|
28
|
+
##### diagnostic
|
|
29
|
+
|
|
30
|
+
[`ITypeScriptToSchemaDiagnostics`](ITypeScriptToSchemaDiagnostics.md)
|
|
31
|
+
|
|
32
|
+
The diagnostic details for the generation issue.
|
|
33
|
+
|
|
34
|
+
#### Returns
|
|
35
|
+
|
|
36
|
+
`void`
|
|
37
|
+
|
|
38
|
+
***
|
|
39
|
+
|
|
40
|
+
### suppressPackageWarnings? {#suppresspackagewarnings}
|
|
41
|
+
|
|
42
|
+
> `optional` **suppressPackageWarnings?**: `string`[]
|
|
43
|
+
|
|
44
|
+
Package names where diagnostics should be suppressed, e.g. jose.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Variable: EmbeddedSchemaMode
|
|
2
|
+
|
|
3
|
+
> `const` **EmbeddedSchemaMode**: `object`
|
|
4
|
+
|
|
5
|
+
The available embedded schema modes.
|
|
6
|
+
|
|
7
|
+
## Type Declaration
|
|
8
|
+
|
|
9
|
+
### Defs {#defs}
|
|
10
|
+
|
|
11
|
+
> `readonly` **Defs**: `"defs"` = `"defs"`
|
|
12
|
+
|
|
13
|
+
Referenced schemas are added to the "defs" section of the root schema.
|
|
14
|
+
|
|
15
|
+
### Inline {#inline}
|
|
16
|
+
|
|
17
|
+
> `readonly` **Inline**: `"inline"` = `"inline"`
|
|
18
|
+
|
|
19
|
+
Referenced schemas are inlined into the referencing schema.
|
package/locales/en.json
CHANGED
|
@@ -1,3 +1,34 @@
|
|
|
1
1
|
{
|
|
2
|
-
"error": {
|
|
2
|
+
"error": {
|
|
3
|
+
"jsonSchemaBuilder": {
|
|
4
|
+
"invalidJsonSchemaTagKey": "Ignoring invalid @json-schema tag key \"{rawKey}\". Mapped key \"{schemaKey}\" is not supported by JSON Schema.",
|
|
5
|
+
"constraintOnIncompatibleType": "The @json-schema \"{schemaKey}\" constraint requires type \"{requiredType}\" but the type is \"{schemaType}\".",
|
|
6
|
+
"invalidFormatValue": "The @json-schema \"format\" value \"{formatValue}\" is not a recognised JSON Schema format. Valid values are: {validFormats}.",
|
|
7
|
+
"missingTypeReferenceSchema": "Unable to resolve type \"{typeName}\"{importSource} required as base type for utility type. Ensure the type is in the configured packages list or its external package exports TypeScript source files that can be parsed via the AST."
|
|
8
|
+
}
|
|
9
|
+
},
|
|
10
|
+
"jsonSchemaBuilder": {
|
|
11
|
+
"diagnostic": {
|
|
12
|
+
"symbolValuedProperty": "Skipping symbol-typed property \"{propertyName}\".",
|
|
13
|
+
"symbolKeyedMember": "Skipping symbol-keyed member \"{memberName}\".",
|
|
14
|
+
"unsupportedComputedPropertyName": "Skipping unsupported computed property name \"{propertyName}\".",
|
|
15
|
+
"functionTypedProperty": "Skipping function-typed property \"{propertyName}\".",
|
|
16
|
+
"unsupportedIndexSignature": "Skipping index signature with unsupported key type \"{keyType}\".",
|
|
17
|
+
"unresolvedKeyofOperand": "Could not resolve keyof operand \"{operand}\".",
|
|
18
|
+
"unmappedTypeNode": "Unsupported TypeScript type node kind \"{kind}\"; the type will be omitted.",
|
|
19
|
+
"unresolvedMappedTypeRemap": "Could not resolve mapped type key remap for \"{typeName}\"; falling back to additionalProperties.",
|
|
20
|
+
"unsupportedImportTypeForm": "Skipping unsupported import type form \"{argument}\".",
|
|
21
|
+
"unresolvedImportTypeQualifier": "Could not resolve import type qualifier for \"{argument}\".",
|
|
22
|
+
"unresolvedTypeQueryTarget": "Could not resolve type query target \"{target}\".",
|
|
23
|
+
"unsupportedInferredExpressionKind": "Skipping unsupported inferred expression kind \"{kind}\".",
|
|
24
|
+
"unsupportedInferredObjectComputedKey": "Skipping inferred object property with unsupported computed key \"{propertyName}\".",
|
|
25
|
+
"unsupportedInferredObjectSpread": "Skipping inferred object spread expression \"{expression}\".",
|
|
26
|
+
"unsupportedInferredObjectMemberKind": "Skipping inferred object member kind \"{kind}\".",
|
|
27
|
+
"unsupportedInferredTupleElement": "Skipping unsupported inferred tuple element kind \"{kind}\".",
|
|
28
|
+
"unsupportedTemplateLiteralSpan": "Could not derive a regex pattern for template literal type \"{type}\"; falling back to string.",
|
|
29
|
+
"unsupportedTypeElementMember": "Skipping unsupported type member kind \"{kind}\".",
|
|
30
|
+
"unsupportedUtilityType": "Skipping unsupported utility type \"{utilityType}\".",
|
|
31
|
+
"excludedEnclosingObjectDisallowedType": "Excluding enclosing object \"{enclosingObjectName}\" because property \"{propertyName}\" uses disallowed type \"{disallowedTypeName}\"."
|
|
32
|
+
}
|
|
33
|
+
}
|
|
3
34
|
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/tools-core",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "Shared
|
|
3
|
+
"version": "0.0.4-next.1",
|
|
4
|
+
"description": "Shared utilities and models for tooling packages",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
|
-
"url": "git+https://github.com/
|
|
7
|
+
"url": "git+https://github.com/iotaledger/twin-tools.git",
|
|
8
8
|
"directory": "packages/tools-core"
|
|
9
9
|
},
|
|
10
10
|
"author": "martyn.janes@iota.org",
|
|
@@ -16,7 +16,8 @@
|
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@twin.org/core": "next",
|
|
18
18
|
"@twin.org/nameof": "next",
|
|
19
|
-
"
|
|
19
|
+
"@twin.org/tools-models": "0.0.4-next.1",
|
|
20
|
+
"glob": "13.0.6"
|
|
20
21
|
},
|
|
21
22
|
"main": "./dist/es/index.js",
|
|
22
23
|
"types": "./dist/types/index.d.ts",
|
|
@@ -46,7 +47,7 @@
|
|
|
46
47
|
"utilities"
|
|
47
48
|
],
|
|
48
49
|
"bugs": {
|
|
49
|
-
"url": "git+https://github.com/
|
|
50
|
+
"url": "git+https://github.com/iotaledger/twin-tools/issues"
|
|
50
51
|
},
|
|
51
52
|
"homepage": "https://twindev.org"
|
|
52
53
|
}
|