Skip to content

Commit c870628

Browse files
committed
using v6.0.0 of scanned apis
1 parent 23a1615 commit c870628

File tree

10 files changed

+403
-35
lines changed

10 files changed

+403
-35
lines changed

server/services/OBPClientService.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,20 @@ export default class OBPClientService {
160160
throw new OBPAPIError(response.status, errorText)
161161
}
162162

163-
return await response.json()
163+
const responseData = await response.json()
164+
// Log count instead of full data to reduce log noise
165+
if (
166+
responseData &&
167+
responseData.scanned_api_versions &&
168+
Array.isArray(responseData.scanned_api_versions)
169+
) {
170+
console.log(
171+
`OBPClientService: Response data: ${responseData.scanned_api_versions.length} scanned_api_versions`
172+
)
173+
} else {
174+
console.log('OBPClientService: Response data received:', typeof responseData)
175+
}
176+
return responseData
164177
}
165178

166179
/**

src/components/HeaderNav.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ const hasObpApiManagerHost = computed(() => obpApiManagerHost.value ? true : fal
4949
const showObpApiManagerButton = computed(() => import.meta.env.VITE_SHOW_API_MANAGER_BUTTON === 'true')
5050
const loginUsername = ref('')
5151
const logoffurl = ref('')
52-
const obpApiVersions = ref(inject(obpApiActiveVersionsKey)!)
53-
const obpMessageDocs = ref(Object.keys(inject(obpGroupedMessageDocsKey)!))
52+
const obpApiVersions = ref(inject(obpApiActiveVersionsKey) || [])
53+
const obpMessageDocs = ref(Object.keys(inject(obpGroupedMessageDocsKey) || {}))
5454
5555
// Split versions into main and other
5656
const mainVersions = ['BGv1.3', 'OBPv5.1.0', 'OBPv6.0.0', 'UKv3.1', 'dynamic-endpoints', 'dynamic-entities', 'OBPdynamic-endpoint', 'OBPdynamic-entity']

src/components/MessageDocsSearchNav.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import { obpGroupedMessageDocsKey } from '@/obp/keys'
3535
3636
let connector = connectors[0]
3737
const route = useRoute()
38-
const groupedMessageDocs = ref(inject(obpGroupedMessageDocsKey)!)
38+
const groupedMessageDocs = ref(inject(obpGroupedMessageDocsKey) || {})
3939
const docs = ref({})
4040
const groups = ref({})
4141
const sortedKeys = ref([])

src/main.ts

Lines changed: 179 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,19 +84,186 @@ import { getCacheStorageInfo } from './obp/common-functions'
8484

8585
app.mount('#app')
8686

87-
if (!isDataSetup) router.replace({ path: 'api-server-error' })
87+
if (!isDataSetup) {
88+
// Error details are already stored in sessionStorage by setupData catch block
89+
router.replace({ path: 'api-server-error' })
90+
}
8891
app.config.errorHandler = (error) => {
89-
console.log(error)
90-
router.replace({ path: 'error' })
92+
console.error('[APP ERROR]', error)
93+
// Show error details in browser DOM
94+
const errorDiv = document.createElement('div')
95+
errorDiv.style.cssText = `
96+
position: fixed;
97+
top: 20px;
98+
left: 50%;
99+
transform: translateX(-50%);
100+
background: #f5f5f5;
101+
color: #333;
102+
padding: 20px;
103+
border-radius: 8px;
104+
max-width: 90%;
105+
max-height: 80vh;
106+
overflow: auto;
107+
z-index: 10000;
108+
font-family: monospace;
109+
white-space: pre-wrap;
110+
box-shadow: 0 4px 6px rgba(0,0,0,0.3);
111+
border: 1px solid #ddd;
112+
`
113+
let errorText = ''
114+
if (error instanceof Error) {
115+
errorText = `Application Error\n\nMessage:\n${error.message}\n\nStack:\n${error.stack || 'No stack trace available'}`
116+
errorDiv.innerHTML = `
117+
<strong style="font-size: 18px;">Application Error</strong><br><br>
118+
<strong>Message:</strong><br>${error.message}<br><br>
119+
<strong>Stack:</strong><br>${error.stack || 'No stack trace available'}
120+
`
121+
} else {
122+
errorText = `Application Error\n\n${JSON.stringify(error, null, 2)}`
123+
errorDiv.innerHTML = `
124+
<strong style="font-size: 18px;">Application Error</strong><br><br>
125+
${JSON.stringify(error, null, 2)}
126+
`
127+
}
128+
129+
const copyBtn = document.createElement('button')
130+
copyBtn.textContent = '📋 Copy'
131+
copyBtn.style.cssText = `
132+
position: absolute;
133+
top: 10px;
134+
right: 90px;
135+
background: #e0e0e0;
136+
border: 1px solid #ccc;
137+
color: #333;
138+
padding: 5px 10px;
139+
cursor: pointer;
140+
border-radius: 4px;
141+
`
142+
copyBtn.onclick = async () => {
143+
try {
144+
await navigator.clipboard.writeText(errorText)
145+
copyBtn.textContent = '✓ Copied!'
146+
setTimeout(() => {
147+
copyBtn.textContent = '📋 Copy'
148+
}, 2000)
149+
} catch (err) {
150+
console.error('Failed to copy error:', err)
151+
copyBtn.textContent = '✗ Failed'
152+
setTimeout(() => {
153+
copyBtn.textContent = '📋 Copy'
154+
}, 2000)
155+
}
156+
}
157+
errorDiv.appendChild(copyBtn)
158+
159+
const closeBtn = document.createElement('button')
160+
closeBtn.textContent = '✕ Close'
161+
closeBtn.style.cssText = `
162+
position: absolute;
163+
top: 10px;
164+
right: 10px;
165+
background: #e0e0e0;
166+
border: 1px solid #ccc;
167+
color: #333;
168+
padding: 5px 10px;
169+
cursor: pointer;
170+
border-radius: 4px;
171+
`
172+
closeBtn.onclick = () => errorDiv.remove()
173+
errorDiv.appendChild(closeBtn)
174+
document.body.appendChild(errorDiv)
91175
}
92176
} catch (error) {
93-
console.log(error)
94-
router.replace({ path: 'error' })
177+
console.error('[APP SETUP ERROR]', error)
178+
// Show error details in browser DOM
179+
const errorDiv = document.createElement('div')
180+
errorDiv.style.cssText = `
181+
position: fixed;
182+
top: 20px;
183+
left: 50%;
184+
transform: translateX(-50%);
185+
background: #f5f5f5;
186+
color: #333;
187+
padding: 20px;
188+
border-radius: 8px;
189+
max-width: 90%;
190+
max-height: 80vh;
191+
overflow: auto;
192+
z-index: 10000;
193+
font-family: monospace;
194+
white-space: pre-wrap;
195+
box-shadow: 0 4px 6px rgba(0,0,0,0.3);
196+
border: 1px solid #ddd;
197+
`
198+
let errorText = ''
199+
if (error instanceof Error) {
200+
errorText = `API Explorer II Error\n\nMessage:\n${error.message}\n\nStack:\n${error.stack || 'No stack trace available'}`
201+
errorDiv.innerHTML = `
202+
<strong style="font-size: 18px;">API Explorer II Error</strong><br><br>
203+
<strong>Message:</strong><br>${error.message}<br><br>
204+
<strong>Stack:</strong><br>${error.stack || 'No stack trace available'}
205+
`
206+
} else {
207+
errorText = `API Explorer II Error\n\n${JSON.stringify(error, null, 2)}`
208+
errorDiv.innerHTML = `
209+
<strong style="font-size: 18px;">API Explorer II Error</strong><br><br>
210+
${JSON.stringify(error, null, 2)}
211+
`
212+
}
213+
214+
const copyBtn = document.createElement('button')
215+
copyBtn.textContent = '📋 Copy'
216+
copyBtn.style.cssText = `
217+
position: absolute;
218+
top: 10px;
219+
right: 90px;
220+
background: #e0e0e0;
221+
border: 1px solid #ccc;
222+
color: #333;
223+
padding: 5px 10px;
224+
cursor: pointer;
225+
border-radius: 4px;
226+
`
227+
copyBtn.onclick = async () => {
228+
try {
229+
await navigator.clipboard.writeText(errorText)
230+
copyBtn.textContent = '✓ Copied!'
231+
setTimeout(() => {
232+
copyBtn.textContent = '📋 Copy'
233+
}, 2000)
234+
} catch (err) {
235+
console.error('Failed to copy error:', err)
236+
copyBtn.textContent = '✗ Failed'
237+
setTimeout(() => {
238+
copyBtn.textContent = '📋 Copy'
239+
}, 2000)
240+
}
241+
}
242+
errorDiv.appendChild(copyBtn)
243+
244+
const closeBtn = document.createElement('button')
245+
closeBtn.textContent = '✕ Close'
246+
closeBtn.style.cssText = `
247+
position: absolute;
248+
top: 10px;
249+
right: 10px;
250+
background: #e0e0e0;
251+
border: 1px solid #ccc;
252+
color: #333;
253+
padding: 5px 10px;
254+
cursor: pointer;
255+
border-radius: 4px;
256+
`
257+
closeBtn.onclick = () => errorDiv.remove()
258+
errorDiv.appendChild(closeBtn)
259+
document.body.appendChild(errorDiv)
95260
}
96261
})()
97262

98263
async function setupData(app: App<Element>, worker: Worker) {
99264
try {
265+
// Clear any previous error
266+
sessionStorage.removeItem('setupError')
100267
// 'open': Returns a Promise that resolves to the Cache object matching the cacheName(obp-resource-docs-cache) (a new cache is created if it doesn't already exist.)
101268
const cacheStorageOfResourceDocs = await caches.open('obp-resource-docs-cache') // Please note: The global 'caches' read-only property returns the 'CacheStorage' object associated with the current context.
102269
// 'match': Checks if a given Request is a key in any of the Cache objects that the CacheStorage object tracks, and returns a Promise that resolves to that match.
@@ -175,6 +342,13 @@ async function setupData(app: App<Element>, worker: Worker) {
175342
return true
176343
} catch (error) {
177344
app.provide(obpApiActiveVersionsKey, [OBP_API_VERSION])
345+
// Store error details for display on error page
346+
const errorDetails =
347+
error instanceof Error
348+
? { message: error.message, stack: error.stack }
349+
: { message: JSON.stringify(error) }
350+
sessionStorage.setItem('setupError', JSON.stringify(errorDetails))
351+
console.error('[SETUP ERROR] Stored error details:', errorDetails)
178352
return false
179353
}
180354
}

0 commit comments

Comments
 (0)