|
| 1 | +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. |
| 2 | + |
| 3 | +import { APIResource } from '../../resource'; |
| 4 | +import { isRequestOptions } from '../../core'; |
| 5 | +import * as Core from '../../core'; |
| 6 | +import { ContentsPage, type ContentsPageParams } from '../../pagination'; |
| 7 | + |
| 8 | +export class Contents extends APIResource { |
| 9 | + /** |
| 10 | + * Get Document Contents |
| 11 | + */ |
| 12 | + list( |
| 13 | + datastoreId: string, |
| 14 | + query?: ContentListParams, |
| 15 | + options?: Core.RequestOptions, |
| 16 | + ): Core.PagePromise<ContentListResponsesContentsPage, ContentListResponse>; |
| 17 | + list( |
| 18 | + datastoreId: string, |
| 19 | + options?: Core.RequestOptions, |
| 20 | + ): Core.PagePromise<ContentListResponsesContentsPage, ContentListResponse>; |
| 21 | + list( |
| 22 | + datastoreId: string, |
| 23 | + query: ContentListParams | Core.RequestOptions = {}, |
| 24 | + options?: Core.RequestOptions, |
| 25 | + ): Core.PagePromise<ContentListResponsesContentsPage, ContentListResponse> { |
| 26 | + if (isRequestOptions(query)) { |
| 27 | + return this.list(datastoreId, {}, query); |
| 28 | + } |
| 29 | + return this._client.getAPIList(`/datastores/${datastoreId}/contents`, ContentListResponsesContentsPage, { |
| 30 | + query, |
| 31 | + ...options, |
| 32 | + }); |
| 33 | + } |
| 34 | + |
| 35 | + /** |
| 36 | + * Get Content Metadata |
| 37 | + */ |
| 38 | + metadata( |
| 39 | + datastoreId: string, |
| 40 | + contentId: string, |
| 41 | + query?: ContentMetadataParams, |
| 42 | + options?: Core.RequestOptions, |
| 43 | + ): Core.APIPromise<ContentMetadataResponse>; |
| 44 | + metadata( |
| 45 | + datastoreId: string, |
| 46 | + contentId: string, |
| 47 | + options?: Core.RequestOptions, |
| 48 | + ): Core.APIPromise<ContentMetadataResponse>; |
| 49 | + metadata( |
| 50 | + datastoreId: string, |
| 51 | + contentId: string, |
| 52 | + query: ContentMetadataParams | Core.RequestOptions = {}, |
| 53 | + options?: Core.RequestOptions, |
| 54 | + ): Core.APIPromise<ContentMetadataResponse> { |
| 55 | + if (isRequestOptions(query)) { |
| 56 | + return this.metadata(datastoreId, contentId, {}, query); |
| 57 | + } |
| 58 | + return this._client.get(`/datastores/${datastoreId}/contents/${contentId}/metadata`, { |
| 59 | + query, |
| 60 | + ...options, |
| 61 | + }); |
| 62 | + } |
| 63 | +} |
| 64 | + |
| 65 | +export class ContentListResponsesContentsPage extends ContentsPage<ContentListResponse> {} |
| 66 | + |
| 67 | +/** |
| 68 | + * Content entry type |
| 69 | + */ |
| 70 | +export type ContentListResponse = |
| 71 | + | ContentListResponse.DocumentContentEntry |
| 72 | + | ContentListResponse.StructuredContentEntry; |
| 73 | + |
| 74 | +export namespace ContentListResponse { |
| 75 | + export interface DocumentContentEntry { |
| 76 | + /** |
| 77 | + * ID of the content |
| 78 | + */ |
| 79 | + content_id: string; |
| 80 | + |
| 81 | + /** |
| 82 | + * Page number of the content |
| 83 | + */ |
| 84 | + page_number: number; |
| 85 | + |
| 86 | + content_type?: 'unstructured'; |
| 87 | + } |
| 88 | + |
| 89 | + /** |
| 90 | + * Tabular content entry used in query retrieval. |
| 91 | + */ |
| 92 | + export interface StructuredContentEntry { |
| 93 | + /** |
| 94 | + * ID of the content |
| 95 | + */ |
| 96 | + content_id: string; |
| 97 | + |
| 98 | + /** |
| 99 | + * Name of the table |
| 100 | + */ |
| 101 | + table_name: string; |
| 102 | + |
| 103 | + content_type?: 'structured'; |
| 104 | + |
| 105 | + /** |
| 106 | + * Name of the schema of the table |
| 107 | + */ |
| 108 | + schema?: string | null; |
| 109 | + } |
| 110 | +} |
| 111 | + |
| 112 | +/** |
| 113 | + * Content type |
| 114 | + */ |
| 115 | +export type ContentMetadataResponse = |
| 116 | + | ContentMetadataResponse.UnstructuredContentMetadata |
| 117 | + | ContentMetadataResponse.StructuredContentMetadata |
| 118 | + | ContentMetadataResponse.FileAnalysisContentMetadata; |
| 119 | + |
| 120 | +export namespace ContentMetadataResponse { |
| 121 | + export interface UnstructuredContentMetadata { |
| 122 | + /** |
| 123 | + * Id of the content. |
| 124 | + */ |
| 125 | + content_id: string; |
| 126 | + |
| 127 | + /** |
| 128 | + * Text of the content. |
| 129 | + */ |
| 130 | + content_text: string; |
| 131 | + |
| 132 | + /** |
| 133 | + * Id of the document which the content belongs to. |
| 134 | + */ |
| 135 | + document_id: string; |
| 136 | + |
| 137 | + /** |
| 138 | + * Height of the image. |
| 139 | + */ |
| 140 | + height: number; |
| 141 | + |
| 142 | + /** |
| 143 | + * Page number of the content. |
| 144 | + */ |
| 145 | + page: number; |
| 146 | + |
| 147 | + /** |
| 148 | + * Image of the page on which the content occurs. |
| 149 | + */ |
| 150 | + page_img: string; |
| 151 | + |
| 152 | + /** |
| 153 | + * Width of the image. |
| 154 | + */ |
| 155 | + width: number; |
| 156 | + |
| 157 | + /** |
| 158 | + * X coordinate of the top left corner on the bounding box. |
| 159 | + */ |
| 160 | + x0: number; |
| 161 | + |
| 162 | + /** |
| 163 | + * X coordinate of the bottom right corner on the bounding box. |
| 164 | + */ |
| 165 | + x1: number; |
| 166 | + |
| 167 | + /** |
| 168 | + * Y coordinate of the top left corner on the bounding box. |
| 169 | + */ |
| 170 | + y0: number; |
| 171 | + |
| 172 | + /** |
| 173 | + * Y coordinate of the bottom right corner on the bounding box. |
| 174 | + */ |
| 175 | + y1: number; |
| 176 | + |
| 177 | + content_type?: 'unstructured'; |
| 178 | + } |
| 179 | + |
| 180 | + export interface StructuredContentMetadata { |
| 181 | + /** |
| 182 | + * Id of the content. |
| 183 | + */ |
| 184 | + content_id: string; |
| 185 | + |
| 186 | + /** |
| 187 | + * Text of the content. |
| 188 | + */ |
| 189 | + content_text: unknown; |
| 190 | + |
| 191 | + content_type?: 'structured'; |
| 192 | + } |
| 193 | + |
| 194 | + export interface FileAnalysisContentMetadata { |
| 195 | + /** |
| 196 | + * Id of the content. |
| 197 | + */ |
| 198 | + content_id: string; |
| 199 | + |
| 200 | + /** |
| 201 | + * Format of the file. |
| 202 | + */ |
| 203 | + file_format: string; |
| 204 | + |
| 205 | + /** |
| 206 | + * GCP location of the file. |
| 207 | + */ |
| 208 | + gcp_location: string; |
| 209 | + |
| 210 | + content_type?: 'file_analysis'; |
| 211 | + } |
| 212 | +} |
| 213 | + |
| 214 | +export interface ContentListParams extends ContentsPageParams { |
| 215 | + /** |
| 216 | + * Document ID of the document to retrieve details for |
| 217 | + */ |
| 218 | + document_id?: string; |
| 219 | + |
| 220 | + /** |
| 221 | + * The query to search keywords for |
| 222 | + */ |
| 223 | + search?: string; |
| 224 | +} |
| 225 | + |
| 226 | +export interface ContentMetadataParams { |
| 227 | + cursor?: string; |
| 228 | +} |
| 229 | + |
| 230 | +Contents.ContentListResponsesContentsPage = ContentListResponsesContentsPage; |
| 231 | + |
| 232 | +export declare namespace Contents { |
| 233 | + export { |
| 234 | + type ContentListResponse as ContentListResponse, |
| 235 | + type ContentMetadataResponse as ContentMetadataResponse, |
| 236 | + ContentListResponsesContentsPage as ContentListResponsesContentsPage, |
| 237 | + type ContentListParams as ContentListParams, |
| 238 | + type ContentMetadataParams as ContentMetadataParams, |
| 239 | + }; |
| 240 | +} |
0 commit comments