@twin.org/tools-core 0.0.3-next.25 → 0.0.3-next.26
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/index.js +3 -2
- package/dist/es/index.js.map +1 -1
- package/dist/es/models/ITypeScriptToSchemaContext.js.map +1 -1
- package/dist/es/models/embeddedSchemaMode.js +17 -0
- package/dist/es/models/embeddedSchemaMode.js.map +1 -0
- package/dist/es/utils/importTypeQuerySchemaResolver.js +1 -0
- 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 +35 -10
- package/dist/es/utils/jsonSchemaBuilder.js.map +1 -1
- package/dist/es/utils/typeScriptToSchema.js +208 -1
- package/dist/es/utils/typeScriptToSchema.js.map +1 -1
- package/dist/es/utils/utilityTypeSchemaMapper.js +21 -21
- package/dist/es/utils/utilityTypeSchemaMapper.js.map +1 -1
- package/dist/types/index.d.ts +3 -2
- package/dist/types/models/ITypeScriptToSchemaContext.d.ts +7 -0
- package/dist/types/models/embeddedSchemaMode.d.ts +17 -0
- package/dist/types/utils/jsDoc.d.ts +1 -1
- package/dist/types/utils/typeScriptToSchema.d.ts +61 -0
- package/dist/types/utils/utilityTypeSchemaMapper.d.ts +21 -21
- package/docs/changelog.md +14 -0
- package/docs/reference/classes/JsDoc.md +1 -1
- package/docs/reference/classes/UtilityTypeSchemaMapper.md +21 -21
- package/docs/reference/index.md +8 -0
- package/docs/reference/interfaces/ITypeScriptToSchemaContext.md +12 -0
- package/docs/reference/type-aliases/EmbeddedSchemaMode.md +5 -0
- package/docs/reference/variables/EmbeddedSchemaMode.md +19 -0
- package/package.json +2 -2
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { IJsonSchema } from "@twin.org/tools-models";
|
|
2
2
|
import type * as ts from "typescript";
|
|
3
|
+
import type { EmbeddedSchemaMode } from "./embeddedSchemaMode.js";
|
|
3
4
|
import type { ITypeScriptToSchemaOptions } from "./ITypeScriptToSchemaOptions.js";
|
|
4
5
|
/**
|
|
5
6
|
* Context for TypeScript to JSON schema generation.
|
|
@@ -57,6 +58,12 @@ export interface ITypeScriptToSchemaContext {
|
|
|
57
58
|
typeParameterBindings?: {
|
|
58
59
|
[id: string]: ts.TypeNode | null;
|
|
59
60
|
};
|
|
61
|
+
/**
|
|
62
|
+
* Schema ids marked with @json-schema embedded and their embedding mode.
|
|
63
|
+
*/
|
|
64
|
+
embeddedSchemaModes?: {
|
|
65
|
+
[id: string]: EmbeddedSchemaMode;
|
|
66
|
+
};
|
|
60
67
|
/**
|
|
61
68
|
* Optional schema generation options.
|
|
62
69
|
*/
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The available embedded schema modes.
|
|
3
|
+
*/
|
|
4
|
+
export declare const EmbeddedSchemaMode: {
|
|
5
|
+
/**
|
|
6
|
+
* Referenced schemas are added to the "defs" section of the root schema.
|
|
7
|
+
*/
|
|
8
|
+
readonly Defs: "defs";
|
|
9
|
+
/**
|
|
10
|
+
* Referenced schemas are inlined into the referencing schema.
|
|
11
|
+
*/
|
|
12
|
+
readonly Inline: "inline";
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* The embedded schema mode value type.
|
|
16
|
+
*/
|
|
17
|
+
export type EmbeddedSchemaMode = (typeof EmbeddedSchemaMode)[keyof typeof EmbeddedSchemaMode];
|
|
@@ -37,7 +37,7 @@ export declare class JsDoc {
|
|
|
37
37
|
static getNodeTagComment(node: ts.Node, tagName: string): string | undefined;
|
|
38
38
|
/**
|
|
39
39
|
* Parse a custom JSDoc tag value into JSON-compatible data.
|
|
40
|
-
* Values that begin with a JSON token character (
|
|
40
|
+
* Values that begin with a JSON token character (open brace, open bracket, double quote, true, false, null) or look like a
|
|
41
41
|
* number are parsed with JSON.parse. All other values are returned as plain strings.
|
|
42
42
|
* @param value The raw value text.
|
|
43
43
|
* @returns The parsed value.
|
|
@@ -28,4 +28,65 @@ export declare class TypeScriptToSchema {
|
|
|
28
28
|
* @returns True if the diagnostic originated from the package.
|
|
29
29
|
*/
|
|
30
30
|
isDiagnosticFromPackage(path: string, fileName: string | undefined, packageName: string): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Rewrite refs to @json-schema embedded local types into the current schema's $defs.
|
|
33
|
+
* @param context The generation context.
|
|
34
|
+
* @param schema The root schema to rewrite.
|
|
35
|
+
* @param rootTitle The title of the root schema.
|
|
36
|
+
*/
|
|
37
|
+
private inlineEmbeddedSchemas;
|
|
38
|
+
/**
|
|
39
|
+
* Traverse a schema tree and move embedded local refs into the root schema's $defs.
|
|
40
|
+
* @param context The generation context.
|
|
41
|
+
* @param rootSchema The root schema document being rewritten.
|
|
42
|
+
* @param currentNode The current schema node.
|
|
43
|
+
* @param rootTitle The title of the root schema.
|
|
44
|
+
* @param ancestry Titles currently being expanded to avoid recursion cycles.
|
|
45
|
+
* @returns True if inline embedding changed this node or a descendant.
|
|
46
|
+
*/
|
|
47
|
+
private inlineEmbeddedSchemasInNode;
|
|
48
|
+
/**
|
|
49
|
+
* Flatten inline-expanded object allOf branches into the containing schema.
|
|
50
|
+
* @param schema The schema to flatten.
|
|
51
|
+
*/
|
|
52
|
+
private flattenInlineAllOfBranches;
|
|
53
|
+
/**
|
|
54
|
+
* Determine whether an allOf branch can be flattened into its parent after inline embedding.
|
|
55
|
+
* @param branch The allOf branch.
|
|
56
|
+
* @returns True if the branch is a plain object schema.
|
|
57
|
+
*/
|
|
58
|
+
private canFlattenInlineAllOfBranch;
|
|
59
|
+
/**
|
|
60
|
+
* Create a clone of an embedded schema suitable for defs or inline expansion.
|
|
61
|
+
* @param context The generation context.
|
|
62
|
+
* @param embeddedSchema The source schema.
|
|
63
|
+
* @param embeddedMode The embedding mode.
|
|
64
|
+
* @returns The cloned schema.
|
|
65
|
+
*/
|
|
66
|
+
private createEmbeddedSchemaClone;
|
|
67
|
+
/**
|
|
68
|
+
* Replace the contents of a schema node while keeping the same object reference.
|
|
69
|
+
* @param target The schema node to mutate.
|
|
70
|
+
* @param replacement The replacement content.
|
|
71
|
+
*/
|
|
72
|
+
private replaceSchemaNode;
|
|
73
|
+
/**
|
|
74
|
+
* Find a generated schema by its canonical id across all loaded packages.
|
|
75
|
+
* @param context The generation context.
|
|
76
|
+
* @param schemaId The schema id to locate.
|
|
77
|
+
* @returns The schema when found.
|
|
78
|
+
*/
|
|
79
|
+
private findSchemaById;
|
|
80
|
+
/**
|
|
81
|
+
* Resolve the local $defs key to use for an embedded schema.
|
|
82
|
+
* @param schema The embedded schema.
|
|
83
|
+
* @param schemaId The canonical schema id.
|
|
84
|
+
* @returns The local definition key.
|
|
85
|
+
*/
|
|
86
|
+
private getEmbeddedDefinitionKey;
|
|
87
|
+
/**
|
|
88
|
+
* Remove $comment fields from a schema tree.
|
|
89
|
+
* @param schema The schema tree to clean.
|
|
90
|
+
*/
|
|
91
|
+
private removeSchemaComments;
|
|
31
92
|
}
|
|
@@ -6,65 +6,65 @@ import type { ITypeScriptToSchemaContext } from "../models/ITypeScriptToSchemaCo
|
|
|
6
6
|
*/
|
|
7
7
|
export declare class UtilityTypeSchemaMapper {
|
|
8
8
|
/**
|
|
9
|
-
* Map Partial<T
|
|
9
|
+
* Map `Partial<T>` to an object schema with no required properties.
|
|
10
10
|
* @param context The generation context.
|
|
11
|
-
* @param typeNode The Partial type reference.
|
|
11
|
+
* @param typeNode The `Partial` type reference.
|
|
12
12
|
* @returns The mapped schema.
|
|
13
13
|
*/
|
|
14
14
|
static mapPartialUtilityType(context: ITypeScriptToSchemaContext, typeNode: ts.TypeReferenceNode): IJsonSchema | undefined;
|
|
15
15
|
/**
|
|
16
|
-
* Map Required<T
|
|
16
|
+
* Map `Required<T>` to an object schema with all properties required.
|
|
17
17
|
* @param context The generation context.
|
|
18
|
-
* @param typeNode The Required type reference.
|
|
18
|
+
* @param typeNode The `Required` type reference.
|
|
19
19
|
* @returns The mapped schema.
|
|
20
20
|
*/
|
|
21
21
|
static mapRequiredUtilityType(context: ITypeScriptToSchemaContext, typeNode: ts.TypeReferenceNode): IJsonSchema | undefined;
|
|
22
22
|
/**
|
|
23
|
-
* Map Pick<T, K
|
|
23
|
+
* Map `Pick<T, K>` to an object schema with selected keys preserved.
|
|
24
24
|
* @param context The generation context.
|
|
25
25
|
* @param typeNode The Pick type reference.
|
|
26
26
|
* @returns The mapped schema.
|
|
27
27
|
*/
|
|
28
28
|
static mapPickUtilityType(context: ITypeScriptToSchemaContext, typeNode: ts.TypeReferenceNode): IJsonSchema | undefined;
|
|
29
29
|
/**
|
|
30
|
-
* Map Omit<T, K
|
|
30
|
+
* Map `Omit<T, K>` to an object schema with selected keys removed.
|
|
31
31
|
* @param context The generation context.
|
|
32
|
-
* @param typeNode The Omit type reference.
|
|
32
|
+
* @param typeNode The `Omit` type reference.
|
|
33
33
|
* @returns The mapped schema.
|
|
34
34
|
*/
|
|
35
35
|
static mapOmitUtilityType(context: ITypeScriptToSchemaContext, typeNode: ts.TypeReferenceNode): IJsonSchema | undefined;
|
|
36
36
|
/**
|
|
37
|
-
* Map Exclude<T, U
|
|
37
|
+
* Map `Exclude<T, U>` to a schema that removes `U` members from `T`.
|
|
38
38
|
* @param context The generation context.
|
|
39
|
-
* @param typeNode The Exclude type reference.
|
|
39
|
+
* @param typeNode The `Exclude` type reference.
|
|
40
40
|
* @returns The mapped schema.
|
|
41
41
|
*/
|
|
42
42
|
static mapExcludeUtilityType(context: ITypeScriptToSchemaContext, typeNode: ts.TypeReferenceNode): IJsonSchema | undefined;
|
|
43
43
|
/**
|
|
44
|
-
* Map Extract<T, U
|
|
44
|
+
* Map `Extract<T, U>` to a schema that keeps `U` members from `T`.
|
|
45
45
|
* @param context The generation context.
|
|
46
|
-
* @param typeNode The Extract type reference.
|
|
46
|
+
* @param typeNode The `Extract` type reference.
|
|
47
47
|
* @returns The mapped schema.
|
|
48
48
|
*/
|
|
49
49
|
static mapExtractUtilityType(context: ITypeScriptToSchemaContext, typeNode: ts.TypeReferenceNode): IJsonSchema | undefined;
|
|
50
50
|
/**
|
|
51
|
-
* Map NonNullable<T
|
|
51
|
+
* Map `NonNullable<T>` by removing `null` and `undefined` branches from `T`.
|
|
52
52
|
* @param context The generation context.
|
|
53
|
-
* @param typeNode The NonNullable type reference.
|
|
53
|
+
* @param typeNode The `NonNullable` type reference.
|
|
54
54
|
* @returns The mapped schema.
|
|
55
55
|
*/
|
|
56
56
|
static mapNonNullableUtilityType(context: ITypeScriptToSchemaContext, typeNode: ts.TypeReferenceNode): IJsonSchema | undefined;
|
|
57
57
|
/**
|
|
58
|
-
* Map Record<K, V
|
|
58
|
+
* Map `Record<K, V>` to an object schema with key constraints where possible.
|
|
59
59
|
* @param context The generation context.
|
|
60
|
-
* @param typeNode The Record type reference.
|
|
60
|
+
* @param typeNode The `Record` type reference.
|
|
61
61
|
* @returns The mapped schema.
|
|
62
62
|
*/
|
|
63
63
|
static mapRecordUtilityType(context: ITypeScriptToSchemaContext, typeNode: ts.TypeReferenceNode): IJsonSchema | undefined;
|
|
64
64
|
/**
|
|
65
|
-
* Map JsonLdObject utility types using key-removal and optional key-addition rules.
|
|
65
|
+
* Map `JsonLdObject` utility types using key-removal and optional key-addition rules.
|
|
66
66
|
* @param context The generation context.
|
|
67
|
-
* @param typeNode The JsonLdObject utility type reference.
|
|
67
|
+
* @param typeNode The `JsonLdObject` utility type reference.
|
|
68
68
|
* @param options The mapping options for key removal and optional key addition.
|
|
69
69
|
* @param options.keysToRemove The property keys to remove from the base schema.
|
|
70
70
|
* @param options.keyToAdd The optional key to add after removal.
|
|
@@ -77,16 +77,16 @@ export declare class UtilityTypeSchemaMapper {
|
|
|
77
77
|
isAddedKeyRequired?: boolean;
|
|
78
78
|
}): IJsonSchema | undefined;
|
|
79
79
|
/**
|
|
80
|
-
* Map ObjectOrArray<T
|
|
80
|
+
* Map `ObjectOrArray<T>` to a schema accepting `T` or `T[]`.
|
|
81
81
|
* @param context The generation context.
|
|
82
|
-
* @param typeNode The ObjectOrArray type reference.
|
|
82
|
+
* @param typeNode The `ObjectOrArray` type reference.
|
|
83
83
|
* @returns The mapped schema.
|
|
84
84
|
*/
|
|
85
85
|
static mapObjectOrArrayUtilityType(context: ITypeScriptToSchemaContext, typeNode: ts.TypeReferenceNode): IJsonSchema | undefined;
|
|
86
86
|
/**
|
|
87
|
-
* Map SingleOccurrenceArray<T, U
|
|
87
|
+
* Map `SingleOccurrenceArray<T, U>` to a non-empty array containing exactly one `U`.
|
|
88
88
|
* @param context The generation context.
|
|
89
|
-
* @param typeNode The SingleOccurrenceArray type reference.
|
|
89
|
+
* @param typeNode The `SingleOccurrenceArray` type reference.
|
|
90
90
|
* @returns The mapped schema.
|
|
91
91
|
*/
|
|
92
92
|
static mapSingleOccurrenceArrayUtilityType(context: ITypeScriptToSchemaContext, typeNode: ts.TypeReferenceNode): IJsonSchema | undefined;
|
package/docs/changelog.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.0.3-next.26](https://github.com/twinfoundation/tools/compare/tools-core-v0.0.3-next.25...tools-core-v0.0.3-next.26) (2026-03-27)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* add json-schema embedded mode ([#102](https://github.com/twinfoundation/tools/issues/102)) ([f070967](https://github.com/twinfoundation/tools/commit/f070967f8f3308e0b5320eab278a319c9d229e3e))
|
|
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.25 to 0.0.3-next.26
|
|
16
|
+
|
|
3
17
|
## [0.0.3-next.25](https://github.com/twinfoundation/tools/compare/tools-core-v0.0.3-next.24...tools-core-v0.0.3-next.25) (2026-03-23)
|
|
4
18
|
|
|
5
19
|
|
|
@@ -123,7 +123,7 @@ The trimmed comment text, or undefined when absent.
|
|
|
123
123
|
> `static` **parseTagValue**(`value`): `unknown`
|
|
124
124
|
|
|
125
125
|
Parse a custom JSDoc tag value into JSON-compatible data.
|
|
126
|
-
Values that begin with a JSON token character (
|
|
126
|
+
Values that begin with a JSON token character (open brace, open bracket, double quote, true, false, null) or look like a
|
|
127
127
|
number are parsed with JSON.parse. All other values are returned as plain strings.
|
|
128
128
|
|
|
129
129
|
#### Parameters
|
|
@@ -18,7 +18,7 @@ Static utility-type schema mapping helpers.
|
|
|
18
18
|
|
|
19
19
|
> `static` **mapPartialUtilityType**(`context`, `typeNode`): `IJsonSchema` \| `undefined`
|
|
20
20
|
|
|
21
|
-
Map Partial<T
|
|
21
|
+
Map `Partial<T>` to an object schema with no required properties.
|
|
22
22
|
|
|
23
23
|
#### Parameters
|
|
24
24
|
|
|
@@ -32,7 +32,7 @@ The generation context.
|
|
|
32
32
|
|
|
33
33
|
`TypeReferenceNode`
|
|
34
34
|
|
|
35
|
-
The Partial type reference.
|
|
35
|
+
The `Partial` type reference.
|
|
36
36
|
|
|
37
37
|
#### Returns
|
|
38
38
|
|
|
@@ -46,7 +46,7 @@ The mapped schema.
|
|
|
46
46
|
|
|
47
47
|
> `static` **mapRequiredUtilityType**(`context`, `typeNode`): `IJsonSchema` \| `undefined`
|
|
48
48
|
|
|
49
|
-
Map Required<T
|
|
49
|
+
Map `Required<T>` to an object schema with all properties required.
|
|
50
50
|
|
|
51
51
|
#### Parameters
|
|
52
52
|
|
|
@@ -60,7 +60,7 @@ The generation context.
|
|
|
60
60
|
|
|
61
61
|
`TypeReferenceNode`
|
|
62
62
|
|
|
63
|
-
The Required type reference.
|
|
63
|
+
The `Required` type reference.
|
|
64
64
|
|
|
65
65
|
#### Returns
|
|
66
66
|
|
|
@@ -74,7 +74,7 @@ The mapped schema.
|
|
|
74
74
|
|
|
75
75
|
> `static` **mapPickUtilityType**(`context`, `typeNode`): `IJsonSchema` \| `undefined`
|
|
76
76
|
|
|
77
|
-
Map Pick<T, K
|
|
77
|
+
Map `Pick<T, K>` to an object schema with selected keys preserved.
|
|
78
78
|
|
|
79
79
|
#### Parameters
|
|
80
80
|
|
|
@@ -102,7 +102,7 @@ The mapped schema.
|
|
|
102
102
|
|
|
103
103
|
> `static` **mapOmitUtilityType**(`context`, `typeNode`): `IJsonSchema` \| `undefined`
|
|
104
104
|
|
|
105
|
-
Map Omit<T, K
|
|
105
|
+
Map `Omit<T, K>` to an object schema with selected keys removed.
|
|
106
106
|
|
|
107
107
|
#### Parameters
|
|
108
108
|
|
|
@@ -116,7 +116,7 @@ The generation context.
|
|
|
116
116
|
|
|
117
117
|
`TypeReferenceNode`
|
|
118
118
|
|
|
119
|
-
The Omit type reference.
|
|
119
|
+
The `Omit` type reference.
|
|
120
120
|
|
|
121
121
|
#### Returns
|
|
122
122
|
|
|
@@ -130,7 +130,7 @@ The mapped schema.
|
|
|
130
130
|
|
|
131
131
|
> `static` **mapExcludeUtilityType**(`context`, `typeNode`): `IJsonSchema` \| `undefined`
|
|
132
132
|
|
|
133
|
-
Map Exclude<T, U
|
|
133
|
+
Map `Exclude<T, U>` to a schema that removes `U` members from `T`.
|
|
134
134
|
|
|
135
135
|
#### Parameters
|
|
136
136
|
|
|
@@ -144,7 +144,7 @@ The generation context.
|
|
|
144
144
|
|
|
145
145
|
`TypeReferenceNode`
|
|
146
146
|
|
|
147
|
-
The Exclude type reference.
|
|
147
|
+
The `Exclude` type reference.
|
|
148
148
|
|
|
149
149
|
#### Returns
|
|
150
150
|
|
|
@@ -158,7 +158,7 @@ The mapped schema.
|
|
|
158
158
|
|
|
159
159
|
> `static` **mapExtractUtilityType**(`context`, `typeNode`): `IJsonSchema` \| `undefined`
|
|
160
160
|
|
|
161
|
-
Map Extract<T, U
|
|
161
|
+
Map `Extract<T, U>` to a schema that keeps `U` members from `T`.
|
|
162
162
|
|
|
163
163
|
#### Parameters
|
|
164
164
|
|
|
@@ -172,7 +172,7 @@ The generation context.
|
|
|
172
172
|
|
|
173
173
|
`TypeReferenceNode`
|
|
174
174
|
|
|
175
|
-
The Extract type reference.
|
|
175
|
+
The `Extract` type reference.
|
|
176
176
|
|
|
177
177
|
#### Returns
|
|
178
178
|
|
|
@@ -186,7 +186,7 @@ The mapped schema.
|
|
|
186
186
|
|
|
187
187
|
> `static` **mapNonNullableUtilityType**(`context`, `typeNode`): `IJsonSchema` \| `undefined`
|
|
188
188
|
|
|
189
|
-
Map NonNullable<T
|
|
189
|
+
Map `NonNullable<T>` by removing `null` and `undefined` branches from `T`.
|
|
190
190
|
|
|
191
191
|
#### Parameters
|
|
192
192
|
|
|
@@ -200,7 +200,7 @@ The generation context.
|
|
|
200
200
|
|
|
201
201
|
`TypeReferenceNode`
|
|
202
202
|
|
|
203
|
-
The NonNullable type reference.
|
|
203
|
+
The `NonNullable` type reference.
|
|
204
204
|
|
|
205
205
|
#### Returns
|
|
206
206
|
|
|
@@ -214,7 +214,7 @@ The mapped schema.
|
|
|
214
214
|
|
|
215
215
|
> `static` **mapRecordUtilityType**(`context`, `typeNode`): `IJsonSchema` \| `undefined`
|
|
216
216
|
|
|
217
|
-
Map Record<K, V
|
|
217
|
+
Map `Record<K, V>` to an object schema with key constraints where possible.
|
|
218
218
|
|
|
219
219
|
#### Parameters
|
|
220
220
|
|
|
@@ -228,7 +228,7 @@ The generation context.
|
|
|
228
228
|
|
|
229
229
|
`TypeReferenceNode`
|
|
230
230
|
|
|
231
|
-
The Record type reference.
|
|
231
|
+
The `Record` type reference.
|
|
232
232
|
|
|
233
233
|
#### Returns
|
|
234
234
|
|
|
@@ -242,7 +242,7 @@ The mapped schema.
|
|
|
242
242
|
|
|
243
243
|
> `static` **mapJsonLdObjectUtilityType**(`context`, `typeNode`, `options`): `IJsonSchema` \| `undefined`
|
|
244
244
|
|
|
245
|
-
Map JsonLdObject utility types using key-removal and optional key-addition rules.
|
|
245
|
+
Map `JsonLdObject` utility types using key-removal and optional key-addition rules.
|
|
246
246
|
|
|
247
247
|
#### Parameters
|
|
248
248
|
|
|
@@ -256,7 +256,7 @@ The generation context.
|
|
|
256
256
|
|
|
257
257
|
`TypeReferenceNode`
|
|
258
258
|
|
|
259
|
-
The JsonLdObject utility type reference.
|
|
259
|
+
The `JsonLdObject` utility type reference.
|
|
260
260
|
|
|
261
261
|
##### options
|
|
262
262
|
|
|
@@ -292,7 +292,7 @@ The mapped schema.
|
|
|
292
292
|
|
|
293
293
|
> `static` **mapObjectOrArrayUtilityType**(`context`, `typeNode`): `IJsonSchema` \| `undefined`
|
|
294
294
|
|
|
295
|
-
Map ObjectOrArray<T
|
|
295
|
+
Map `ObjectOrArray<T>` to a schema accepting `T` or `T[]`.
|
|
296
296
|
|
|
297
297
|
#### Parameters
|
|
298
298
|
|
|
@@ -306,7 +306,7 @@ The generation context.
|
|
|
306
306
|
|
|
307
307
|
`TypeReferenceNode`
|
|
308
308
|
|
|
309
|
-
The ObjectOrArray type reference.
|
|
309
|
+
The `ObjectOrArray` type reference.
|
|
310
310
|
|
|
311
311
|
#### Returns
|
|
312
312
|
|
|
@@ -320,7 +320,7 @@ The mapped schema.
|
|
|
320
320
|
|
|
321
321
|
> `static` **mapSingleOccurrenceArrayUtilityType**(`context`, `typeNode`): `IJsonSchema` \| `undefined`
|
|
322
322
|
|
|
323
|
-
Map SingleOccurrenceArray<T, U
|
|
323
|
+
Map `SingleOccurrenceArray<T, U>` to a non-empty array containing exactly one `U`.
|
|
324
324
|
|
|
325
325
|
#### Parameters
|
|
326
326
|
|
|
@@ -334,7 +334,7 @@ The generation context.
|
|
|
334
334
|
|
|
335
335
|
`TypeReferenceNode`
|
|
336
336
|
|
|
337
|
-
The SingleOccurrenceArray type reference.
|
|
337
|
+
The `SingleOccurrenceArray` type reference.
|
|
338
338
|
|
|
339
339
|
#### Returns
|
|
340
340
|
|
package/docs/reference/index.md
CHANGED
|
@@ -25,3 +25,11 @@
|
|
|
25
25
|
- [ITypeScriptToSchemaContext](interfaces/ITypeScriptToSchemaContext.md)
|
|
26
26
|
- [ITypeScriptToSchemaDiagnostics](interfaces/ITypeScriptToSchemaDiagnostics.md)
|
|
27
27
|
- [ITypeScriptToSchemaOptions](interfaces/ITypeScriptToSchemaOptions.md)
|
|
28
|
+
|
|
29
|
+
## Type Aliases
|
|
30
|
+
|
|
31
|
+
- [EmbeddedSchemaMode](type-aliases/EmbeddedSchemaMode.md)
|
|
32
|
+
|
|
33
|
+
## Variables
|
|
34
|
+
|
|
35
|
+
- [EmbeddedSchemaMode](variables/EmbeddedSchemaMode.md)
|
|
@@ -106,6 +106,18 @@ Generic type parameter bindings active for the current mapping scope.
|
|
|
106
106
|
|
|
107
107
|
***
|
|
108
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
|
+
|
|
109
121
|
### options? {#options}
|
|
110
122
|
|
|
111
123
|
> `optional` **options?**: [`ITypeScriptToSchemaOptions`](ITypeScriptToSchemaOptions.md)
|
|
@@ -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/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.26",
|
|
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.26",
|
|
20
20
|
"glob": "13.0.6"
|
|
21
21
|
},
|
|
22
22
|
"main": "./dist/es/index.js",
|