MCPcopy Index your code
hub / github.com/simstudioai/sim / listDirectory

Function listDirectory

apps/sim/connectors/obsidian/obsidian.ts:54–81  ·  view source on GitHub ↗

* Lists entries in a single vault directory (non-recursive). * Returns raw entries: files as names, subdirectories with trailing slash.

(
  baseUrl: string,
  accessToken: string,
  dirPath: string,
  retryOptions?: Parameters<typeof secureFetchWithRetry>[2]
)

Source from the content-addressed store, hash-verified

52 * Returns raw entries: files as names, subdirectories with trailing slash.
53 */
54async function listDirectory(
55 baseUrl: string,
56 accessToken: string,
57 dirPath: string,
58 retryOptions?: Parameters<typeof secureFetchWithRetry>[2]
59): Promise<string[]> {
60 const encodedDir = dirPath ? dirPath.split('/').map(encodeURIComponent).join('/') : ''
61 const endpoint = encodedDir ? `${baseUrl}/vault/${encodedDir}/` : `${baseUrl}/vault/`
62
63 const response = await secureFetchWithRetry(
64 endpoint,
65 {
66 method: 'GET',
67 headers: {
68 Authorization: `Bearer ${accessToken}`,
69 Accept: 'application/json',
70 },
71 },
72 retryOptions
73 )
74
75 if (!response.ok) {
76 throw new Error(`Obsidian API error: ${response.status} ${response.statusText}`)
77 }
78
79 const data = (await response.json()) as { files: string[] }
80 return data.files ?? []
81}
82
83const MAX_RECURSION_DEPTH = 20
84

Callers 2

listVaultFilesFunction · 0.85
obsidian.tsFile · 0.85

Calls 2

secureFetchWithRetryFunction · 0.90
joinMethod · 0.80

Tested by

no test coverage detected