|
| 1 | +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. |
| 2 | + |
| 3 | +import { APIResource } from '../core/resource'; |
| 4 | +import { APIPromise } from '../core/api-promise'; |
| 5 | +import { RequestOptions } from '../internal/request-options'; |
| 6 | +import { path } from '../internal/utils/path'; |
| 7 | + |
| 8 | +export class Beta extends APIResource { |
| 9 | + /** |
| 10 | + * Retrieve labels automatically detected for cells and ranges in the workbook. |
| 11 | + */ |
| 12 | + getWorkbookLabels(id: string, options?: RequestOptions): APIPromise<BetaGetWorkbookLabelsResponse> { |
| 13 | + return this._client.get(path`/v1/workbooks/${id}/labels`, options); |
| 14 | + } |
| 15 | + |
| 16 | + /** |
| 17 | + * Search data labels across all spreadsheets uploaded to an account |
| 18 | + */ |
| 19 | + searchLabels(body: BetaSearchLabelsParams, options?: RequestOptions): APIPromise<BetaSearchLabelsResponse> { |
| 20 | + return this._client.post('/v1/workbooks/search/labels', { body, ...options }); |
| 21 | + } |
| 22 | +} |
| 23 | + |
| 24 | +export interface BetaGetWorkbookLabelsResponse { |
| 25 | + /** |
| 26 | + * The date/time the labels were detected and stored |
| 27 | + */ |
| 28 | + created: string; |
| 29 | + |
| 30 | + /** |
| 31 | + * The labels associated with the workbook |
| 32 | + */ |
| 33 | + labels: Array<BetaGetWorkbookLabelsResponse.Label>; |
| 34 | + |
| 35 | + /** |
| 36 | + * The id of the workbook the labels belong to |
| 37 | + */ |
| 38 | + workbook_id: string; |
| 39 | + |
| 40 | + /** |
| 41 | + * The version of the workbook the labels belong to |
| 42 | + */ |
| 43 | + workbook_version: number; |
| 44 | +} |
| 45 | + |
| 46 | +export namespace BetaGetWorkbookLabelsResponse { |
| 47 | + export interface Label { |
| 48 | + /** |
| 49 | + * The cell address/reference which the label applies to |
| 50 | + */ |
| 51 | + at: string; |
| 52 | + |
| 53 | + /** |
| 54 | + * The cell address/reference which the label applies to |
| 55 | + */ |
| 56 | + for: string; |
| 57 | + |
| 58 | + /** |
| 59 | + * The label string |
| 60 | + */ |
| 61 | + text: string; |
| 62 | + |
| 63 | + /** |
| 64 | + * The type of the label, almost always text, not to be confused with cell type |
| 65 | + */ |
| 66 | + type?: string | null; |
| 67 | + } |
| 68 | +} |
| 69 | + |
| 70 | +/** |
| 71 | + * The results of a spreadsheet data label search. |
| 72 | + */ |
| 73 | +export interface BetaSearchLabelsResponse { |
| 74 | + results: Array<BetaSearchLabelsResponse.Result>; |
| 75 | +} |
| 76 | + |
| 77 | +export namespace BetaSearchLabelsResponse { |
| 78 | + /** |
| 79 | + * Contains a workbook that includes data labels that match the search query. |
| 80 | + */ |
| 81 | + export interface Result { |
| 82 | + /** |
| 83 | + * UUID for the user that uploaded the workbook. This will always be the UUID of |
| 84 | + * the account linked to the API key used in the request. |
| 85 | + */ |
| 86 | + creator_id: string; |
| 87 | + |
| 88 | + /** |
| 89 | + * Generated description summarising the contents of the workbook |
| 90 | + */ |
| 91 | + description: string; |
| 92 | + |
| 93 | + /** |
| 94 | + * Original filename of the workbook |
| 95 | + */ |
| 96 | + filename: string; |
| 97 | + |
| 98 | + /** |
| 99 | + * Most recent version number of the workbook |
| 100 | + */ |
| 101 | + latest_version: number; |
| 102 | + |
| 103 | + /** |
| 104 | + * Absolute URL for a thumbnail of the workbook's first sheet |
| 105 | + */ |
| 106 | + thumbnail_url: string; |
| 107 | + |
| 108 | + /** |
| 109 | + * UUID for the workbook |
| 110 | + */ |
| 111 | + workbook_id: string; |
| 112 | + |
| 113 | + labels?: Array<Result.Label>; |
| 114 | + |
| 115 | + /** |
| 116 | + * Relevance ranking of the workbook in relation to the search results (higher is |
| 117 | + * better) |
| 118 | + */ |
| 119 | + score?: number | null; |
| 120 | + } |
| 121 | + |
| 122 | + export namespace Result { |
| 123 | + /** |
| 124 | + * A label search result. Includes the location, text content, value, and score. |
| 125 | + */ |
| 126 | + export interface Label { |
| 127 | + /** |
| 128 | + * Cell reference or range that contains the labelled data |
| 129 | + */ |
| 130 | + for: string; |
| 131 | + |
| 132 | + /** |
| 133 | + * Text content of the label |
| 134 | + */ |
| 135 | + text: string; |
| 136 | + |
| 137 | + /** |
| 138 | + * The labelled data value(s). If a range of data is labelled, this will be a |
| 139 | + * stringified JSON array |
| 140 | + */ |
| 141 | + value: string; |
| 142 | + |
| 143 | + /** |
| 144 | + * Relevance ranking of the workbook in relation to the search results (higher is |
| 145 | + * better) |
| 146 | + */ |
| 147 | + score?: number | null; |
| 148 | + } |
| 149 | + } |
| 150 | +} |
| 151 | + |
| 152 | +export interface BetaSearchLabelsParams { |
| 153 | + query: string; |
| 154 | + |
| 155 | + /** |
| 156 | + * Maximum number of labels to return per workbook |
| 157 | + */ |
| 158 | + max_labels?: number | null; |
| 159 | + |
| 160 | + /** |
| 161 | + * Maximum number of workbooks to return results for |
| 162 | + */ |
| 163 | + max_results?: number | null; |
| 164 | +} |
| 165 | + |
| 166 | +export declare namespace Beta { |
| 167 | + export { |
| 168 | + type BetaGetWorkbookLabelsResponse as BetaGetWorkbookLabelsResponse, |
| 169 | + type BetaSearchLabelsResponse as BetaSearchLabelsResponse, |
| 170 | + type BetaSearchLabelsParams as BetaSearchLabelsParams, |
| 171 | + }; |
| 172 | +} |
0 commit comments