@twin.org/tools-core 0.0.2-next.6 → 0.0.2-next.8
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
|
@@ -152,9 +152,7 @@ class JsonSchemaHelper {
|
|
|
152
152
|
for (const typeKey of Object.keys(allSchemas)) {
|
|
153
153
|
if (!referencedSchemas[typeKey]) {
|
|
154
154
|
for (const requiredType of requiredTypes) {
|
|
155
|
-
const regex =
|
|
156
|
-
? new RegExp(requiredType.slice(1, -1))
|
|
157
|
-
: new RegExp(requiredType);
|
|
155
|
+
const regex = JsonSchemaHelper.stringToRegEx(requiredType);
|
|
158
156
|
if (regex.test(typeKey)) {
|
|
159
157
|
referencedSchemas[typeKey] = allSchemas[typeKey];
|
|
160
158
|
JsonSchemaHelper.extractTypesFromSchema(allSchemas, allSchemas[typeKey], referencedSchemas);
|
|
@@ -184,7 +182,7 @@ class JsonSchemaHelper {
|
|
|
184
182
|
if (core.Is.stringValue(schema.$ref)) {
|
|
185
183
|
for (const expandedType of expandedTypes) {
|
|
186
184
|
const typeName = JsonSchemaHelper.normaliseTypeName(schema.$ref.replace("#/definitions/", ""));
|
|
187
|
-
const regex = JsonSchemaHelper.
|
|
185
|
+
const regex = JsonSchemaHelper.stringToRegEx(expandedType);
|
|
188
186
|
if (regex.test(typeName) && allSchemas[typeName]) {
|
|
189
187
|
delete schema.$ref;
|
|
190
188
|
Object.assign(schema, allSchemas[typeName]);
|
|
@@ -231,14 +229,14 @@ class JsonSchemaHelper {
|
|
|
231
229
|
}
|
|
232
230
|
}
|
|
233
231
|
/**
|
|
234
|
-
* Convert a string
|
|
235
|
-
* @param
|
|
232
|
+
* Convert a string pattern to a regular expression.
|
|
233
|
+
* @param matchPattern The pattern to convert.
|
|
236
234
|
* @returns The regular expression.
|
|
237
235
|
*/
|
|
238
|
-
static
|
|
239
|
-
return
|
|
240
|
-
? new RegExp(
|
|
241
|
-
: new RegExp(
|
|
236
|
+
static stringToRegEx(matchPattern) {
|
|
237
|
+
return matchPattern.startsWith("/") && matchPattern.endsWith("/")
|
|
238
|
+
? new RegExp(matchPattern.slice(1, -1))
|
|
239
|
+
: new RegExp(`^${matchPattern}$`);
|
|
242
240
|
}
|
|
243
241
|
}
|
|
244
242
|
|
package/dist/esm/index.mjs
CHANGED
|
@@ -150,9 +150,7 @@ class JsonSchemaHelper {
|
|
|
150
150
|
for (const typeKey of Object.keys(allSchemas)) {
|
|
151
151
|
if (!referencedSchemas[typeKey]) {
|
|
152
152
|
for (const requiredType of requiredTypes) {
|
|
153
|
-
const regex =
|
|
154
|
-
? new RegExp(requiredType.slice(1, -1))
|
|
155
|
-
: new RegExp(requiredType);
|
|
153
|
+
const regex = JsonSchemaHelper.stringToRegEx(requiredType);
|
|
156
154
|
if (regex.test(typeKey)) {
|
|
157
155
|
referencedSchemas[typeKey] = allSchemas[typeKey];
|
|
158
156
|
JsonSchemaHelper.extractTypesFromSchema(allSchemas, allSchemas[typeKey], referencedSchemas);
|
|
@@ -182,7 +180,7 @@ class JsonSchemaHelper {
|
|
|
182
180
|
if (Is.stringValue(schema.$ref)) {
|
|
183
181
|
for (const expandedType of expandedTypes) {
|
|
184
182
|
const typeName = JsonSchemaHelper.normaliseTypeName(schema.$ref.replace("#/definitions/", ""));
|
|
185
|
-
const regex = JsonSchemaHelper.
|
|
183
|
+
const regex = JsonSchemaHelper.stringToRegEx(expandedType);
|
|
186
184
|
if (regex.test(typeName) && allSchemas[typeName]) {
|
|
187
185
|
delete schema.$ref;
|
|
188
186
|
Object.assign(schema, allSchemas[typeName]);
|
|
@@ -229,14 +227,14 @@ class JsonSchemaHelper {
|
|
|
229
227
|
}
|
|
230
228
|
}
|
|
231
229
|
/**
|
|
232
|
-
* Convert a string
|
|
233
|
-
* @param
|
|
230
|
+
* Convert a string pattern to a regular expression.
|
|
231
|
+
* @param matchPattern The pattern to convert.
|
|
234
232
|
* @returns The regular expression.
|
|
235
233
|
*/
|
|
236
|
-
static
|
|
237
|
-
return
|
|
238
|
-
? new RegExp(
|
|
239
|
-
: new RegExp(
|
|
234
|
+
static stringToRegEx(matchPattern) {
|
|
235
|
+
return matchPattern.startsWith("/") && matchPattern.endsWith("/")
|
|
236
|
+
? new RegExp(matchPattern.slice(1, -1))
|
|
237
|
+
: new RegExp(`^${matchPattern}$`);
|
|
240
238
|
}
|
|
241
239
|
}
|
|
242
240
|
|
|
@@ -70,9 +70,9 @@ export declare class JsonSchemaHelper {
|
|
|
70
70
|
[id: string]: IJsonSchema;
|
|
71
71
|
}, schema: IJsonSchema, expandedTypes: string[]): void;
|
|
72
72
|
/**
|
|
73
|
-
* Convert a string
|
|
74
|
-
* @param
|
|
73
|
+
* Convert a string pattern to a regular expression.
|
|
74
|
+
* @param matchPattern The pattern to convert.
|
|
75
75
|
* @returns The regular expression.
|
|
76
76
|
*/
|
|
77
|
-
static
|
|
77
|
+
static stringToRegEx(matchPattern: string): RegExp;
|
|
78
78
|
}
|
package/docs/changelog.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.0.2-next.8](https://github.com/twinfoundation/tools/compare/tools-core-v0.0.2-next.7...tools-core-v0.0.2-next.8) (2025-09-05)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* tighten the types included with the regex matching ([e54909b](https://github.com/twinfoundation/tools/commit/e54909bded4a19d00560dd3ec783e9146580bda3))
|
|
9
|
+
|
|
10
|
+
## [0.0.2-next.7](https://github.com/twinfoundation/tools/compare/tools-core-v0.0.2-next.6...tools-core-v0.0.2-next.7) (2025-08-29)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
* eslint migration to flat config ([25acfcf](https://github.com/twinfoundation/tools/commit/25acfcf4c4e0c496fffeaf67659fe171bc15199a))
|
|
16
|
+
|
|
3
17
|
## [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
18
|
|
|
5
19
|
|
|
@@ -212,19 +212,19 @@ The types to expand.
|
|
|
212
212
|
|
|
213
213
|
***
|
|
214
214
|
|
|
215
|
-
###
|
|
215
|
+
### stringToRegEx()
|
|
216
216
|
|
|
217
|
-
> `static` **
|
|
217
|
+
> `static` **stringToRegEx**(`matchPattern`): `RegExp`
|
|
218
218
|
|
|
219
|
-
Convert a string
|
|
219
|
+
Convert a string pattern to a regular expression.
|
|
220
220
|
|
|
221
221
|
#### Parameters
|
|
222
222
|
|
|
223
|
-
#####
|
|
223
|
+
##### matchPattern
|
|
224
224
|
|
|
225
225
|
`string`
|
|
226
226
|
|
|
227
|
-
The
|
|
227
|
+
The pattern to convert.
|
|
228
228
|
|
|
229
229
|
#### Returns
|
|
230
230
|
|