@twin.org/tools-core 0.0.2-next.3 → 0.0.2-next.5
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/cjs/index.cjs
CHANGED
|
@@ -5,7 +5,7 @@ var core = require('@twin.org/core');
|
|
|
5
5
|
// Copyright 2024 IOTA Stiftung.
|
|
6
6
|
// SPDX-License-Identifier: Apache-2.0.
|
|
7
7
|
/**
|
|
8
|
-
* Helper class for JSON Schema processing.
|
|
8
|
+
* Helper class for JSON Schema processing.
|
|
9
9
|
*/
|
|
10
10
|
class JsonSchemaHelper {
|
|
11
11
|
/**
|
|
@@ -152,8 +152,10 @@ class JsonSchemaHelper {
|
|
|
152
152
|
for (const typeKey of Object.keys(allSchemas)) {
|
|
153
153
|
if (!referencedSchemas[typeKey]) {
|
|
154
154
|
for (const requiredType of requiredTypes) {
|
|
155
|
-
|
|
156
|
-
(
|
|
155
|
+
const regex = requiredType.startsWith("/") && requiredType.endsWith("/")
|
|
156
|
+
? new RegExp(requiredType.slice(1, -1))
|
|
157
|
+
: new RegExp(requiredType);
|
|
158
|
+
if (regex.test(typeKey)) {
|
|
157
159
|
referencedSchemas[typeKey] = allSchemas[typeKey];
|
|
158
160
|
JsonSchemaHelper.extractTypesFromSchema(allSchemas, allSchemas[typeKey], referencedSchemas);
|
|
159
161
|
}
|
|
@@ -182,7 +184,10 @@ class JsonSchemaHelper {
|
|
|
182
184
|
if (core.Is.stringValue(schema.$ref)) {
|
|
183
185
|
for (const expandedType of expandedTypes) {
|
|
184
186
|
const typeName = JsonSchemaHelper.normaliseTypeName(schema.$ref.replace("#/definitions/", ""));
|
|
185
|
-
|
|
187
|
+
const regex = expandedType.startsWith("/") && expandedType.endsWith("/")
|
|
188
|
+
? new RegExp(expandedType.slice(1, -1))
|
|
189
|
+
: new RegExp(expandedType);
|
|
190
|
+
if (regex.test(typeName) && allSchemas[typeName]) {
|
|
186
191
|
delete schema.$ref;
|
|
187
192
|
Object.assign(schema, allSchemas[typeName]);
|
|
188
193
|
break;
|
package/dist/esm/index.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { Is, ArrayHelper } from '@twin.org/core';
|
|
|
3
3
|
// Copyright 2024 IOTA Stiftung.
|
|
4
4
|
// SPDX-License-Identifier: Apache-2.0.
|
|
5
5
|
/**
|
|
6
|
-
* Helper class for JSON Schema processing.
|
|
6
|
+
* Helper class for JSON Schema processing.
|
|
7
7
|
*/
|
|
8
8
|
class JsonSchemaHelper {
|
|
9
9
|
/**
|
|
@@ -150,8 +150,10 @@ class JsonSchemaHelper {
|
|
|
150
150
|
for (const typeKey of Object.keys(allSchemas)) {
|
|
151
151
|
if (!referencedSchemas[typeKey]) {
|
|
152
152
|
for (const requiredType of requiredTypes) {
|
|
153
|
-
|
|
154
|
-
(
|
|
153
|
+
const regex = requiredType.startsWith("/") && requiredType.endsWith("/")
|
|
154
|
+
? new RegExp(requiredType.slice(1, -1))
|
|
155
|
+
: new RegExp(requiredType);
|
|
156
|
+
if (regex.test(typeKey)) {
|
|
155
157
|
referencedSchemas[typeKey] = allSchemas[typeKey];
|
|
156
158
|
JsonSchemaHelper.extractTypesFromSchema(allSchemas, allSchemas[typeKey], referencedSchemas);
|
|
157
159
|
}
|
|
@@ -180,7 +182,10 @@ class JsonSchemaHelper {
|
|
|
180
182
|
if (Is.stringValue(schema.$ref)) {
|
|
181
183
|
for (const expandedType of expandedTypes) {
|
|
182
184
|
const typeName = JsonSchemaHelper.normaliseTypeName(schema.$ref.replace("#/definitions/", ""));
|
|
183
|
-
|
|
185
|
+
const regex = expandedType.startsWith("/") && expandedType.endsWith("/")
|
|
186
|
+
? new RegExp(expandedType.slice(1, -1))
|
|
187
|
+
: new RegExp(expandedType);
|
|
188
|
+
if (regex.test(typeName) && allSchemas[typeName]) {
|
|
184
189
|
delete schema.$ref;
|
|
185
190
|
Object.assign(schema, allSchemas[typeName]);
|
|
186
191
|
break;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { IJsonSchema } from "../models/IJsonSchema";
|
|
2
2
|
/**
|
|
3
|
-
* Helper class for JSON Schema processing.
|
|
3
|
+
* Helper class for JSON Schema processing.
|
|
4
4
|
*/
|
|
5
5
|
export declare class JsonSchemaHelper {
|
|
6
6
|
/**
|
|
@@ -49,7 +49,7 @@ export declare class JsonSchemaHelper {
|
|
|
49
49
|
*/
|
|
50
50
|
static extractTypes(allSchemas: {
|
|
51
51
|
[id: string]: IJsonSchema;
|
|
52
|
-
}, requiredTypes:
|
|
52
|
+
}, requiredTypes: string[], referencedSchemas: {
|
|
53
53
|
[id: string]: IJsonSchema;
|
|
54
54
|
}): void;
|
|
55
55
|
/**
|
package/docs/changelog.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.0.2-next.5](https://github.com/twinfoundation/tools/compare/tools-core-v0.0.2-next.4...tools-core-v0.0.2-next.5) (2025-08-19)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* correctly handle auto expand types ([57fce0f](https://github.com/twinfoundation/tools/commit/57fce0f9ec4a0876665d70adc6e885f6feb3caf7))
|
|
9
|
+
|
|
10
|
+
## [0.0.2-next.4](https://github.com/twinfoundation/tools/compare/tools-core-v0.0.2-next.3...tools-core-v0.0.2-next.4) (2025-08-19)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
* update framework core ([559cb98](https://github.com/twinfoundation/tools/commit/559cb98612c05a05458b37462cda806b9591b18a))
|
|
16
|
+
|
|
3
17
|
## [0.0.2-next.3](https://github.com/twinfoundation/tools/compare/tools-core-v0.0.2-next.2...tools-core-v0.0.2-next.3) (2025-08-05)
|
|
4
18
|
|
|
5
19
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Class: JsonSchemaHelper
|
|
2
2
|
|
|
3
|
-
Helper class for JSON Schema processing.
|
|
3
|
+
Helper class for JSON Schema processing.
|
|
4
4
|
|
|
5
5
|
## Constructors
|
|
6
6
|
|
|
@@ -144,7 +144,7 @@ All the known schemas.
|
|
|
144
144
|
|
|
145
145
|
##### requiredTypes
|
|
146
146
|
|
|
147
|
-
|
|
147
|
+
`string`[]
|
|
148
148
|
|
|
149
149
|
The required types.
|
|
150
150
|
|