• 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/exportFeatures.ts
1
import type { BaseRequest, BaseResponse } from '@gestell/types/base'
2
import loadFetch from '@gestell/util/fetch'
44✔
3

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

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

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

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

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

50
  if (type === 'json') {
25✔
51
    const response = (await payload.json()) as ExportFeaturesResponse
42✔
52
    return response
15✔
NEW
53
  } else {
×
NEW
54
    return await payload.text()
×
55
  }
56
}
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