@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
|
@@ -388,64 +388,17 @@ export declare class JsonSchemaBuilder {
|
|
|
388
388
|
* @param context The generation context.
|
|
389
389
|
* @param schema The schema to expand.
|
|
390
390
|
* @param declaration The interface declaration.
|
|
391
|
+
* @throws GeneralError when an extended type cannot be resolved to a schema.
|
|
391
392
|
*/
|
|
392
393
|
static applyInterfaceExtendsSchema(context: ITypeScriptToSchemaContext, schema: Partial<IJsonSchema>, declaration: ts.InterfaceDeclaration): void;
|
|
393
394
|
/**
|
|
394
|
-
*
|
|
395
|
+
* Resolve a direct base reference for refinement Omit patterns in interface extends clauses.
|
|
395
396
|
* @param context The generation context.
|
|
396
|
-
* @param
|
|
397
|
-
* @
|
|
398
|
-
|
|
399
|
-
static mapPartialUtilityType(context: ITypeScriptToSchemaContext, typeNode: ts.TypeReferenceNode): IJsonSchema | undefined;
|
|
400
|
-
/**
|
|
401
|
-
* Map Required<T> to an object schema with all properties required.
|
|
402
|
-
* @param context The generation context.
|
|
403
|
-
* @param typeNode The Required type reference.
|
|
404
|
-
* @returns The mapped schema.
|
|
405
|
-
*/
|
|
406
|
-
static mapRequiredUtilityType(context: ITypeScriptToSchemaContext, typeNode: ts.TypeReferenceNode): IJsonSchema | undefined;
|
|
407
|
-
/**
|
|
408
|
-
* Map Pick<T, K> to an object schema with selected keys preserved.
|
|
409
|
-
* @param context The generation context.
|
|
410
|
-
* @param typeNode The Pick type reference.
|
|
411
|
-
* @returns The mapped schema.
|
|
412
|
-
*/
|
|
413
|
-
static mapPickUtilityType(context: ITypeScriptToSchemaContext, typeNode: ts.TypeReferenceNode): IJsonSchema | undefined;
|
|
414
|
-
/**
|
|
415
|
-
* Map Omit<T, K> to an object schema with selected keys removed.
|
|
416
|
-
* @param context The generation context.
|
|
417
|
-
* @param typeNode The Omit type reference.
|
|
418
|
-
* @returns The mapped schema.
|
|
419
|
-
*/
|
|
420
|
-
static mapOmitUtilityType(context: ITypeScriptToSchemaContext, typeNode: ts.TypeReferenceNode): IJsonSchema | undefined;
|
|
421
|
-
/**
|
|
422
|
-
* Map Exclude<T, U> to a schema that removes U members from T.
|
|
423
|
-
* @param context The generation context.
|
|
424
|
-
* @param typeNode The Exclude type reference.
|
|
425
|
-
* @returns The mapped schema.
|
|
426
|
-
*/
|
|
427
|
-
static mapExcludeUtilityType(context: ITypeScriptToSchemaContext, typeNode: ts.TypeReferenceNode): IJsonSchema | undefined;
|
|
428
|
-
/**
|
|
429
|
-
* Map Extract<T, U> to a schema that keeps U members from T.
|
|
430
|
-
* @param context The generation context.
|
|
431
|
-
* @param typeNode The Extract type reference.
|
|
432
|
-
* @returns The mapped schema.
|
|
397
|
+
* @param declaration The interface declaration being mapped.
|
|
398
|
+
* @param extendedType The heritage type being processed.
|
|
399
|
+
* @returns A direct base reference when a refinement pattern is detected.
|
|
433
400
|
*/
|
|
434
|
-
static
|
|
435
|
-
/**
|
|
436
|
-
* Map NonNullable<T> by removing null and undefined branches from T.
|
|
437
|
-
* @param context The generation context.
|
|
438
|
-
* @param typeNode The NonNullable type reference.
|
|
439
|
-
* @returns The mapped schema.
|
|
440
|
-
*/
|
|
441
|
-
static mapNonNullableUtilityType(context: ITypeScriptToSchemaContext, typeNode: ts.TypeReferenceNode): IJsonSchema | undefined;
|
|
442
|
-
/**
|
|
443
|
-
* Map Record<K, V> to an object schema with key constraints where possible.
|
|
444
|
-
* @param context The generation context.
|
|
445
|
-
* @param typeNode The Record type reference.
|
|
446
|
-
* @returns The mapped schema.
|
|
447
|
-
*/
|
|
448
|
-
static mapRecordUtilityType(context: ITypeScriptToSchemaContext, typeNode: ts.TypeReferenceNode): IJsonSchema | undefined;
|
|
401
|
+
static resolveRefinementUtilityBaseRef(context: ITypeScriptToSchemaContext, declaration: ts.InterfaceDeclaration, extendedType: ts.ExpressionWithTypeArguments): IJsonSchema | undefined;
|
|
449
402
|
/**
|
|
450
403
|
* Determine whether a type node represents null or undefined.
|
|
451
404
|
* @param typeNode The type node.
|
|
@@ -458,21 +411,6 @@ export declare class JsonSchemaBuilder {
|
|
|
458
411
|
* @returns The extracted literal keys.
|
|
459
412
|
*/
|
|
460
413
|
static extractRecordLiteralKeys(keyTypeNode: ts.TypeNode): string[];
|
|
461
|
-
/**
|
|
462
|
-
* Map JsonLdObject utility types using key-removal and optional key-addition rules.
|
|
463
|
-
* @param context The generation context.
|
|
464
|
-
* @param typeNode The JsonLdObject utility type reference.
|
|
465
|
-
* @param options Mapping options.
|
|
466
|
-
* @param options.keysToRemove Keys to remove from the base schema.
|
|
467
|
-
* @param options.keyToAdd Optional key to add to the base schema.
|
|
468
|
-
* @param options.isAddedKeyRequired Whether the added key should be required.
|
|
469
|
-
* @returns The mapped schema.
|
|
470
|
-
*/
|
|
471
|
-
static mapJsonLdObjectUtilityType(context: ITypeScriptToSchemaContext, typeNode: ts.TypeReferenceNode, options: {
|
|
472
|
-
keysToRemove: string[];
|
|
473
|
-
keyToAdd?: "id" | "@id" | "type" | "@type" | "@context";
|
|
474
|
-
isAddedKeyRequired?: boolean;
|
|
475
|
-
}): IJsonSchema | undefined;
|
|
476
414
|
/**
|
|
477
415
|
* Resolve a default schema for JsonLdObject utility key additions when the type argument is omitted.
|
|
478
416
|
* @param baseSchema The base object schema.
|
|
@@ -507,20 +445,6 @@ export declare class JsonSchemaBuilder {
|
|
|
507
445
|
* @returns The resolved schema.
|
|
508
446
|
*/
|
|
509
447
|
static mapJsonLdObjectDefaultEitherSchema(baseSchema: IJsonSchema, firstKey: string, secondKey: string, fallbackSchema: IJsonSchema): IJsonSchema;
|
|
510
|
-
/**
|
|
511
|
-
* Map ObjectOrArray<T> to a schema accepting T or T[].
|
|
512
|
-
* @param context The generation context.
|
|
513
|
-
* @param typeNode The ObjectOrArray type reference.
|
|
514
|
-
* @returns The mapped schema.
|
|
515
|
-
*/
|
|
516
|
-
static mapObjectOrArrayUtilityType(context: ITypeScriptToSchemaContext, typeNode: ts.TypeReferenceNode): IJsonSchema | undefined;
|
|
517
|
-
/**
|
|
518
|
-
* Map SingleOccurrenceArray<T, U> to a non-empty array containing exactly one U.
|
|
519
|
-
* @param context The generation context.
|
|
520
|
-
* @param typeNode The SingleOccurrenceArray type reference.
|
|
521
|
-
* @returns The mapped schema.
|
|
522
|
-
*/
|
|
523
|
-
static mapSingleOccurrenceArrayUtilityType(context: ITypeScriptToSchemaContext, typeNode: ts.TypeReferenceNode): IJsonSchema | undefined;
|
|
524
448
|
/**
|
|
525
449
|
* Add a comment to schemas inlined for utility type transformations.
|
|
526
450
|
* @param schema The schema to annotate.
|
|
@@ -7,6 +7,11 @@ import type { ITypeScriptToSchemaContext } from "../models/ITypeScriptToSchemaCo
|
|
|
7
7
|
export declare class MappedTypeSchemaResolver {
|
|
8
8
|
/**
|
|
9
9
|
* Resolve mapped type output keys, including remapped key names via `as`.
|
|
10
|
+
* @param context The generation context.
|
|
11
|
+
* @param typeNode The mapped type node.
|
|
12
|
+
* @param mappedKeys The resolved source keys from the mapped type constraint.
|
|
13
|
+
* @param mappedTypeParameterName The mapped type parameter identifier.
|
|
14
|
+
* @returns The resolved source-to-output mapped key entries.
|
|
10
15
|
*/
|
|
11
16
|
static resolveMappedTypePropertyEntries(context: ITypeScriptToSchemaContext, typeNode: ts.MappedTypeNode, mappedKeys: string[], mappedTypeParameterName: string): {
|
|
12
17
|
sourceKey: string;
|
|
@@ -14,26 +19,53 @@ export declare class MappedTypeSchemaResolver {
|
|
|
14
19
|
}[] | undefined;
|
|
15
20
|
/**
|
|
16
21
|
* Resolve a remapped mapped-type key expression for a concrete source key.
|
|
22
|
+
* @param context The generation context.
|
|
23
|
+
* @param nameTypeNode The mapped type name remapping expression node.
|
|
24
|
+
* @param sourceKey The concrete source key currently being evaluated.
|
|
25
|
+
* @param mappedTypeParameterName The mapped type parameter identifier.
|
|
26
|
+
* @returns The remapped key, null when excluded via never, or undefined when unresolved.
|
|
17
27
|
*/
|
|
18
28
|
static resolveMappedTypeRemappedKey(context: ITypeScriptToSchemaContext, nameTypeNode: ts.TypeNode, sourceKey: string, mappedTypeParameterName: string): string | null | undefined;
|
|
19
29
|
/**
|
|
20
30
|
* Evaluate whether a concrete mapped key satisfies an `extends` condition.
|
|
31
|
+
* @param context The generation context.
|
|
32
|
+
* @param sourceKey The concrete source key being evaluated.
|
|
33
|
+
* @param extendsTypeNode The extends condition type node.
|
|
34
|
+
* @returns True when the key satisfies the condition, false when it does not, otherwise undefined.
|
|
21
35
|
*/
|
|
22
36
|
static evaluateMappedKeyExtendsCondition(context: ITypeScriptToSchemaContext, sourceKey: string, extendsTypeNode: ts.TypeNode): boolean | undefined;
|
|
23
37
|
/**
|
|
24
38
|
* Build a conservative fallback schema for mapped types whose key remapping cannot be resolved.
|
|
39
|
+
* @param context The generation context.
|
|
40
|
+
* @param typeNode The mapped type node.
|
|
41
|
+
* @param mappedKeys The resolved source keys from the mapped type constraint.
|
|
42
|
+
* @param mappedTypeParameterName The mapped type parameter identifier.
|
|
43
|
+
* @param sourceObjectSchema The optional source object schema for property lookups.
|
|
44
|
+
* @returns The fallback mapped type schema.
|
|
25
45
|
*/
|
|
26
46
|
static buildMappedTypeFallbackSchema(context: ITypeScriptToSchemaContext, typeNode: ts.MappedTypeNode, mappedKeys: string[], mappedTypeParameterName: string, sourceObjectSchema?: IJsonSchema): IJsonSchema;
|
|
27
47
|
/**
|
|
28
48
|
* Build fallback additionalProperties for unresolved mapped key remapping.
|
|
49
|
+
* @param context The generation context.
|
|
50
|
+
* @param typeNode The mapped type node.
|
|
51
|
+
* @param mappedKeys The resolved source keys from the mapped type constraint.
|
|
52
|
+
* @param mappedTypeParameterName The mapped type parameter identifier.
|
|
53
|
+
* @param sourceObjectSchema The optional source object schema for property lookups.
|
|
54
|
+
* @returns The fallback additionalProperties schema.
|
|
29
55
|
*/
|
|
30
56
|
static buildMappedTypeFallbackAdditionalProperties(context: ITypeScriptToSchemaContext, typeNode: ts.MappedTypeNode, mappedKeys: string[], mappedTypeParameterName: string, sourceObjectSchema?: IJsonSchema): IJsonSchema | undefined;
|
|
31
57
|
/**
|
|
32
58
|
* Merge mapped property schemas when multiple source keys remap to the same output key.
|
|
59
|
+
* @param existingSchema The existing schema already assigned to the mapped key.
|
|
60
|
+
* @param nextSchema The next schema to merge into the mapped key.
|
|
61
|
+
* @returns The merged schema.
|
|
33
62
|
*/
|
|
34
63
|
static mergeMappedTypePropertySchemas(existingSchema: IJsonSchema, nextSchema: IJsonSchema): IJsonSchema;
|
|
35
64
|
/**
|
|
36
65
|
* Resolve required remapped keys from the source object's required key set.
|
|
66
|
+
* @param mappedEntries The source-to-output mapped key entries.
|
|
67
|
+
* @param sourceObjectSchema The source object schema containing required keys.
|
|
68
|
+
* @returns The required output keys.
|
|
37
69
|
*/
|
|
38
70
|
static resolveMappedTypeSourceRequiredPropertyKeys(mappedEntries: {
|
|
39
71
|
sourceKey: string;
|
|
@@ -41,6 +73,9 @@ export declare class MappedTypeSchemaResolver {
|
|
|
41
73
|
}[], sourceObjectSchema: IJsonSchema): string[] | undefined;
|
|
42
74
|
/**
|
|
43
75
|
* Apply TypeScript intrinsic string remapping helpers to a key.
|
|
76
|
+
* @param intrinsicName The intrinsic helper name.
|
|
77
|
+
* @param value The input key value.
|
|
78
|
+
* @returns The remapped key value.
|
|
44
79
|
*/
|
|
45
80
|
private static applyIntrinsicMappedTypeKeyRemap;
|
|
46
81
|
}
|
|
@@ -7,9 +7,15 @@ export declare class Resolver {
|
|
|
7
7
|
* Resolve a type declaration AST from a package and type name.
|
|
8
8
|
* @param packageName The package to inspect.
|
|
9
9
|
* @param typeName The type to resolve.
|
|
10
|
+
* @param containingFilePath An optional source file path to use as the starting point for
|
|
11
|
+
* package resolution. When provided, TypeScript module resolution walks up from that file's
|
|
12
|
+
* directory, which allows transitive dependencies installed alongside the source file (e.g.
|
|
13
|
+
* in a sub-directory node_modules) to be found even when they are not reachable from the
|
|
14
|
+
* current working directory. The path is normalised to absolute before use;
|
|
15
|
+
* falls back to process.cwd() when omitted.
|
|
10
16
|
* @returns The resolved declaration AST.
|
|
11
17
|
*/
|
|
12
|
-
static resolveTypeDeclarationAst(packageName: string, typeName: string): {
|
|
18
|
+
static resolveTypeDeclarationAst(packageName: string, typeName: string, containingFilePath?: string): {
|
|
13
19
|
sourceFile: ts.SourceFile;
|
|
14
20
|
declaration: ts.InterfaceDeclaration | ts.TypeAliasDeclaration;
|
|
15
21
|
} | undefined;
|
|
@@ -9,84 +9,131 @@ export declare class UtilityTypeSchemaMapper {
|
|
|
9
9
|
* Map Partial<T> to an object schema with no required properties.
|
|
10
10
|
* @param context The generation context.
|
|
11
11
|
* @param typeNode The Partial type reference.
|
|
12
|
-
* @param resolveUtilityBaseObjectSchema Callback to resolve base object schemas.
|
|
13
12
|
* @returns The mapped schema.
|
|
14
13
|
*/
|
|
15
|
-
static mapPartialUtilityType(context: ITypeScriptToSchemaContext, typeNode: ts.TypeReferenceNode
|
|
14
|
+
static mapPartialUtilityType(context: ITypeScriptToSchemaContext, typeNode: ts.TypeReferenceNode): IJsonSchema | undefined;
|
|
16
15
|
/**
|
|
17
16
|
* Map Required<T> to an object schema with all properties required.
|
|
18
17
|
* @param context The generation context.
|
|
19
18
|
* @param typeNode The Required type reference.
|
|
20
|
-
* @param resolveUtilityBaseObjectSchema Callback to resolve base object schemas.
|
|
21
19
|
* @returns The mapped schema.
|
|
22
20
|
*/
|
|
23
|
-
static mapRequiredUtilityType(context: ITypeScriptToSchemaContext, typeNode: ts.TypeReferenceNode
|
|
21
|
+
static mapRequiredUtilityType(context: ITypeScriptToSchemaContext, typeNode: ts.TypeReferenceNode): IJsonSchema | undefined;
|
|
24
22
|
/**
|
|
25
23
|
* Map Pick<T, K> to an object schema with selected keys preserved.
|
|
24
|
+
* @param context The generation context.
|
|
25
|
+
* @param typeNode The Pick type reference.
|
|
26
|
+
* @returns The mapped schema.
|
|
26
27
|
*/
|
|
27
|
-
static mapPickUtilityType(context: ITypeScriptToSchemaContext, typeNode: ts.TypeReferenceNode
|
|
28
|
+
static mapPickUtilityType(context: ITypeScriptToSchemaContext, typeNode: ts.TypeReferenceNode): IJsonSchema | undefined;
|
|
28
29
|
/**
|
|
29
30
|
* Map Omit<T, K> to an object schema with selected keys removed.
|
|
31
|
+
* @param context The generation context.
|
|
32
|
+
* @param typeNode The Omit type reference.
|
|
33
|
+
* @returns The mapped schema.
|
|
30
34
|
*/
|
|
31
|
-
static mapOmitUtilityType(context: ITypeScriptToSchemaContext, typeNode: ts.TypeReferenceNode
|
|
35
|
+
static mapOmitUtilityType(context: ITypeScriptToSchemaContext, typeNode: ts.TypeReferenceNode): IJsonSchema | undefined;
|
|
32
36
|
/**
|
|
33
37
|
* Map Exclude<T, U> to a schema that removes U members from T.
|
|
38
|
+
* @param context The generation context.
|
|
39
|
+
* @param typeNode The Exclude type reference.
|
|
40
|
+
* @returns The mapped schema.
|
|
34
41
|
*/
|
|
35
|
-
static mapExcludeUtilityType(context: ITypeScriptToSchemaContext, typeNode: ts.TypeReferenceNode
|
|
42
|
+
static mapExcludeUtilityType(context: ITypeScriptToSchemaContext, typeNode: ts.TypeReferenceNode): IJsonSchema | undefined;
|
|
36
43
|
/**
|
|
37
44
|
* Map Extract<T, U> to a schema that keeps U members from T.
|
|
45
|
+
* @param context The generation context.
|
|
46
|
+
* @param typeNode The Extract type reference.
|
|
47
|
+
* @returns The mapped schema.
|
|
38
48
|
*/
|
|
39
|
-
static mapExtractUtilityType(context: ITypeScriptToSchemaContext, typeNode: ts.TypeReferenceNode
|
|
49
|
+
static mapExtractUtilityType(context: ITypeScriptToSchemaContext, typeNode: ts.TypeReferenceNode): IJsonSchema | undefined;
|
|
40
50
|
/**
|
|
41
51
|
* Map NonNullable<T> by removing null and undefined branches from T.
|
|
52
|
+
* @param context The generation context.
|
|
53
|
+
* @param typeNode The NonNullable type reference.
|
|
54
|
+
* @returns The mapped schema.
|
|
42
55
|
*/
|
|
43
|
-
static mapNonNullableUtilityType(context: ITypeScriptToSchemaContext, typeNode: ts.TypeReferenceNode
|
|
56
|
+
static mapNonNullableUtilityType(context: ITypeScriptToSchemaContext, typeNode: ts.TypeReferenceNode): IJsonSchema | undefined;
|
|
44
57
|
/**
|
|
45
58
|
* Map Record<K, V> to an object schema with key constraints where possible.
|
|
59
|
+
* @param context The generation context.
|
|
60
|
+
* @param typeNode The Record type reference.
|
|
61
|
+
* @returns The mapped schema.
|
|
46
62
|
*/
|
|
47
|
-
static mapRecordUtilityType(context: ITypeScriptToSchemaContext, typeNode: ts.TypeReferenceNode
|
|
63
|
+
static mapRecordUtilityType(context: ITypeScriptToSchemaContext, typeNode: ts.TypeReferenceNode): IJsonSchema | undefined;
|
|
48
64
|
/**
|
|
49
65
|
* Map JsonLdObject utility types using key-removal and optional key-addition rules.
|
|
66
|
+
* @param context The generation context.
|
|
67
|
+
* @param typeNode The JsonLdObject utility type reference.
|
|
68
|
+
* @param options The mapping options for key removal and optional key addition.
|
|
69
|
+
* @param options.keysToRemove The property keys to remove from the base schema.
|
|
70
|
+
* @param options.keyToAdd The optional key to add after removal.
|
|
71
|
+
* @param options.isAddedKeyRequired True when the added key must be required.
|
|
72
|
+
* @returns The mapped schema.
|
|
50
73
|
*/
|
|
51
74
|
static mapJsonLdObjectUtilityType(context: ITypeScriptToSchemaContext, typeNode: ts.TypeReferenceNode, options: {
|
|
52
75
|
keysToRemove: string[];
|
|
53
76
|
keyToAdd?: "id" | "@id" | "type" | "@type" | "@context";
|
|
54
77
|
isAddedKeyRequired?: boolean;
|
|
55
|
-
}
|
|
78
|
+
}): IJsonSchema | undefined;
|
|
56
79
|
/**
|
|
57
80
|
* Map ObjectOrArray<T> to a schema accepting T or T[].
|
|
81
|
+
* @param context The generation context.
|
|
82
|
+
* @param typeNode The ObjectOrArray type reference.
|
|
83
|
+
* @returns The mapped schema.
|
|
58
84
|
*/
|
|
59
|
-
static mapObjectOrArrayUtilityType(context: ITypeScriptToSchemaContext, typeNode: ts.TypeReferenceNode
|
|
85
|
+
static mapObjectOrArrayUtilityType(context: ITypeScriptToSchemaContext, typeNode: ts.TypeReferenceNode): IJsonSchema | undefined;
|
|
60
86
|
/**
|
|
61
87
|
* Map SingleOccurrenceArray<T, U> to a non-empty array containing exactly one U.
|
|
88
|
+
* @param context The generation context.
|
|
89
|
+
* @param typeNode The SingleOccurrenceArray type reference.
|
|
90
|
+
* @returns The mapped schema.
|
|
62
91
|
*/
|
|
63
|
-
static mapSingleOccurrenceArrayUtilityType(context: ITypeScriptToSchemaContext, typeNode: ts.TypeReferenceNode
|
|
92
|
+
static mapSingleOccurrenceArrayUtilityType(context: ITypeScriptToSchemaContext, typeNode: ts.TypeReferenceNode): IJsonSchema | undefined;
|
|
64
93
|
/**
|
|
65
94
|
* Determine whether a type node represents null or undefined.
|
|
95
|
+
* @param typeNode The type node to inspect.
|
|
96
|
+
* @returns True if the node represents null or undefined; otherwise false.
|
|
66
97
|
*/
|
|
67
98
|
private static isNullOrUndefinedTypeNode;
|
|
68
99
|
/**
|
|
69
100
|
* Extract literal keys from a Record key type argument.
|
|
101
|
+
* @param keyTypeNode The Record key type argument to inspect.
|
|
102
|
+
* @returns The extracted literal keys.
|
|
70
103
|
*/
|
|
71
104
|
private static extractRecordLiteralKeys;
|
|
72
105
|
/**
|
|
73
106
|
* Resolve a default schema for JsonLdObject utility key additions when the type argument is omitted.
|
|
107
|
+
* @param baseSchema The base object schema being transformed.
|
|
108
|
+
* @param keyToAdd The key to add when no explicit value type argument is provided.
|
|
109
|
+
* @returns The resolved default schema for the added key.
|
|
74
110
|
*/
|
|
75
111
|
private static mapJsonLdObjectDefaultSchemaByKey;
|
|
76
112
|
/**
|
|
77
113
|
* Resolve default id schema for JsonLdObjectWithId when Id type argument is omitted.
|
|
114
|
+
* @param baseSchema The base object schema being transformed.
|
|
115
|
+
* @returns The default id schema.
|
|
78
116
|
*/
|
|
79
117
|
private static mapJsonLdObjectWithIdDefaultIdSchema;
|
|
80
118
|
/**
|
|
81
119
|
* Resolve default type schema for JsonLdObjectWithType when Type argument is omitted.
|
|
120
|
+
* @param baseSchema The base object schema being transformed.
|
|
121
|
+
* @returns The default type schema.
|
|
82
122
|
*/
|
|
83
123
|
private static mapJsonLdObjectWithTypeDefaultTypeSchema;
|
|
84
124
|
/**
|
|
85
125
|
* Resolve default context schema for JsonLdObjectWithContext when Context argument is omitted.
|
|
126
|
+
* @param baseSchema The base object schema being transformed.
|
|
127
|
+
* @returns The default context schema.
|
|
86
128
|
*/
|
|
87
129
|
private static mapJsonLdObjectWithContextDefaultContextSchema;
|
|
88
130
|
/**
|
|
89
131
|
* Resolve default schema from either of two source keys, with fallback when both are absent.
|
|
132
|
+
* @param baseSchema The base object schema being transformed.
|
|
133
|
+
* @param firstKey The first property key to check.
|
|
134
|
+
* @param secondKey The second property key to check.
|
|
135
|
+
* @param fallbackSchema The fallback schema when neither key is present.
|
|
136
|
+
* @returns The resolved schema.
|
|
90
137
|
*/
|
|
91
138
|
private static mapJsonLdObjectDefaultEitherSchema;
|
|
92
139
|
}
|
package/docs/changelog.md
CHANGED
|
@@ -1,5 +1,56 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.0.3-next.23](https://github.com/twinfoundation/tools/compare/tools-core-v0.0.3-next.22...tools-core-v0.0.3-next.23) (2026-03-20)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* improve inheritance redefinition optionality ([e7024f6](https://github.com/twinfoundation/tools/commit/e7024f699988c0b3de8315a0dbe455a13268e75d))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Dependencies
|
|
12
|
+
|
|
13
|
+
* The following workspace dependencies were updated
|
|
14
|
+
* dependencies
|
|
15
|
+
* @twin.org/tools-models bumped from 0.0.3-next.22 to 0.0.3-next.23
|
|
16
|
+
|
|
17
|
+
## [0.0.3-next.22](https://github.com/twinfoundation/tools/compare/tools-core-v0.0.3-next.21...tools-core-v0.0.3-next.22) (2026-03-20)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Features
|
|
21
|
+
|
|
22
|
+
* add context id features ([#54](https://github.com/twinfoundation/tools/issues/54)) ([41ad65d](https://github.com/twinfoundation/tools/commit/41ad65d5ae33d0533d32a2864cd94e5c35e56c76))
|
|
23
|
+
* add jsdoc default value to schema ([7886a84](https://github.com/twinfoundation/tools/commit/7886a84961e692d2054f223e2e99205a654b76a6))
|
|
24
|
+
* add jsdoc tag validation ([971b8d3](https://github.com/twinfoundation/tools/commit/971b8d3817d40467bfd7549c99af602f0c590299))
|
|
25
|
+
* add support for auto expand types ([dd1e10a](https://github.com/twinfoundation/tools/commit/dd1e10a5b2fea6f80890ff6f3971f48e239cb4c1))
|
|
26
|
+
* add validate-locales ([97bb11f](https://github.com/twinfoundation/tools/commit/97bb11fd9e6ed400e7fa69671075ba78f36ca6e6))
|
|
27
|
+
* correctly handle auto expand types ([57fce0f](https://github.com/twinfoundation/tools/commit/57fce0f9ec4a0876665d70adc6e885f6feb3caf7))
|
|
28
|
+
* eslint migration to flat config ([25acfcf](https://github.com/twinfoundation/tools/commit/25acfcf4c4e0c496fffeaf67659fe171bc15199a))
|
|
29
|
+
* improve auto expand types ([6181d1d](https://github.com/twinfoundation/tools/commit/6181d1daded1f91323195cf7efbc2f1881f38b41))
|
|
30
|
+
* improve discriminated unions ([9c36ea7](https://github.com/twinfoundation/tools/commit/9c36ea7283230089ff19085ddc4b4c30a4e3f8a2))
|
|
31
|
+
* improve type name normalisation ([1fe28e5](https://github.com/twinfoundation/tools/commit/1fe28e567593e46a41a833fbba95fe4cd958f525))
|
|
32
|
+
* remove additionalProperties ([f9b5d81](https://github.com/twinfoundation/tools/commit/f9b5d81e952468f9579593cb979f2b84db6f0dfa))
|
|
33
|
+
* remove auto expanded types from final output ([18e05dc](https://github.com/twinfoundation/tools/commit/18e05dc88f71a0a27b79d1d076b1261b42d2c4c2))
|
|
34
|
+
* tighten the types included with the regex matching ([e54909b](https://github.com/twinfoundation/tools/commit/e54909bded4a19d00560dd3ec783e9146580bda3))
|
|
35
|
+
* ts to schema ([#86](https://github.com/twinfoundation/tools/issues/86)) ([ffebda5](https://github.com/twinfoundation/tools/commit/ffebda5f14ab5ec734bf37c9fb70a7ec3d4012c3))
|
|
36
|
+
* update framework core ([559cb98](https://github.com/twinfoundation/tools/commit/559cb98612c05a05458b37462cda806b9591b18a))
|
|
37
|
+
* use jsdoc tags for json-ld markup ([1ea872e](https://github.com/twinfoundation/tools/commit/1ea872e07a1cc0e94178158a57383d64008e02e3))
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
### Bug Fixes
|
|
41
|
+
|
|
42
|
+
* additionalItems object check ([ca81668](https://github.com/twinfoundation/tools/commit/ca81668e1ee0d2b1a479215265e651932d7b76de))
|
|
43
|
+
* improve schema output ([9e53cbe](https://github.com/twinfoundation/tools/commit/9e53cbe26e6272323d72c65e277b7d24521fdbba))
|
|
44
|
+
* missing type definitions when importing relative from dynamic node_modules ([52d9fc5](https://github.com/twinfoundation/tools/commit/52d9fc5f2618a09c02b9f5dbe585b37cf60c9f20))
|
|
45
|
+
* work for schema generator spread defect ([1a705ff](https://github.com/twinfoundation/tools/commit/1a705ffc74b353f652e74ea43454164a2f6740bf))
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
### Dependencies
|
|
49
|
+
|
|
50
|
+
* The following workspace dependencies were updated
|
|
51
|
+
* dependencies
|
|
52
|
+
* @twin.org/tools-models bumped from 0.0.3-next.21 to 0.0.3-next.22
|
|
53
|
+
|
|
3
54
|
## [0.0.3-next.21](https://github.com/twinfoundation/tools/compare/tools-core-v0.0.3-next.20...tools-core-v0.0.3-next.21) (2026-03-20)
|
|
4
55
|
|
|
5
56
|
|
|
@@ -26,14 +26,20 @@ Map import type nodes (e.g. import("pkg").Type) to schema references.
|
|
|
26
26
|
|
|
27
27
|
[`ITypeScriptToSchemaContext`](../interfaces/ITypeScriptToSchemaContext.md)
|
|
28
28
|
|
|
29
|
+
The generation context.
|
|
30
|
+
|
|
29
31
|
##### typeNode
|
|
30
32
|
|
|
31
33
|
`ImportTypeNode`
|
|
32
34
|
|
|
35
|
+
The import type node.
|
|
36
|
+
|
|
33
37
|
#### Returns
|
|
34
38
|
|
|
35
39
|
`IJsonSchema` \| `undefined`
|
|
36
40
|
|
|
41
|
+
The mapped schema.
|
|
42
|
+
|
|
37
43
|
***
|
|
38
44
|
|
|
39
45
|
### mapTypeQueryNodeToSchema() {#maptypequerynodetoschema}
|
|
@@ -48,14 +54,20 @@ Map a type query node (typeof expr) to schema by resolving the referenced variab
|
|
|
48
54
|
|
|
49
55
|
[`ITypeScriptToSchemaContext`](../interfaces/ITypeScriptToSchemaContext.md)
|
|
50
56
|
|
|
57
|
+
The generation context.
|
|
58
|
+
|
|
51
59
|
##### typeNode
|
|
52
60
|
|
|
53
61
|
`TypeQueryNode`
|
|
54
62
|
|
|
63
|
+
The type query node.
|
|
64
|
+
|
|
55
65
|
#### Returns
|
|
56
66
|
|
|
57
67
|
`IJsonSchema`
|
|
58
68
|
|
|
69
|
+
The mapped schema.
|
|
70
|
+
|
|
59
71
|
***
|
|
60
72
|
|
|
61
73
|
### resolveImportTypeReferenceSchemaId() {#resolveimporttypereferenceschemaid}
|
|
@@ -70,18 +82,28 @@ Resolve import-type references to local or external schema ids.
|
|
|
70
82
|
|
|
71
83
|
[`ITypeScriptToSchemaContext`](../interfaces/ITypeScriptToSchemaContext.md)
|
|
72
84
|
|
|
85
|
+
The generation context.
|
|
86
|
+
|
|
73
87
|
##### moduleSpecifier
|
|
74
88
|
|
|
75
89
|
`string`
|
|
76
90
|
|
|
91
|
+
The import module specifier.
|
|
92
|
+
|
|
77
93
|
##### typeName
|
|
78
94
|
|
|
79
95
|
`string`
|
|
80
96
|
|
|
97
|
+
The imported type name.
|
|
98
|
+
|
|
81
99
|
##### title
|
|
82
100
|
|
|
83
101
|
`string`
|
|
84
102
|
|
|
103
|
+
The stripped schema title.
|
|
104
|
+
|
|
85
105
|
#### Returns
|
|
86
106
|
|
|
87
107
|
`string` \| `undefined`
|
|
108
|
+
|
|
109
|
+
The resolved schema id.
|