• 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

93.62
/src/document/list.ts
1
import type { BaseRequest, BaseResponse } from '@gestell/types/base'
2
import { Document } from '@gestell/types/document'
3
import { JobStatus } from '@gestell/types/job'
4
import loadFetch from '@gestell/util/fetch'
44✔
5

6
/**
7
 * Payload for requesting multiple documents from a specific collection,
8
 * with support for pagination, filtering, and optional extended data.
9
 *
10
 * @interface GetDocumentsRequest
11
 */
12
export interface GetDocumentsRequest {
13
  /**
14
   * The unique identifier of the collection to query.
15
   */
16
  collectionId: string
17

18
  /**
19
   * Optional text to search within document content or metadata.
20
   */
21
  search?: string
22

23
  /**
24
   * Maximum number of documents to return.
25
   * Useful for paging through large result sets.
26
   */
27
  take?: number
28

29
  /**
30
   * Number of documents to skip before starting to collect the result set.
31
   * Useful for paging (e.g., skip = pageIndex * take).
32
   */
33
  skip?: number
34

35
  /**
36
   * Whether to include extended document data (metadata and layout).
37
   */
38
  extended?: boolean
39

40
  /**
41
   * Filter documents by overall enframing states.
42
   */
43
  status?: JobStatus
44

45
  /**
46
   * Filter by the status of the nodes indexing stage.
47
   */
48
  nodes?: JobStatus
49

50
  /**
51
   * Filter by the status of the edges graph-building stage.
52
   */
53
  edges?: JobStatus
54

55
  /**
56
   * Filter by the status of the vector generation stage.
57
   */
58
  vectors?: JobStatus
59

60
  /**
61
   * Filter by the status of the category generation stage.
62
   */
63
  category?: JobStatus
64
}
65

66
/**
67
 * Response data from a document listing operation.
68
 * Extends the base response with an array of documents.
69
 */
70
export interface GetDocumentsResponse extends BaseResponse {
71
  /** Array of document objects matching the query */
72
  result: Document[]
73
}
74

75
export async function getDocuments({
9✔
76
  apiKey,
9✔
77
  apiUrl,
9✔
78
  debug,
8✔
79
  collectionId,
15✔
80
  search = '',
14✔
81
  take = 10,
12✔
82
  skip = 0,
11✔
83
  extended = false,
19✔
84
  status = 'all',
17✔
85
  nodes = 'all',
16✔
86
  edges = 'all',
16✔
87
  vectors = 'all',
18✔
88
  category = 'all'
18✔
89
}: GetDocumentsRequest & BaseRequest): Promise<GetDocumentsResponse> {
3✔
90
  const fetch = await loadFetch()
34✔
91
  const url = new URL(`/api/collection/${collectionId}/document`, apiUrl)
74✔
92

93
  url.searchParams.set('search', search)
41✔
94
  url.searchParams.set('take', take.toString())
48✔
95
  url.searchParams.set('skip', skip.toString())
48✔
96
  url.searchParams.set('extended', extended.toString())
56✔
97
  url.searchParams.set('status', status)
41✔
98
  url.searchParams.set('nodes', nodes)
39✔
99
  url.searchParams.set('edges', edges)
39✔
100
  url.searchParams.set('vectors', vectors)
43✔
101
  url.searchParams.set('category', category)
45✔
102

103
  const payload = await fetch(url, {
38✔
104
    method: 'GET',
18✔
105
    headers: {
16✔
106
      Authorization: `BEARER ${apiKey}`
37✔
107
    }
3✔
108
  })
5✔
109

110
  if (!payload.ok) {
21✔
111
    const errorResponse = await payload.json().catch(() => null)
54✔
112
    if (debug) {
17✔
113
      console.log(errorResponse)
31✔
114
    }
4✔
115
    return {
14✔
116
      status: 'ERROR',
22✔
117
      message:
9✔
118
        errorResponse?.message || 'There was an error retrieving documents',
74✔
119
      result: []
14✔
120
    }
1✔
UNCOV
121
  }
×
122

UNCOV
123
  const response = (await payload.json()) as GetDocumentsResponse
×
124

UNCOV
125
  return response
×
126
}
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