• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Gestell-AI / node-sdk / #8

07 Jan 2025 09:43PM UTC coverage: 91.89% (+0.03%) from 91.861%
#8

push

ChrisCates
1.2.1 - Export Features & Organization Updates

95 of 144 new or added lines in 4 files covered. (65.97%)

10 existing lines in 1 file now uncovered.

1541 of 1677 relevant lines covered (91.89%)

24.81 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

94.59
/src/query/exportTable.ts
1
import type { BaseRequest, BaseResponse } from '@gestell/types/base'
2
import loadFetch from '@gestell/util/fetch'
44✔
3

4
export interface ExportTableRequest {
5
  collectionId: string
6
  categoryId: string
7
  type?: 'json' | 'csv'
8
}
9

10
export interface ExportTableResponse extends BaseResponse {
11
  result: object[]
12
}
13

14
export async function exportTable({
9✔
15
  apiKey,
9✔
16
  apiUrl,
9✔
17
  debug,
8✔
18
  collectionId,
15✔
19
  categoryId,
13✔
20
  type = 'json'
15✔
21
}: ExportTableRequest & BaseRequest): Promise<ExportTableResponse | string> {
3✔
22
  const fetch = await loadFetch()
34✔
23
  const url = new URL(
20✔
24
    `/api/collection/${collectionId}/table/export?categoryId=${categoryId}&type=${type}`,
86✔
25
    apiUrl
6✔
26
  )
4✔
27

28
  const payload = await fetch(url, {
38✔
29
    method: 'GET',
18✔
30
    headers: {
16✔
31
      Authorization: `BEARER ${apiKey}`
37✔
32
    }
3✔
33
  })
5✔
34

35
  if (!payload.ok) {
21✔
36
    const errorResponse = await payload.json().catch(() => null)
54✔
37
    if (debug) {
17✔
38
      console.log(errorResponse)
31✔
39
    }
4✔
40
    return {
14✔
41
      status: 'ERROR',
22✔
42
      message:
9✔
43
        errorResponse?.message || 'There was an error exporting the table',
73✔
44
      result: []
14✔
45
    }
1✔
46
  }
2✔
47

48
  if (type === 'json') {
25✔
49
    const response = (await payload.json()) as ExportTableResponse
42✔
50
    return response
15✔
NEW
51
  } else {
×
NEW
52
    return await payload.text()
×
53
  }
54
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc