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

Gestell-AI / node-sdk / #11

15 May 2025 11:50PM UTC coverage: 91.743%. Remained the same
#11

push

ChrisCates
v1.4.0 - Refactored Shapes & SDK

- Expose types with clearer shapes
- Add PII controls
- Support single-entry categories
- Update table records & prompt features
- Refactor code & IntelliSense
- Enhance API shape tests
- Cleaned project structure

243 of 244 new or added lines in 19 files covered. (99.59%)

46 existing lines in 6 files now uncovered.

1400 of 1526 relevant lines covered (91.74%)

21.06 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
/**
11
 * Request parameters for exporting a document from a collection.
12
 */
13
export interface ExportDocumentRequest {
14
  /** ID of the collection containing the document */
15
  collectionId: string
16
  /** ID of the document to export */
17
  documentId: string
18
  /** Format of the exported document (defaults to JSON if not specified) */
19
  type?: 'json' | 'text'
20
}
21

22
/**
23
 * Response data from a document export operation.
24
 * Returns layout arrays for various media types or a string representation.
25
 */
26
export type ExportDocumentResponse =
27
  | DocumentLayout[]
28
  | AudioLayout[]
29
  | PhotoLayout[]
30
  | VideoLayout[]
31
  | string
32

UNCOV
33
export async function exportDocument({
×
UNCOV
34
  apiKey,
×
UNCOV
35
  apiUrl,
×
UNCOV
36
  debug,
×
UNCOV
37
  collectionId,
×
UNCOV
38
  documentId,
×
UNCOV
39
  type = 'json'
×
UNCOV
40
}: ExportDocumentRequest & BaseRequest): Promise<ExportDocumentResponse> {
×
UNCOV
41
  const fetch = await loadFetch()
×
UNCOV
42
  const url = new URL(
×
43
    `/api/collection/${collectionId}/document/${documentId}/export?type=${type}`,
×
44
    apiUrl
×
45
  )
×
46

×
47
  const payload = await fetch(url, {
×
48
    method: 'GET',
×
49
    headers: {
×
50
      Authorization: `BEARER ${apiKey}`
×
51
    }
×
52
  })
×
53

×
54
  if (!payload.ok) {
×
55
    const errorResponse = await payload.json().catch(() => null)
×
56
    if (debug) {
×
57
      console.log(errorResponse)
×
58
    }
×
59
    return 'ERROR EXPORTING DOCUMENT'
×
60
  }
×
61

×
62
  const response =
×
63
    type === 'json'
×
64
      ? await payload.json()
×
65
      : ((await payload.text()) as ExportDocumentResponse)
×
66

×
67
  return response
68
}
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