@twin.org/tools-core 0.0.2-next.4 → 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.
@@ -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
- if ((core.Is.regexp(requiredType) && new RegExp(requiredType).test(typeKey)) ||
156
- (core.Is.stringValue(requiredType) && requiredType === typeKey)) {
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
- if (new RegExp(expandedType).test(typeName) && allSchemas[typeName]) {
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;
@@ -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
- if ((Is.regexp(requiredType) && new RegExp(requiredType).test(typeKey)) ||
154
- (Is.stringValue(requiredType) && requiredType === typeKey)) {
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
- if (new RegExp(expandedType).test(typeName) && allSchemas[typeName]) {
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;
@@ -49,7 +49,7 @@ export declare class JsonSchemaHelper {
49
49
  */
50
50
  static extractTypes(allSchemas: {
51
51
  [id: string]: IJsonSchema;
52
- }, requiredTypes: (string | RegExp)[], referencedSchemas: {
52
+ }, requiredTypes: string[], referencedSchemas: {
53
53
  [id: string]: IJsonSchema;
54
54
  }): void;
55
55
  /**
package/docs/changelog.md CHANGED
@@ -1,5 +1,12 @@
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
+
3
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)
4
11
 
5
12
 
@@ -144,7 +144,7 @@ All the known schemas.
144
144
 
145
145
  ##### requiredTypes
146
146
 
147
- (`string` \| `RegExp`)[]
147
+ `string`[]
148
148
 
149
149
  The required types.
150
150
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/tools-core",
3
- "version": "0.0.2-next.4",
3
+ "version": "0.0.2-next.5",
4
4
  "description": "Shared components for the tools",
5
5
  "repository": {
6
6
  "type": "git",