• 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

2.86
/src/document/export.ts
1
import type { BaseRequest } from '@gestell/types/base'
2
import {
3
  AudioLayout,
4
  DocumentLayout,
5
  PhotoLayout,
6
  VideoLayout
7
} from '@gestell/types/layout'
8
import loadFetch from '@gestell/util/fetch'
44✔
9

10
export interface ExportDocumentRequest {
11
  collectionId: string
12
  documentId: string
13
  type?: 'json' | 'text'
14
}
15

16
export type ExportDocumentResponse =
17
  | DocumentLayout[]
18
  | AudioLayout[]
19
  | PhotoLayout[]
20
  | VideoLayout[]
21
  | string
22

NEW
23
export async function exportDocument({
×
NEW
24
  apiKey,
×
NEW
25
  apiUrl,
×
NEW
26
  debug,
×
NEW
27
  collectionId,
×
NEW
28
  documentId,
×
NEW
29
  type = 'json'
×
NEW
30
}: ExportDocumentRequest & BaseRequest): Promise<ExportDocumentResponse> {
×
NEW
31
  const fetch = await loadFetch()
×
NEW
32
  const url = new URL(
×
NEW
33
    `/api/collection/${collectionId}/document/${documentId}/export?type=${type}`,
×
NEW
34
    apiUrl
×
NEW
35
  )
×
NEW
36

×
NEW
37
  const payload = await fetch(url, {
×
NEW
38
    method: 'GET',
×
NEW
39
    headers: {
×
NEW
40
      Authorization: `BEARER ${apiKey}`
×
NEW
41
    }
×
NEW
42
  })
×
NEW
43

×
NEW
44
  if (!payload.ok) {
×
NEW
45
    const errorResponse = await payload.json().catch(() => null)
×
NEW
46
    if (debug) {
×
NEW
47
      console.log(errorResponse)
×
NEW
48
    }
×
NEW
49
    return 'ERROR EXPORTING DOCUMENT'
×
NEW
50
  }
×
NEW
51

×
NEW
52
  const response =
×
NEW
53
    type === 'json'
×
NEW
54
      ? await payload.json()
×
NEW
55
      : ((await payload.text()) as ExportDocumentResponse)
×
NEW
56

×
57
  return response
58
}
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