@atolis-hq/corum 0.1.10 → 0.1.11

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.
@@ -186,7 +186,8 @@ function deriveComponentForSchema(name, document, entry, visited = new Set()) {
186
186
  if (visited.has(name))
187
187
  return undefined;
188
188
  visited.add(name);
189
- // Direct: find an operation that references this schema
189
+ // Direct: collect all components whose operations reference this schema
190
+ const directComponents = new Set();
190
191
  for (const [urlPath, pathItem] of Object.entries(document.paths ?? {})) {
191
192
  if (!pathItem)
192
193
  continue;
@@ -196,12 +197,18 @@ function deriveComponentForSchema(name, document, entry, visited = new Set()) {
196
197
  if (!operation)
197
198
  continue;
198
199
  if (referencesSchema(operation, name)) {
199
- return entry.componentMapping.strategy === 'tag'
200
+ const component = entry.componentMapping.strategy === 'tag'
200
201
  ? operation.tags?.[0]
201
202
  : deriveComponent(urlPath, entry.componentMapping);
203
+ if (component)
204
+ directComponents.add(component);
202
205
  }
203
206
  }
204
207
  }
208
+ if (directComponents.size > 1)
209
+ return 'shared';
210
+ if (directComponents.size === 1)
211
+ return [...directComponents][0];
205
212
  // Indirect: find another component schema that references this one and use its component
206
213
  for (const [schemaName, schema] of Object.entries(document.components?.schemas ?? {})) {
207
214
  if (schemaName === name || isRefSchema(schema))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atolis-hq/corum",
3
- "version": "0.1.10",
3
+ "version": "0.1.11",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -168,7 +168,11 @@ function fieldSchemaName(nodeId) {
168
168
  const fieldMarker = '.fields.';
169
169
  const schemaIdx = nodeId.indexOf(schemaMarker);
170
170
  const fieldIdx = nodeId.indexOf(fieldMarker);
171
- if (schemaIdx < 0 || fieldIdx < 0) return null;
171
+ if (fieldIdx < 0) return null;
172
+ if (schemaIdx < 0) {
173
+ // Standalone Schema node: e.g. user.Schema.User.fields.email → 'User'
174
+ return nodeId.slice(0, fieldIdx).split('.').pop() ?? null;
175
+ }
172
176
  return nodeId.slice(schemaIdx + schemaMarker.length, fieldIdx);
173
177
  }
174
178