vovk-cli 0.0.1-draft.229 → 0.0.1-draft.230

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.
@@ -23,6 +23,29 @@ export function convertJSONSchemaToTypeScriptDef(schema) {
23
23
  }
24
24
  return currentSchema || null;
25
25
  };
26
+ // Process schema and any nested definitions
27
+ const processSchema = (currentSchema) => {
28
+ // Merge any $defs into the main schema for reference resolution
29
+ if (currentSchema.$defs || currentSchema.definitions) {
30
+ // Create a copy to avoid modifying the original
31
+ const processedSchema = { ...currentSchema };
32
+ // Support both $defs (JSON Schema 2019-09+) and definitions (older JSON Schema)
33
+ if (!processedSchema.definitions) {
34
+ processedSchema.definitions = {};
35
+ }
36
+ // Copy $defs into definitions for consistent reference resolution
37
+ if (processedSchema.$defs) {
38
+ processedSchema.definitions = {
39
+ ...processedSchema.definitions,
40
+ ...processedSchema.$defs,
41
+ };
42
+ }
43
+ return processedSchema;
44
+ }
45
+ return currentSchema;
46
+ };
47
+ // Pre-process the schema to handle definitions
48
+ const processedSchema = processSchema(schema);
26
49
  // Helper function to get JSDoc from schema
27
50
  const getJSDoc = (schema, indentation = '') => {
28
51
  if (typeof schema === 'boolean') {
@@ -49,6 +72,7 @@ export function convertJSONSchemaToTypeScriptDef(schema) {
49
72
  else {
50
73
  // If we can't resolve the reference, use the reference name as type
51
74
  const refName = schema.$ref.split('/').pop();
75
+ console.warn(`Warning: Could not resolve reference ${schema.$ref}`);
52
76
  return refName || 'KnownAny';
53
77
  }
54
78
  }
@@ -185,6 +209,6 @@ export function convertJSONSchemaToTypeScriptDef(schema) {
185
209
  };
186
210
  // Generate the interface
187
211
  const jsDoc = getJSDoc(schema);
188
- const interfaceBody = schemaToType(schema);
212
+ const interfaceBody = schemaToType(processedSchema);
189
213
  return `${jsDoc}\n${interfaceBody}`;
190
214
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vovk-cli",
3
- "version": "0.0.1-draft.229",
3
+ "version": "0.0.1-draft.230",
4
4
  "bin": {
5
5
  "vovk": "./dist/index.mjs"
6
6
  },
@@ -35,7 +35,7 @@
35
35
  },
36
36
  "homepage": "https://vovk.dev",
37
37
  "peerDependencies": {
38
- "vovk": "^3.0.0-draft.217"
38
+ "vovk": "^3.0.0-draft.218"
39
39
  },
40
40
  "optionalDependencies": {
41
41
  "vovk-python": "^0.0.1-draft.40"