@twin.org/tools-core 0.0.2-next.5 → 0.0.2-next.6
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
|
@@ -184,9 +184,7 @@ class JsonSchemaHelper {
|
|
|
184
184
|
if (core.Is.stringValue(schema.$ref)) {
|
|
185
185
|
for (const expandedType of expandedTypes) {
|
|
186
186
|
const typeName = JsonSchemaHelper.normaliseTypeName(schema.$ref.replace("#/definitions/", ""));
|
|
187
|
-
const regex =
|
|
188
|
-
? new RegExp(expandedType.slice(1, -1))
|
|
189
|
-
: new RegExp(expandedType);
|
|
187
|
+
const regex = JsonSchemaHelper.autoExpandToRegEx(expandedType);
|
|
190
188
|
if (regex.test(typeName) && allSchemas[typeName]) {
|
|
191
189
|
delete schema.$ref;
|
|
192
190
|
Object.assign(schema, allSchemas[typeName]);
|
|
@@ -232,6 +230,16 @@ class JsonSchemaHelper {
|
|
|
232
230
|
}
|
|
233
231
|
}
|
|
234
232
|
}
|
|
233
|
+
/**
|
|
234
|
+
* Convert a string auto expand pattern to a regular expression.
|
|
235
|
+
* @param autoExpand The auto expand pattern.
|
|
236
|
+
* @returns The regular expression.
|
|
237
|
+
*/
|
|
238
|
+
static autoExpandToRegEx(autoExpand) {
|
|
239
|
+
return autoExpand.startsWith("/") && autoExpand.endsWith("/")
|
|
240
|
+
? new RegExp(autoExpand.slice(1, -1))
|
|
241
|
+
: new RegExp(autoExpand);
|
|
242
|
+
}
|
|
235
243
|
}
|
|
236
244
|
|
|
237
245
|
// Copyright 2024 IOTA Stiftung.
|
package/dist/esm/index.mjs
CHANGED
|
@@ -182,9 +182,7 @@ class JsonSchemaHelper {
|
|
|
182
182
|
if (Is.stringValue(schema.$ref)) {
|
|
183
183
|
for (const expandedType of expandedTypes) {
|
|
184
184
|
const typeName = JsonSchemaHelper.normaliseTypeName(schema.$ref.replace("#/definitions/", ""));
|
|
185
|
-
const regex =
|
|
186
|
-
? new RegExp(expandedType.slice(1, -1))
|
|
187
|
-
: new RegExp(expandedType);
|
|
185
|
+
const regex = JsonSchemaHelper.autoExpandToRegEx(expandedType);
|
|
188
186
|
if (regex.test(typeName) && allSchemas[typeName]) {
|
|
189
187
|
delete schema.$ref;
|
|
190
188
|
Object.assign(schema, allSchemas[typeName]);
|
|
@@ -230,6 +228,16 @@ class JsonSchemaHelper {
|
|
|
230
228
|
}
|
|
231
229
|
}
|
|
232
230
|
}
|
|
231
|
+
/**
|
|
232
|
+
* Convert a string auto expand pattern to a regular expression.
|
|
233
|
+
* @param autoExpand The auto expand pattern.
|
|
234
|
+
* @returns The regular expression.
|
|
235
|
+
*/
|
|
236
|
+
static autoExpandToRegEx(autoExpand) {
|
|
237
|
+
return autoExpand.startsWith("/") && autoExpand.endsWith("/")
|
|
238
|
+
? new RegExp(autoExpand.slice(1, -1))
|
|
239
|
+
: new RegExp(autoExpand);
|
|
240
|
+
}
|
|
233
241
|
}
|
|
234
242
|
|
|
235
243
|
// Copyright 2024 IOTA Stiftung.
|
|
@@ -69,4 +69,10 @@ export declare class JsonSchemaHelper {
|
|
|
69
69
|
static expandSchemaTypes(allSchemas: {
|
|
70
70
|
[id: string]: IJsonSchema;
|
|
71
71
|
}, schema: IJsonSchema, expandedTypes: string[]): void;
|
|
72
|
+
/**
|
|
73
|
+
* Convert a string auto expand pattern to a regular expression.
|
|
74
|
+
* @param autoExpand The auto expand pattern.
|
|
75
|
+
* @returns The regular expression.
|
|
76
|
+
*/
|
|
77
|
+
static autoExpandToRegEx(autoExpand: string): RegExp;
|
|
72
78
|
}
|
package/docs/changelog.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.0.2-next.6](https://github.com/twinfoundation/tools/compare/tools-core-v0.0.2-next.5...tools-core-v0.0.2-next.6) (2025-08-21)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* remove auto expanded types from final output ([18e05dc](https://github.com/twinfoundation/tools/commit/18e05dc88f71a0a27b79d1d076b1261b42d2c4c2))
|
|
9
|
+
|
|
3
10
|
## [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
11
|
|
|
5
12
|
|
|
@@ -209,3 +209,25 @@ The types to expand.
|
|
|
209
209
|
#### Returns
|
|
210
210
|
|
|
211
211
|
`void`
|
|
212
|
+
|
|
213
|
+
***
|
|
214
|
+
|
|
215
|
+
### autoExpandToRegEx()
|
|
216
|
+
|
|
217
|
+
> `static` **autoExpandToRegEx**(`autoExpand`): `RegExp`
|
|
218
|
+
|
|
219
|
+
Convert a string auto expand pattern to a regular expression.
|
|
220
|
+
|
|
221
|
+
#### Parameters
|
|
222
|
+
|
|
223
|
+
##### autoExpand
|
|
224
|
+
|
|
225
|
+
`string`
|
|
226
|
+
|
|
227
|
+
The auto expand pattern.
|
|
228
|
+
|
|
229
|
+
#### Returns
|
|
230
|
+
|
|
231
|
+
`RegExp`
|
|
232
|
+
|
|
233
|
+
The regular expression.
|