@twin.org/tools-core 0.0.3-next.21 → 0.0.3-next.23
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/dist/es/utils/importTypeQuerySchemaResolver.js +36 -2
- package/dist/es/utils/importTypeQuerySchemaResolver.js.map +1 -1
- package/dist/es/utils/jsDoc.js +1 -1
- package/dist/es/utils/jsDoc.js.map +1 -1
- package/dist/es/utils/jsonSchemaBuilder.js +144 -133
- package/dist/es/utils/jsonSchemaBuilder.js.map +1 -1
- package/dist/es/utils/mappedTypeSchemaResolver.js +35 -1
- package/dist/es/utils/mappedTypeSchemaResolver.js.map +1 -1
- package/dist/es/utils/objectTransformer.js +1 -1
- package/dist/es/utils/objectTransformer.js.map +1 -1
- package/dist/es/utils/resolver.js +22 -9
- package/dist/es/utils/resolver.js.map +1 -1
- package/dist/es/utils/utilityTypeSchemaMapper.js +81 -40
- package/dist/es/utils/utilityTypeSchemaMapper.js.map +1 -1
- package/dist/types/utils/importTypeQuerySchemaResolver.d.ts +35 -0
- package/dist/types/utils/jsonSchemaBuilder.d.ts +6 -82
- package/dist/types/utils/mappedTypeSchemaResolver.d.ts +35 -0
- package/dist/types/utils/resolver.d.ts +7 -1
- package/dist/types/utils/utilityTypeSchemaMapper.d.ts +60 -13
- package/docs/changelog.md +51 -0
- package/docs/reference/classes/ImportTypeQuerySchemaResolver.md +22 -0
- package/docs/reference/classes/JsonSchemaBuilder.md +12 -304
- package/docs/reference/classes/MappedTypeSchemaResolver.md +64 -0
- package/docs/reference/classes/Resolver.md +12 -1
- package/docs/reference/classes/UtilityTypeSchemaMapper.md +64 -62
- package/package.json +2 -2
|
@@ -16,7 +16,7 @@ Static utility-type schema mapping helpers.
|
|
|
16
16
|
|
|
17
17
|
### mapPartialUtilityType() {#mappartialutilitytype}
|
|
18
18
|
|
|
19
|
-
> `static` **mapPartialUtilityType**(`context`, `typeNode
|
|
19
|
+
> `static` **mapPartialUtilityType**(`context`, `typeNode`): `IJsonSchema` \| `undefined`
|
|
20
20
|
|
|
21
21
|
Map Partial<T> to an object schema with no required properties.
|
|
22
22
|
|
|
@@ -34,12 +34,6 @@ The generation context.
|
|
|
34
34
|
|
|
35
35
|
The Partial type reference.
|
|
36
36
|
|
|
37
|
-
##### resolveUtilityBaseObjectSchema
|
|
38
|
-
|
|
39
|
-
(`context`, `baseTypeNode`) => `IJsonSchema` \| `undefined`
|
|
40
|
-
|
|
41
|
-
Callback to resolve base object schemas.
|
|
42
|
-
|
|
43
37
|
#### Returns
|
|
44
38
|
|
|
45
39
|
`IJsonSchema` \| `undefined`
|
|
@@ -50,7 +44,7 @@ The mapped schema.
|
|
|
50
44
|
|
|
51
45
|
### mapRequiredUtilityType() {#maprequiredutilitytype}
|
|
52
46
|
|
|
53
|
-
> `static` **mapRequiredUtilityType**(`context`, `typeNode
|
|
47
|
+
> `static` **mapRequiredUtilityType**(`context`, `typeNode`): `IJsonSchema` \| `undefined`
|
|
54
48
|
|
|
55
49
|
Map Required<T> to an object schema with all properties required.
|
|
56
50
|
|
|
@@ -68,12 +62,6 @@ The generation context.
|
|
|
68
62
|
|
|
69
63
|
The Required type reference.
|
|
70
64
|
|
|
71
|
-
##### resolveUtilityBaseObjectSchema
|
|
72
|
-
|
|
73
|
-
(`context`, `baseTypeNode`) => `IJsonSchema` \| `undefined`
|
|
74
|
-
|
|
75
|
-
Callback to resolve base object schemas.
|
|
76
|
-
|
|
77
65
|
#### Returns
|
|
78
66
|
|
|
79
67
|
`IJsonSchema` \| `undefined`
|
|
@@ -84,7 +72,7 @@ The mapped schema.
|
|
|
84
72
|
|
|
85
73
|
### mapPickUtilityType() {#mappickutilitytype}
|
|
86
74
|
|
|
87
|
-
> `static` **mapPickUtilityType**(`context`, `typeNode
|
|
75
|
+
> `static` **mapPickUtilityType**(`context`, `typeNode`): `IJsonSchema` \| `undefined`
|
|
88
76
|
|
|
89
77
|
Map Pick<T, K> to an object schema with selected keys preserved.
|
|
90
78
|
|
|
@@ -94,27 +82,25 @@ Map Pick<T, K> to an object schema with selected keys preserved.
|
|
|
94
82
|
|
|
95
83
|
[`ITypeScriptToSchemaContext`](../interfaces/ITypeScriptToSchemaContext.md)
|
|
96
84
|
|
|
85
|
+
The generation context.
|
|
86
|
+
|
|
97
87
|
##### typeNode
|
|
98
88
|
|
|
99
89
|
`TypeReferenceNode`
|
|
100
90
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
(`context`, `baseTypeNode`) => `IJsonSchema` \| `undefined`
|
|
104
|
-
|
|
105
|
-
##### extractUtilityTypeKeys
|
|
106
|
-
|
|
107
|
-
(`context`, `keysNode`) => `string`[]
|
|
91
|
+
The Pick type reference.
|
|
108
92
|
|
|
109
93
|
#### Returns
|
|
110
94
|
|
|
111
95
|
`IJsonSchema` \| `undefined`
|
|
112
96
|
|
|
97
|
+
The mapped schema.
|
|
98
|
+
|
|
113
99
|
***
|
|
114
100
|
|
|
115
101
|
### mapOmitUtilityType() {#mapomitutilitytype}
|
|
116
102
|
|
|
117
|
-
> `static` **mapOmitUtilityType**(`context`, `typeNode
|
|
103
|
+
> `static` **mapOmitUtilityType**(`context`, `typeNode`): `IJsonSchema` \| `undefined`
|
|
118
104
|
|
|
119
105
|
Map Omit<T, K> to an object schema with selected keys removed.
|
|
120
106
|
|
|
@@ -124,27 +110,25 @@ Map Omit<T, K> to an object schema with selected keys removed.
|
|
|
124
110
|
|
|
125
111
|
[`ITypeScriptToSchemaContext`](../interfaces/ITypeScriptToSchemaContext.md)
|
|
126
112
|
|
|
113
|
+
The generation context.
|
|
114
|
+
|
|
127
115
|
##### typeNode
|
|
128
116
|
|
|
129
117
|
`TypeReferenceNode`
|
|
130
118
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
(`context`, `baseTypeNode`) => `IJsonSchema` \| `undefined`
|
|
134
|
-
|
|
135
|
-
##### extractUtilityTypeKeys
|
|
136
|
-
|
|
137
|
-
(`context`, `keysNode`) => `string`[]
|
|
119
|
+
The Omit type reference.
|
|
138
120
|
|
|
139
121
|
#### Returns
|
|
140
122
|
|
|
141
123
|
`IJsonSchema` \| `undefined`
|
|
142
124
|
|
|
125
|
+
The mapped schema.
|
|
126
|
+
|
|
143
127
|
***
|
|
144
128
|
|
|
145
129
|
### mapExcludeUtilityType() {#mapexcludeutilitytype}
|
|
146
130
|
|
|
147
|
-
> `static` **mapExcludeUtilityType**(`context`, `typeNode
|
|
131
|
+
> `static` **mapExcludeUtilityType**(`context`, `typeNode`): `IJsonSchema` \| `undefined`
|
|
148
132
|
|
|
149
133
|
Map Exclude<T, U> to a schema that removes U members from T.
|
|
150
134
|
|
|
@@ -154,23 +138,25 @@ Map Exclude<T, U> to a schema that removes U members from T.
|
|
|
154
138
|
|
|
155
139
|
[`ITypeScriptToSchemaContext`](../interfaces/ITypeScriptToSchemaContext.md)
|
|
156
140
|
|
|
141
|
+
The generation context.
|
|
142
|
+
|
|
157
143
|
##### typeNode
|
|
158
144
|
|
|
159
145
|
`TypeReferenceNode`
|
|
160
146
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
(`context`, `typeNode`) => `IJsonSchema` \| `undefined`
|
|
147
|
+
The Exclude type reference.
|
|
164
148
|
|
|
165
149
|
#### Returns
|
|
166
150
|
|
|
167
151
|
`IJsonSchema` \| `undefined`
|
|
168
152
|
|
|
153
|
+
The mapped schema.
|
|
154
|
+
|
|
169
155
|
***
|
|
170
156
|
|
|
171
157
|
### mapExtractUtilityType() {#mapextractutilitytype}
|
|
172
158
|
|
|
173
|
-
> `static` **mapExtractUtilityType**(`context`, `typeNode
|
|
159
|
+
> `static` **mapExtractUtilityType**(`context`, `typeNode`): `IJsonSchema` \| `undefined`
|
|
174
160
|
|
|
175
161
|
Map Extract<T, U> to a schema that keeps U members from T.
|
|
176
162
|
|
|
@@ -180,23 +166,25 @@ Map Extract<T, U> to a schema that keeps U members from T.
|
|
|
180
166
|
|
|
181
167
|
[`ITypeScriptToSchemaContext`](../interfaces/ITypeScriptToSchemaContext.md)
|
|
182
168
|
|
|
169
|
+
The generation context.
|
|
170
|
+
|
|
183
171
|
##### typeNode
|
|
184
172
|
|
|
185
173
|
`TypeReferenceNode`
|
|
186
174
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
(`context`, `typeNode`) => `IJsonSchema` \| `undefined`
|
|
175
|
+
The Extract type reference.
|
|
190
176
|
|
|
191
177
|
#### Returns
|
|
192
178
|
|
|
193
179
|
`IJsonSchema` \| `undefined`
|
|
194
180
|
|
|
181
|
+
The mapped schema.
|
|
182
|
+
|
|
195
183
|
***
|
|
196
184
|
|
|
197
185
|
### mapNonNullableUtilityType() {#mapnonnullableutilitytype}
|
|
198
186
|
|
|
199
|
-
> `static` **mapNonNullableUtilityType**(`context`, `typeNode
|
|
187
|
+
> `static` **mapNonNullableUtilityType**(`context`, `typeNode`): `IJsonSchema` \| `undefined`
|
|
200
188
|
|
|
201
189
|
Map NonNullable<T> by removing null and undefined branches from T.
|
|
202
190
|
|
|
@@ -206,23 +194,25 @@ Map NonNullable<T> by removing null and undefined branches from T.
|
|
|
206
194
|
|
|
207
195
|
[`ITypeScriptToSchemaContext`](../interfaces/ITypeScriptToSchemaContext.md)
|
|
208
196
|
|
|
197
|
+
The generation context.
|
|
198
|
+
|
|
209
199
|
##### typeNode
|
|
210
200
|
|
|
211
201
|
`TypeReferenceNode`
|
|
212
202
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
(`context`, `typeNode`) => `IJsonSchema` \| `undefined`
|
|
203
|
+
The NonNullable type reference.
|
|
216
204
|
|
|
217
205
|
#### Returns
|
|
218
206
|
|
|
219
207
|
`IJsonSchema` \| `undefined`
|
|
220
208
|
|
|
209
|
+
The mapped schema.
|
|
210
|
+
|
|
221
211
|
***
|
|
222
212
|
|
|
223
213
|
### mapRecordUtilityType() {#maprecordutilitytype}
|
|
224
214
|
|
|
225
|
-
> `static` **mapRecordUtilityType**(`context`, `typeNode
|
|
215
|
+
> `static` **mapRecordUtilityType**(`context`, `typeNode`): `IJsonSchema` \| `undefined`
|
|
226
216
|
|
|
227
217
|
Map Record<K, V> to an object schema with key constraints where possible.
|
|
228
218
|
|
|
@@ -232,23 +222,25 @@ Map Record<K, V> to an object schema with key constraints where possible.
|
|
|
232
222
|
|
|
233
223
|
[`ITypeScriptToSchemaContext`](../interfaces/ITypeScriptToSchemaContext.md)
|
|
234
224
|
|
|
225
|
+
The generation context.
|
|
226
|
+
|
|
235
227
|
##### typeNode
|
|
236
228
|
|
|
237
229
|
`TypeReferenceNode`
|
|
238
230
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
(`context`, `typeNode`) => `IJsonSchema` \| `undefined`
|
|
231
|
+
The Record type reference.
|
|
242
232
|
|
|
243
233
|
#### Returns
|
|
244
234
|
|
|
245
235
|
`IJsonSchema` \| `undefined`
|
|
246
236
|
|
|
237
|
+
The mapped schema.
|
|
238
|
+
|
|
247
239
|
***
|
|
248
240
|
|
|
249
241
|
### mapJsonLdObjectUtilityType() {#mapjsonldobjectutilitytype}
|
|
250
242
|
|
|
251
|
-
> `static` **mapJsonLdObjectUtilityType**(`context`, `typeNode`, `options
|
|
243
|
+
> `static` **mapJsonLdObjectUtilityType**(`context`, `typeNode`, `options`): `IJsonSchema` \| `undefined`
|
|
252
244
|
|
|
253
245
|
Map JsonLdObject utility types using key-removal and optional key-addition rules.
|
|
254
246
|
|
|
@@ -258,41 +250,47 @@ Map JsonLdObject utility types using key-removal and optional key-addition rules
|
|
|
258
250
|
|
|
259
251
|
[`ITypeScriptToSchemaContext`](../interfaces/ITypeScriptToSchemaContext.md)
|
|
260
252
|
|
|
253
|
+
The generation context.
|
|
254
|
+
|
|
261
255
|
##### typeNode
|
|
262
256
|
|
|
263
257
|
`TypeReferenceNode`
|
|
264
258
|
|
|
259
|
+
The JsonLdObject utility type reference.
|
|
260
|
+
|
|
265
261
|
##### options
|
|
266
262
|
|
|
263
|
+
The mapping options for key removal and optional key addition.
|
|
264
|
+
|
|
267
265
|
###### keysToRemove
|
|
268
266
|
|
|
269
267
|
`string`[]
|
|
270
268
|
|
|
269
|
+
The property keys to remove from the base schema.
|
|
270
|
+
|
|
271
271
|
###### keyToAdd?
|
|
272
272
|
|
|
273
273
|
`"type"` \| `"id"` \| `"@id"` \| `"@type"` \| `"@context"`
|
|
274
274
|
|
|
275
|
+
The optional key to add after removal.
|
|
276
|
+
|
|
275
277
|
###### isAddedKeyRequired?
|
|
276
278
|
|
|
277
279
|
`boolean`
|
|
278
280
|
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
(`context`, `baseTypeNode`) => `IJsonSchema` \| `undefined`
|
|
282
|
-
|
|
283
|
-
##### mapTypeNodeToSchema
|
|
284
|
-
|
|
285
|
-
(`context`, `typeNode`) => `IJsonSchema` \| `undefined`
|
|
281
|
+
True when the added key must be required.
|
|
286
282
|
|
|
287
283
|
#### Returns
|
|
288
284
|
|
|
289
285
|
`IJsonSchema` \| `undefined`
|
|
290
286
|
|
|
287
|
+
The mapped schema.
|
|
288
|
+
|
|
291
289
|
***
|
|
292
290
|
|
|
293
291
|
### mapObjectOrArrayUtilityType() {#mapobjectorarrayutilitytype}
|
|
294
292
|
|
|
295
|
-
> `static` **mapObjectOrArrayUtilityType**(`context`, `typeNode
|
|
293
|
+
> `static` **mapObjectOrArrayUtilityType**(`context`, `typeNode`): `IJsonSchema` \| `undefined`
|
|
296
294
|
|
|
297
295
|
Map ObjectOrArray<T> to a schema accepting T or T[].
|
|
298
296
|
|
|
@@ -302,23 +300,25 @@ Map ObjectOrArray<T> to a schema accepting T or T[].
|
|
|
302
300
|
|
|
303
301
|
[`ITypeScriptToSchemaContext`](../interfaces/ITypeScriptToSchemaContext.md)
|
|
304
302
|
|
|
303
|
+
The generation context.
|
|
304
|
+
|
|
305
305
|
##### typeNode
|
|
306
306
|
|
|
307
307
|
`TypeReferenceNode`
|
|
308
308
|
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
(`context`, `typeNode`) => `IJsonSchema` \| `undefined`
|
|
309
|
+
The ObjectOrArray type reference.
|
|
312
310
|
|
|
313
311
|
#### Returns
|
|
314
312
|
|
|
315
313
|
`IJsonSchema` \| `undefined`
|
|
316
314
|
|
|
315
|
+
The mapped schema.
|
|
316
|
+
|
|
317
317
|
***
|
|
318
318
|
|
|
319
319
|
### mapSingleOccurrenceArrayUtilityType() {#mapsingleoccurrencearrayutilitytype}
|
|
320
320
|
|
|
321
|
-
> `static` **mapSingleOccurrenceArrayUtilityType**(`context`, `typeNode
|
|
321
|
+
> `static` **mapSingleOccurrenceArrayUtilityType**(`context`, `typeNode`): `IJsonSchema` \| `undefined`
|
|
322
322
|
|
|
323
323
|
Map SingleOccurrenceArray<T, U> to a non-empty array containing exactly one U.
|
|
324
324
|
|
|
@@ -328,14 +328,16 @@ Map SingleOccurrenceArray<T, U> to a non-empty array containing exactly one U.
|
|
|
328
328
|
|
|
329
329
|
[`ITypeScriptToSchemaContext`](../interfaces/ITypeScriptToSchemaContext.md)
|
|
330
330
|
|
|
331
|
+
The generation context.
|
|
332
|
+
|
|
331
333
|
##### typeNode
|
|
332
334
|
|
|
333
335
|
`TypeReferenceNode`
|
|
334
336
|
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
(`context`, `typeNode`) => `IJsonSchema` \| `undefined`
|
|
337
|
+
The SingleOccurrenceArray type reference.
|
|
338
338
|
|
|
339
339
|
#### Returns
|
|
340
340
|
|
|
341
341
|
`IJsonSchema` \| `undefined`
|
|
342
|
+
|
|
343
|
+
The mapped schema.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/tools-core",
|
|
3
|
-
"version": "0.0.3-next.
|
|
3
|
+
"version": "0.0.3-next.23",
|
|
4
4
|
"description": "Shared utilities and models for tooling packages",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@twin.org/core": "next",
|
|
18
18
|
"@twin.org/nameof": "next",
|
|
19
|
-
"@twin.org/tools-models": "0.0.3-next.
|
|
19
|
+
"@twin.org/tools-models": "0.0.3-next.23",
|
|
20
20
|
"glob": "13.0.6"
|
|
21
21
|
},
|
|
22
22
|
"main": "./dist/es/index.js",
|