From 4b3026b168b042eab239a2a6cd2327ed238595b3 Mon Sep 17 00:00:00 2001 From: box-sdk-build Date: Tue, 2 Dec 2025 07:11:43 -0800 Subject: [PATCH] docs: modify can_view_path description and add confidence scores for structured extract (box/box-openapi#566) --- .codegen.json | 2 +- src/sdk-gen/managers/userCollaborations.ts | 8 ++-- src/sdk-gen/schemas/aiExtractStructured.ts | 18 ++++++++ .../schemas/aiExtractStructuredResponse.ts | 46 +++++++++++++++++++ src/sessions/persistent-session.ts | 8 ++-- 5 files changed, 73 insertions(+), 9 deletions(-) diff --git a/.codegen.json b/.codegen.json index 115c1d5f0..898666b33 100644 --- a/.codegen.json +++ b/.codegen.json @@ -1 +1 @@ -{ "engineHash": "49f3695", "specHash": "7e4908e", "version": "4.1.1" } +{ "engineHash": "49f3695", "specHash": "5183b65", "version": "4.1.1" } diff --git a/src/sdk-gen/managers/userCollaborations.ts b/src/sdk-gen/managers/userCollaborations.ts index f5dce1301..0d55c99d5 100644 --- a/src/sdk-gen/managers/userCollaborations.ts +++ b/src/sdk-gen/managers/userCollaborations.ts @@ -238,8 +238,8 @@ export interface UpdateCollaborationByIdRequestBody { * invitee's **All Files** page. We recommend you limit the number of * collaborations with `can_view_path` enabled to 1,000 per user. * - * Only owner or co-owners can invite collaborators with a `can_view_path` of - * `true`. + * Only an owner or co-owners can invite collaborators with a `can_view_path` of + * `true`. Only an owner can update `can_view_path` on existing collaborations. * * `can_view_path` can only be used for folder collaborations. */ readonly canViewPath?: boolean; @@ -360,8 +360,8 @@ export interface CreateCollaborationRequestBody { * invitee's **All Files** page. We recommend you limit the number of * collaborations with `can_view_path` enabled to 1,000 per user. * - * Only owner or co-owners can invite collaborators with a `can_view_path` of - * `true`. + * Only an owner or co-owners can invite collaborators with a `can_view_path` of + * `true`. Only an owner can update `can_view_path` on existing collaborations. * * `can_view_path` can only be used for folder collaborations. */ readonly canViewPath?: boolean; diff --git a/src/sdk-gen/schemas/aiExtractStructured.ts b/src/sdk-gen/schemas/aiExtractStructured.ts index eb90fdafc..ac7b6aa30 100644 --- a/src/sdk-gen/schemas/aiExtractStructured.ts +++ b/src/sdk-gen/schemas/aiExtractStructured.ts @@ -75,6 +75,9 @@ export interface AiExtractStructured { * The fields to be extracted from the provided items. * For your request to work, you must provide either `metadata_template` or `fields`, but not both. */ readonly fields?: readonly AiExtractStructuredFieldsField[]; + /** + * A flag to indicate whether confidence scores for every extracted field should be returned. */ + readonly includeConfidenceScore?: boolean; readonly aiAgent?: AiExtractStructuredAgent; readonly rawData?: SerializedData; } @@ -282,6 +285,7 @@ export function serializeAiExtractStructured( ): SerializedData { return serializeAiExtractStructuredFieldsField(item); }) as readonly any[]), + ['include_confidence_score']: val.includeConfidenceScore, ['ai_agent']: val.aiAgent == void 0 ? val.aiAgent @@ -332,6 +336,19 @@ export function deserializeAiExtractStructured( return deserializeAiExtractStructuredFieldsField(itm); }) as readonly any[]) : []; + if ( + !(val.include_confidence_score == void 0) && + !sdIsBoolean(val.include_confidence_score) + ) { + throw new BoxSdkError({ + message: + 'Expecting boolean for "include_confidence_score" of type "AiExtractStructured"', + }); + } + const includeConfidenceScore: undefined | boolean = + val.include_confidence_score == void 0 + ? void 0 + : val.include_confidence_score; const aiAgent: undefined | AiExtractStructuredAgent = val.ai_agent == void 0 ? void 0 @@ -340,6 +357,7 @@ export function deserializeAiExtractStructured( items: items, metadataTemplate: metadataTemplate, fields: fields, + includeConfidenceScore: includeConfidenceScore, aiAgent: aiAgent, } satisfies AiExtractStructured; } diff --git a/src/sdk-gen/schemas/aiExtractStructuredResponse.ts b/src/sdk-gen/schemas/aiExtractStructuredResponse.ts index dbb4ac273..b67736a2d 100644 --- a/src/sdk-gen/schemas/aiExtractStructuredResponse.ts +++ b/src/sdk-gen/schemas/aiExtractStructuredResponse.ts @@ -23,6 +23,11 @@ export interface AiExtractStructuredResponse { /** * The reason the response finishes. */ readonly completionReason?: string; + /** + * The confidence score numeric values for each extracted field as a JSON dictionary. This can be empty if no field could be extracted. */ + readonly confidenceScore?: { + readonly [key: string]: any; + }; readonly aiAgentInfo?: AiAgentInfo; readonly rawData?: SerializedData; } @@ -33,6 +38,19 @@ export function serializeAiExtractStructuredResponse( ['answer']: serializeAiExtractResponse(val.answer), ['created_at']: serializeDateTime(val.createdAt), ['completion_reason']: val.completionReason, + ['confidence_score']: + val.confidenceScore == void 0 + ? val.confidenceScore + : (Object.fromEntries( + Object.entries(val.confidenceScore).map(([k, v]: [string, any]) => [ + k, + (function (v: any): any { + return v; + })(v), + ]) + ) as { + readonly [key: string]: any; + }), ['ai_agent_info']: val.aiAgentInfo == void 0 ? val.aiAgentInfo @@ -78,6 +96,33 @@ export function deserializeAiExtractStructuredResponse( } const completionReason: undefined | string = val.completion_reason == void 0 ? void 0 : val.completion_reason; + if (!(val.confidence_score == void 0) && !sdIsMap(val.confidence_score)) { + throw new BoxSdkError({ + message: + 'Expecting object for "confidence_score" of type "AiExtractStructuredResponse"', + }); + } + const confidenceScore: + | undefined + | { + readonly [key: string]: any; + } = + val.confidence_score == void 0 + ? void 0 + : sdIsMap(val.confidence_score) + ? (Object.fromEntries( + Object.entries(val.confidence_score).map( + ([k, v]: [string, any]) => [ + k, + (function (v: any): any { + return v; + })(v), + ] + ) + ) as { + readonly [key: string]: any; + }) + : {}; const aiAgentInfo: undefined | AiAgentInfo = val.ai_agent_info == void 0 ? void 0 @@ -86,6 +131,7 @@ export function deserializeAiExtractStructuredResponse( answer: answer, createdAt: createdAt, completionReason: completionReason, + confidenceScore: confidenceScore, aiAgentInfo: aiAgentInfo, } satisfies AiExtractStructuredResponse; } diff --git a/src/sessions/persistent-session.ts b/src/sessions/persistent-session.ts index 1852f81fb..2de97a09d 100644 --- a/src/sessions/persistent-session.ts +++ b/src/sessions/persistent-session.ts @@ -36,10 +36,10 @@ type TokenRequestOptions = Record /* FIXME */; function isObjectValidTokenInfo(obj: Record) { return Boolean( obj && - obj.accessToken && - obj.refreshToken && - obj.accessTokenTTLMS && - obj.acquiredAtMS + obj.accessToken && + obj.refreshToken && + obj.accessTokenTTLMS && + obj.acquiredAtMS ); }