@atolis-hq/corum 0.1.8 → 0.1.10

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.
@@ -86,7 +86,6 @@ export function mapDocument(document, entry, packConfig) {
86
86
  endpointNode.properties = {
87
87
  method: method.toUpperCase(),
88
88
  path: urlPath,
89
- ...(operation.operationId && { operationId: operation.operationId }),
90
89
  ...(operation.summary && { description: operation.summary }),
91
90
  };
92
91
  nodes.push(endpointNode);
@@ -94,16 +93,23 @@ export function mapDocument(document, entry, packConfig) {
94
93
  if (requestBody?.content) {
95
94
  const jsonContent = requestBody.content['application/json'];
96
95
  if (jsonContent?.schema) {
97
- emitSchemaNode(jsonContent.schema, `${operationId}-request`, endpointId, 'schemas', packConfig, entry.spec, nodes, edges, diagnostics, sharedSchemas);
96
+ const ref = emitSchemaNode(jsonContent.schema, `${operationId}-request`, endpointId, 'schemas', packConfig, entry.spec, nodes, edges, diagnostics, sharedSchemas);
97
+ if (ref)
98
+ endpointNode.properties.request = ref;
98
99
  }
99
100
  }
101
+ const responses = {};
100
102
  for (const [status, response] of Object.entries(operation.responses ?? {})) {
101
103
  const responseObj = response;
102
104
  const jsonContent = responseObj.content?.['application/json'];
103
105
  if (jsonContent?.schema) {
104
- emitSchemaNode(jsonContent.schema, `${operationId}-response-${status}`, endpointId, 'schemas', packConfig, entry.spec, nodes, edges, diagnostics, sharedSchemas);
106
+ const ref = emitSchemaNode(jsonContent.schema, `${operationId}-response-${status}`, endpointId, 'schemas', packConfig, entry.spec, nodes, edges, diagnostics, sharedSchemas);
107
+ if (ref)
108
+ responses[status] = ref;
105
109
  }
106
110
  }
111
+ if (Object.keys(responses).length > 0)
112
+ endpointNode.properties.responses = responses;
107
113
  }
108
114
  }
109
115
  return { nodes, edges, diagnostics };
@@ -125,13 +131,7 @@ function makeNode(template, component, specPath, id) {
125
131
  }
126
132
  function emitSchemaNode(schema, name, parentId, section, packConfig, specPath, nodes, edges, diagnostics, sharedSchemas) {
127
133
  if (isRefSchema(schema)) {
128
- const refId = sharedSchemas.get(refName(schema.$ref));
129
- if (refId) {
130
- const parent = nodes.find(n => n.id === parentId);
131
- if (parent)
132
- parent.properties[`${section}.${name}`] = refId;
133
- }
134
- return;
134
+ return sharedSchemas.get(refName(schema.$ref));
135
135
  }
136
136
  const schemaId = deriveNodeId('schema', undefined, name, parentId, section);
137
137
  const [component] = parentId.split('.');
@@ -139,6 +139,7 @@ function emitSchemaNode(schema, name, parentId, section, packConfig, specPath, n
139
139
  nodes.push(node);
140
140
  edges.push({ id: `${parentId}__has-field__${schemaId}`, from: parentId, to: schemaId, type: 'has-field', state: 'implemented', stability: 'unstable' });
141
141
  emitFields(schema, schemaId, 'fields', packConfig, specPath, nodes, edges, diagnostics, sharedSchemas);
142
+ return `#/${section}/${name}`;
142
143
  }
143
144
  function emitFields(schema, parentId, section, packConfig, specPath, nodes, edges, diagnostics, sharedSchemas) {
144
145
  for (const [fieldName, fieldSchema] of Object.entries(schema.properties ?? {})) {
@@ -2,6 +2,7 @@
2
2
  import { Command } from 'commander';
3
3
  import { existsSync, mkdirSync, writeFileSync } from 'node:fs';
4
4
  import { readFile as fsReadFile } from 'node:fs/promises';
5
+ import { createRequire } from 'node:module';
5
6
  import path from 'node:path';
6
7
  import { parse as parseYaml } from 'yaml';
7
8
  import { buildOpenAPIConfig, loadImportConfig } from '../import/config.js';
@@ -15,11 +16,13 @@ import { readManifest, upsertPack } from '../pack/manifest.js';
15
16
  import { fetchRegistry, findPack, resolveRef } from '../pack/registry.js';
16
17
  import { createGraphRuntimeConfig } from '../source/config.js';
17
18
  import { startWebServer } from '../web/server.js';
19
+ const require = createRequire(import.meta.url);
20
+ const { version } = require('../../../package.json');
18
21
  const program = new Command();
19
22
  program
20
23
  .name('corum')
21
24
  .description('Corum graph CLI')
22
- .version('0.1.0');
25
+ .version(version);
23
26
  program
24
27
  .command('mcp')
25
28
  .description('Start the MCP stdio server (+ web UI by default)')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atolis-hq/corum",
3
- "version": "0.1.8",
3
+ "version": "0.1.10",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",