@@ -2,14 +2,29 @@ import { serializeAiAgentReference } from './aiAgentReference';
22import { deserializeAiAgentReference } from './aiAgentReference' ;
33import { serializeAiAgentExtractStructured } from './aiAgentExtractStructured' ;
44import { deserializeAiAgentExtractStructured } from './aiAgentExtractStructured' ;
5+ import { serializeAiTaxonomyReference } from './aiTaxonomyReference' ;
6+ import { deserializeAiTaxonomyReference } from './aiTaxonomyReference' ;
7+ import { serializeAiTaxonomyFileReference } from './aiTaxonomyFileReference' ;
8+ import { deserializeAiTaxonomyFileReference } from './aiTaxonomyFileReference' ;
59import { serializeAiItemBase } from './aiItemBase' ;
610import { deserializeAiItemBase } from './aiItemBase' ;
11+ import { serializeAiExtractSubField } from './aiExtractSubField' ;
12+ import { deserializeAiExtractSubField } from './aiExtractSubField' ;
13+ import { serializeAiOptionsRules } from './aiOptionsRules' ;
14+ import { deserializeAiOptionsRules } from './aiOptionsRules' ;
715import { serializeAiExtractStructuredAgent } from './aiExtractStructuredAgent' ;
816import { deserializeAiExtractStructuredAgent } from './aiExtractStructuredAgent' ;
17+ import { serializeAiTaxonomySource } from './aiTaxonomySource' ;
18+ import { deserializeAiTaxonomySource } from './aiTaxonomySource' ;
919import { AiAgentReference } from './aiAgentReference' ;
1020import { AiAgentExtractStructured } from './aiAgentExtractStructured' ;
21+ import { AiTaxonomyReference } from './aiTaxonomyReference' ;
22+ import { AiTaxonomyFileReference } from './aiTaxonomyFileReference' ;
1123import { AiItemBase } from './aiItemBase' ;
24+ import { AiExtractSubField } from './aiExtractSubField' ;
25+ import { AiOptionsRules } from './aiOptionsRules' ;
1226import { AiExtractStructuredAgent } from './aiExtractStructuredAgent' ;
27+ import { AiTaxonomySource } from './aiTaxonomySource' ;
1328import { BoxSdkError } from '../box/errors' ;
1429import { SerializedData } from '../serialization/json' ;
1530import { sdIsEmpty } from '../serialization/json' ;
@@ -56,11 +71,21 @@ export interface AiExtractStructuredFieldsField {
5671 * The context about the key that may include how to find and format it. */
5772 readonly prompt ?: string ;
5873 /**
59- * The type of the field. It can include but is not limited to `string`, `float`, `date`, `enum`, and `multiSelect `. */
74+ * The type of the field. It can include but is not limited to `string`, `float`, `date`, `enum`, `multiSelect`,`taxonomy`, `struct`, and `table `. */
6075 readonly type ?: string ;
6176 /**
6277 * A list of options for this field. This is most often used in combination with the `enum` and `multiSelect` field types. */
6378 readonly options ?: readonly AiExtractStructuredFieldsOptionsField [ ] ;
79+ /**
80+ * The nested fields for this field. Used with `struct` and `table` field types to define the nested structure. */
81+ readonly fields ?: readonly AiExtractSubField [ ] ;
82+ /**
83+ * The identifier for a taxonomy, which corresponds to the `key` of the taxonomy source. Required if using `taxonomy` type field. */
84+ readonly taxonomyKey ?: string ;
85+ /**
86+ * The namespace of the taxonomy source. Required if using `taxonomy` type field from an existing taxonomy. */
87+ readonly namespace ?: string ;
88+ readonly optionsRules ?: AiOptionsRules ;
6489 readonly rawData ?: SerializedData ;
6590}
6691export interface AiExtractStructured {
@@ -82,6 +107,10 @@ export interface AiExtractStructured {
82107 /**
83108 * A flag to indicate whether references for every extracted field should be returned. */
84109 readonly includeReference ?: boolean ;
110+ /**
111+ * The taxonomy sources to be used for the structured extraction. They can either be an existing file or a taxonomy.
112+ * For your request to work, `fields` must also be provided. `taxonomy_sources` is not supported with `metadata_template`. */
113+ readonly taxonomySources ?: readonly AiTaxonomySource [ ] ;
85114 readonly rawData ?: SerializedData ;
86115}
87116export function serializeAiExtractStructuredMetadataTemplateTypeField (
@@ -189,6 +218,18 @@ export function serializeAiExtractStructuredFieldsField(
189218 ) : SerializedData {
190219 return serializeAiExtractStructuredFieldsOptionsField ( item ) ;
191220 } ) as readonly any [ ] ) ,
221+ [ 'fields' ] :
222+ val . fields == void 0
223+ ? val . fields
224+ : ( val . fields . map ( function ( item : AiExtractSubField ) : SerializedData {
225+ return serializeAiExtractSubField ( item ) ;
226+ } ) as readonly any [ ] ) ,
227+ [ 'taxonomy_key' ] : val . taxonomyKey ,
228+ [ 'namespace' ] : val . namespace ,
229+ [ 'options_rules' ] :
230+ val . optionsRules == void 0
231+ ? val . optionsRules
232+ : serializeAiOptionsRules ( val . optionsRules ) ,
192233 } ;
193234}
194235export function deserializeAiExtractStructuredFieldsField (
@@ -258,13 +299,51 @@ export function deserializeAiExtractStructuredFieldsField(
258299 return deserializeAiExtractStructuredFieldsOptionsField ( itm ) ;
259300 } ) as readonly any [ ] )
260301 : [ ] ;
302+ if ( ! ( val . fields == void 0 ) && ! sdIsList ( val . fields ) ) {
303+ throw new BoxSdkError ( {
304+ message :
305+ 'Expecting array for "fields" of type "AiExtractStructuredFieldsField"' ,
306+ } ) ;
307+ }
308+ const fields : undefined | readonly AiExtractSubField [ ] =
309+ val . fields == void 0
310+ ? void 0
311+ : sdIsList ( val . fields )
312+ ? ( val . fields . map ( function ( itm : SerializedData ) : AiExtractSubField {
313+ return deserializeAiExtractSubField ( itm ) ;
314+ } ) as readonly any [ ] )
315+ : [ ] ;
316+ if ( ! ( val . taxonomy_key == void 0 ) && ! sdIsString ( val . taxonomy_key ) ) {
317+ throw new BoxSdkError ( {
318+ message :
319+ 'Expecting string for "taxonomy_key" of type "AiExtractStructuredFieldsField"' ,
320+ } ) ;
321+ }
322+ const taxonomyKey : undefined | string =
323+ val . taxonomy_key == void 0 ? void 0 : val . taxonomy_key ;
324+ if ( ! ( val . namespace == void 0 ) && ! sdIsString ( val . namespace ) ) {
325+ throw new BoxSdkError ( {
326+ message :
327+ 'Expecting string for "namespace" of type "AiExtractStructuredFieldsField"' ,
328+ } ) ;
329+ }
330+ const namespace : undefined | string =
331+ val . namespace == void 0 ? void 0 : val . namespace ;
332+ const optionsRules : undefined | AiOptionsRules =
333+ val . options_rules == void 0
334+ ? void 0
335+ : deserializeAiOptionsRules ( val . options_rules ) ;
261336 return {
262337 key : key ,
263338 description : description ,
264339 displayName : displayName ,
265340 prompt : prompt ,
266341 type : type ,
267342 options : options ,
343+ fields : fields ,
344+ taxonomyKey : taxonomyKey ,
345+ namespace : namespace ,
346+ optionsRules : optionsRules ,
268347 } satisfies AiExtractStructuredFieldsField ;
269348}
270349export function serializeAiExtractStructured (
@@ -294,6 +373,14 @@ export function serializeAiExtractStructured(
294373 : serializeAiExtractStructuredAgent ( val . aiAgent ) ,
295374 [ 'include_confidence_score' ] : val . includeConfidenceScore ,
296375 [ 'include_reference' ] : val . includeReference ,
376+ [ 'taxonomy_sources' ] :
377+ val . taxonomySources == void 0
378+ ? val . taxonomySources
379+ : ( val . taxonomySources . map ( function (
380+ item : AiTaxonomySource ,
381+ ) : SerializedData {
382+ return serializeAiTaxonomySource ( item ) ;
383+ } ) as readonly any [ ] ) ,
297384 } ;
298385}
299386export function deserializeAiExtractStructured (
@@ -368,12 +455,29 @@ export function deserializeAiExtractStructured(
368455 }
369456 const includeReference : undefined | boolean =
370457 val . include_reference == void 0 ? void 0 : val . include_reference ;
458+ if ( ! ( val . taxonomy_sources == void 0 ) && ! sdIsList ( val . taxonomy_sources ) ) {
459+ throw new BoxSdkError ( {
460+ message :
461+ 'Expecting array for "taxonomy_sources" of type "AiExtractStructured"' ,
462+ } ) ;
463+ }
464+ const taxonomySources : undefined | readonly AiTaxonomySource [ ] =
465+ val . taxonomy_sources == void 0
466+ ? void 0
467+ : sdIsList ( val . taxonomy_sources )
468+ ? ( val . taxonomy_sources . map ( function (
469+ itm : SerializedData ,
470+ ) : AiTaxonomySource {
471+ return deserializeAiTaxonomySource ( itm ) ;
472+ } ) as readonly any [ ] )
473+ : [ ] ;
371474 return {
372475 items : items ,
373476 metadataTemplate : metadataTemplate ,
374477 fields : fields ,
375478 aiAgent : aiAgent ,
376479 includeConfidenceScore : includeConfidenceScore ,
377480 includeReference : includeReference ,
481+ taxonomySources : taxonomySources ,
378482 } satisfies AiExtractStructured ;
379483}
0 commit comments