@twin.org/tools-core 0.0.2-next.7 → 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.
@@ -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 = requiredType.startsWith("/") && requiredType.endsWith("/")
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.autoExpandToRegEx(expandedType);
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 auto expand pattern to a regular expression.
235
- * @param autoExpand The auto expand pattern.
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 autoExpandToRegEx(autoExpand) {
239
- return autoExpand.startsWith("/") && autoExpand.endsWith("/")
240
- ? new RegExp(autoExpand.slice(1, -1))
241
- : new RegExp(autoExpand);
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
 
@@ -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 = requiredType.startsWith("/") && requiredType.endsWith("/")
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.autoExpandToRegEx(expandedType);
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 auto expand pattern to a regular expression.
233
- * @param autoExpand The auto expand pattern.
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 autoExpandToRegEx(autoExpand) {
237
- return autoExpand.startsWith("/") && autoExpand.endsWith("/")
238
- ? new RegExp(autoExpand.slice(1, -1))
239
- : new RegExp(autoExpand);
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 auto expand pattern to a regular expression.
74
- * @param autoExpand The auto expand pattern.
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 autoExpandToRegEx(autoExpand: string): RegExp;
77
+ static stringToRegEx(matchPattern: string): RegExp;
78
78
  }
package/docs/changelog.md CHANGED
@@ -1,5 +1,12 @@
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
+
3
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)
4
11
 
5
12
 
@@ -212,19 +212,19 @@ The types to expand.
212
212
 
213
213
  ***
214
214
 
215
- ### autoExpandToRegEx()
215
+ ### stringToRegEx()
216
216
 
217
- > `static` **autoExpandToRegEx**(`autoExpand`): `RegExp`
217
+ > `static` **stringToRegEx**(`matchPattern`): `RegExp`
218
218
 
219
- Convert a string auto expand pattern to a regular expression.
219
+ Convert a string pattern to a regular expression.
220
220
 
221
221
  #### Parameters
222
222
 
223
- ##### autoExpand
223
+ ##### matchPattern
224
224
 
225
225
  `string`
226
226
 
227
- The auto expand pattern.
227
+ The pattern to convert.
228
228
 
229
229
  #### Returns
230
230
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/tools-core",
3
- "version": "0.0.2-next.7",
3
+ "version": "0.0.2-next.8",
4
4
  "description": "Shared components for the tools",
5
5
  "repository": {
6
6
  "type": "git",