Skip to content

Commit 0ed2ab6

Browse files
authored
Update deps and refactor (#248)
* [refactor] async function * update deps
1 parent 6f782f5 commit 0ed2ab6

File tree

2 files changed

+43
-45
lines changed

2 files changed

+43
-45
lines changed

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
},
5555
"dependencies": {
5656
"hightable": "0.15.6",
57-
"hyparquet": "1.13.3",
57+
"hyparquet": "1.13.5",
5858
"hyparquet-compressors": "1.1.1",
5959
"icebird": "0.3.0",
6060
"react": "18.3.1",
@@ -69,11 +69,11 @@
6969
"@storybook/react-vite": "8.6.14",
7070
"@storybook/test": "8.6.14",
7171
"@testing-library/react": "16.3.0",
72-
"@types/node": "22.15.18",
73-
"@types/react": "19.1.4",
72+
"@types/node": "22.15.21",
73+
"@types/react": "19.1.5",
7474
"@types/react-dom": "19.1.5",
7575
"@vitejs/plugin-react": "4.4.1",
76-
"@vitest/coverage-v8": "3.1.3",
76+
"@vitest/coverage-v8": "3.1.4",
7777
"eslint": "9.27.0",
7878
"eslint-plugin-react": "7.37.5",
7979
"eslint-plugin-react-hooks": "5.2.0",
@@ -87,7 +87,7 @@
8787
"typescript": "5.8.3",
8888
"typescript-eslint": "8.32.1",
8989
"vite": "6.3.5",
90-
"vitest": "3.1.3"
90+
"vitest": "3.1.4"
9191
},
9292
"eslintConfig": {
9393
"extends": [

src/lib/sources/httpSource.ts

Lines changed: 38 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,53 @@
11
import { DirSource, FileMetadata, FileSource, SourcePart } from './types.js'
22
import { getFileName } from './utils.js'
33

4-
function s3list(bucket: string, prefix: string) {
4+
async function s3list(bucket: string, prefix: string) {
55
const url = `https://${bucket}.s3.amazonaws.com/?list-type=2&prefix=${prefix}&delimiter=/`
6-
return fetch(url)
7-
.then(res => {
8-
if (!res.ok) throw new Error(`${res.status} ${res.statusText}`)
9-
return res.text()
10-
})
11-
.then(text => {
12-
const results = []
6+
const result = await fetch(url)
7+
if (!result.ok) {
8+
throw new Error(`${result.status} ${result.statusText}`)
9+
}
10+
const text = await result.text()
11+
const results = []
1312

14-
// Parse regular objects (files and explicit directories)
15-
const contentsRegex = /<Contents>(.*?)<\/Contents>/gs
16-
const contentsMatches = text.match(contentsRegex) ?? []
13+
// Parse regular objects (files and explicit directories)
14+
const contentsRegex = /<Contents>(.*?)<\/Contents>/gs
15+
const contentsMatches = text.match(contentsRegex) ?? []
1716

18-
for (const match of contentsMatches) {
19-
const keyMatch = /<Key>(.*?)<\/Key>/.exec(match)
20-
const lastModifiedMatch = /<LastModified>(.*?)<\/LastModified>/.exec(match)
21-
const sizeMatch = /<Size>(.*?)<\/Size>/.exec(match)
22-
const eTagMatch = /<ETag>&quot;(.*?)&quot;<\/ETag>/.exec(match) ?? /<ETag>"(.*?)"<\/ETag>/.exec(match)
17+
for (const match of contentsMatches) {
18+
const keyMatch = /<Key>(.*?)<\/Key>/.exec(match)
19+
const lastModifiedMatch = /<LastModified>(.*?)<\/LastModified>/.exec(match)
20+
const sizeMatch = /<Size>(.*?)<\/Size>/.exec(match)
21+
const eTagMatch = /<ETag>&quot;(.*?)&quot;<\/ETag>/.exec(match) ?? /<ETag>"(.*?)"<\/ETag>/.exec(match)
2322

24-
if (!keyMatch || !lastModifiedMatch) continue
23+
if (!keyMatch || !lastModifiedMatch) continue
2524

26-
const key = keyMatch[1]
27-
const lastModified = lastModifiedMatch[1]
28-
const size = sizeMatch ? parseInt(sizeMatch[1] ?? '', 10) : undefined
29-
const eTag = eTagMatch ? eTagMatch[1] : undefined
25+
const key = keyMatch[1]
26+
const lastModified = lastModifiedMatch[1]
27+
const size = sizeMatch ? parseInt(sizeMatch[1] ?? '', 10) : undefined
28+
const eTag = eTagMatch ? eTagMatch[1] : undefined
3029

31-
results.push({ key, lastModified, size, eTag })
32-
}
30+
results.push({ key, lastModified, size, eTag })
31+
}
3332

34-
// Parse CommonPrefixes (virtual directories)
35-
const prefixRegex = /<CommonPrefixes>(.*?)<\/CommonPrefixes>/gs
36-
const prefixMatches = text.match(prefixRegex) ?? []
37-
38-
for (const match of prefixMatches) {
39-
const prefixMatch = /<Prefix>(.*?)<\/Prefix>/.exec(match)
40-
if (!prefixMatch) continue
41-
42-
const key = prefixMatch[1]
43-
results.push({
44-
key,
45-
lastModified: new Date().toISOString(), // No lastModified for CommonPrefixes
46-
size: 0,
47-
isCommonPrefix: true,
48-
})
49-
}
33+
// Parse CommonPrefixes (virtual directories)
34+
const prefixRegex = /<CommonPrefixes>(.*?)<\/CommonPrefixes>/gs
35+
const prefixMatches = text.match(prefixRegex) ?? []
36+
37+
for (const match of prefixMatches) {
38+
const prefixMatch = /<Prefix>(.*?)<\/Prefix>/.exec(match)
39+
if (!prefixMatch) continue
5040

51-
return results
41+
const key = prefixMatch[1]
42+
results.push({
43+
key,
44+
lastModified: new Date().toISOString(), // No lastModified for CommonPrefixes
45+
size: 0,
46+
isCommonPrefix: true,
5247
})
48+
}
49+
50+
return results
5351
}
5452

5553
function getSourceParts(sourceId: string): SourcePart[] {

0 commit comments

Comments
 (0)