zero-doc 1.0.4 → 1.0.6
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.
- package/README.md +1 -1
- package/dist/ai-analyzer.d.ts +4 -8
- package/dist/ai-analyzer.js +274 -263
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +86 -151
- package/dist/config.json +1 -1
- package/package.json +4 -1
- package/scripts/inject-config.js +25 -19
- package/viewer/src/App.tsx +8 -45
- package/viewer/src/components/CodeSnippet.tsx +0 -1
- package/viewer/vite.config.ts +17 -1
package/viewer/src/App.tsx
CHANGED
|
@@ -12,75 +12,44 @@ function App() {
|
|
|
12
12
|
|
|
13
13
|
const handleInventoryChange = (updatedInventory: APIInventory) => {
|
|
14
14
|
setInventory(updatedInventory);
|
|
15
|
-
// Save to localStorage for persistence
|
|
16
15
|
localStorage.setItem('zero-doc-inventory', JSON.stringify(updatedInventory));
|
|
17
16
|
};
|
|
18
17
|
|
|
19
18
|
useEffect(() => {
|
|
20
|
-
|
|
21
|
-
const savedInventory = localStorage.getItem('zero-doc-inventory');
|
|
22
|
-
if (savedInventory) {
|
|
23
|
-
try {
|
|
24
|
-
const parsed = JSON.parse(savedInventory);
|
|
25
|
-
// Validate localStorage data
|
|
26
|
-
if (parsed.endpoints && Array.isArray(parsed.endpoints) && parsed.endpoints.length > 0) {
|
|
27
|
-
console.log('📦 Loaded from localStorage:', parsed.endpoints.length, 'endpoints');
|
|
28
|
-
setInventory(parsed);
|
|
29
|
-
setLoading(false);
|
|
30
|
-
return;
|
|
31
|
-
} else {
|
|
32
|
-
console.log('⚠️ localStorage data invalid or empty, fetching from server...');
|
|
33
|
-
localStorage.removeItem('zero-doc-inventory');
|
|
34
|
-
}
|
|
35
|
-
} catch (error) {
|
|
36
|
-
console.error('⚠️ Failed to parse localStorage data:', error);
|
|
37
|
-
localStorage.removeItem('zero-doc-inventory');
|
|
38
|
-
}
|
|
39
|
-
}
|
|
19
|
+
localStorage.removeItem('zero-doc-inventory');
|
|
40
20
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
cache: 'no-cache',
|
|
21
|
+
const timestamp = Date.now();
|
|
22
|
+
fetch(`/api-inventory.json?t=${timestamp}`, {
|
|
23
|
+
cache: 'no-store',
|
|
45
24
|
headers: {
|
|
46
25
|
'Accept': 'application/json',
|
|
26
|
+
'Cache-Control': 'no-cache, no-store, must-revalidate',
|
|
27
|
+
'Pragma': 'no-cache',
|
|
28
|
+
'Expires': '0',
|
|
47
29
|
},
|
|
48
30
|
})
|
|
49
31
|
.then(res => {
|
|
50
|
-
console.log('📡 Response status:', res.status, res.statusText);
|
|
51
32
|
if (!res.ok) {
|
|
52
33
|
throw new Error(`HTTP error! status: ${res.status} - ${res.statusText}`);
|
|
53
34
|
}
|
|
54
35
|
return res.text().then(text => {
|
|
55
|
-
console.log('📄 Response length:', text.length, 'bytes');
|
|
56
36
|
if (!text || text.trim().length === 0) {
|
|
57
37
|
throw new Error('Empty response from server');
|
|
58
38
|
}
|
|
59
39
|
try {
|
|
60
40
|
const parsed = JSON.parse(text);
|
|
61
|
-
console.log('✅ JSON parsed successfully');
|
|
62
|
-
console.log('📊 Endpoints in JSON:', parsed.endpoints?.length || 0);
|
|
63
41
|
return parsed;
|
|
64
42
|
} catch (parseError) {
|
|
65
|
-
console.error('❌ Failed to parse JSON:', parseError);
|
|
66
|
-
console.error('Raw response (first 500 chars):', text.substring(0, 500));
|
|
67
43
|
throw new Error('Invalid JSON response from server');
|
|
68
44
|
}
|
|
69
45
|
});
|
|
70
46
|
})
|
|
71
47
|
.then((data: APIInventory) => {
|
|
72
|
-
console.log('📦 Loaded inventory:', data);
|
|
73
|
-
|
|
74
|
-
// Validate and normalize data
|
|
75
48
|
if (!data.endpoints || !Array.isArray(data.endpoints)) {
|
|
76
|
-
console.error('❌ Invalid inventory format: endpoints is not an array', data);
|
|
77
49
|
setLoading(false);
|
|
78
50
|
return;
|
|
79
51
|
}
|
|
80
52
|
|
|
81
|
-
console.log(`✅ Found ${data.endpoints.length} endpoints`);
|
|
82
|
-
|
|
83
|
-
// Ensure all required fields exist
|
|
84
53
|
if (!data.stats) {
|
|
85
54
|
data.stats = {
|
|
86
55
|
totalEndpoints: data.endpoints.length,
|
|
@@ -88,7 +57,6 @@ function App() {
|
|
|
88
57
|
};
|
|
89
58
|
}
|
|
90
59
|
|
|
91
|
-
// Validate each endpoint
|
|
92
60
|
data.endpoints = data.endpoints.map((ep, idx) => {
|
|
93
61
|
if (!ep.id) ep.id = `ep-${idx}`;
|
|
94
62
|
if (!ep.method) ep.method = 'GET';
|
|
@@ -101,14 +69,10 @@ function App() {
|
|
|
101
69
|
});
|
|
102
70
|
|
|
103
71
|
setInventory(data);
|
|
104
|
-
|
|
72
|
+
localStorage.setItem('zero-doc-inventory', JSON.stringify(data));
|
|
105
73
|
setLoading(false);
|
|
106
74
|
})
|
|
107
75
|
.catch(err => {
|
|
108
|
-
console.error('❌ Failed to load API inventory:', err);
|
|
109
|
-
console.error('Error details:', err);
|
|
110
|
-
console.error('💡 Make sure api-inventory.json exists in the public folder');
|
|
111
|
-
console.error('💡 Try accessing http://localhost:5173/api-inventory.json directly in your browser');
|
|
112
76
|
setLoading(false);
|
|
113
77
|
});
|
|
114
78
|
}, []);
|
|
@@ -161,4 +125,3 @@ function App() {
|
|
|
161
125
|
}
|
|
162
126
|
|
|
163
127
|
export default App;
|
|
164
|
-
|
package/viewer/vite.config.ts
CHANGED
|
@@ -8,8 +8,24 @@ export default defineConfig({
|
|
|
8
8
|
open: false,
|
|
9
9
|
fs: {
|
|
10
10
|
strict: false
|
|
11
|
+
},
|
|
12
|
+
headers: {
|
|
13
|
+
'Cache-Control': 'no-store, no-cache, must-revalidate, proxy-revalidate',
|
|
11
14
|
}
|
|
12
15
|
},
|
|
13
|
-
publicDir: 'public'
|
|
16
|
+
publicDir: 'public',
|
|
17
|
+
// Disable caching for JSON files
|
|
18
|
+
build: {
|
|
19
|
+
rollupOptions: {
|
|
20
|
+
output: {
|
|
21
|
+
assetFileNames: (assetInfo) => {
|
|
22
|
+
if (assetInfo.name && assetInfo.name.endsWith('.json')) {
|
|
23
|
+
return 'assets/[name]-[hash][extname]';
|
|
24
|
+
}
|
|
25
|
+
return 'assets/[name]-[hash][extname]';
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
14
30
|
})
|
|
15
31
|
|