1.0.0 (2024-12-16)
Features Added
-
Adds
streamToUint8Array
, a convenience function that buffers aNodeJS.ReadableStream
in aUint8Array
. It can be used to read the pdf and png responses from the results of an analysis.import DocumentIntelligence from "@azure-rest/ai-document-intelligence"; import { streamToUint8Array } from "@azure-rest/ai-document-intelligence"; const client = DocumentIntelligence("<DOCUMENT_INTELLIGENCE_ENDPOINT>", { key: "<DOCUMENT_INTELLIGENCE_API_KEY>", }); // Do analysis on you document and get the resultId, figureId // Example for the figures api that provides an image output const output = await client .path( "/documentModels/{modelId}/analyzeResults/{resultId}/figures/{figureId}", "prebuilt-layout", resultId, figureId ) .get() .asNodeStream(); // output.body would be NodeJS.ReadableStream if (output.status !== "200" || !output.body) { throw new Error("The response was unexpected, expected NodeJS.ReadableStream in the body."); } const imageData = await streamToUint8Array(output.body); fs.promises.writeFile(`./figures/${figureId}.png`, imageData); // Or you can consume the NodeJS.ReadableStream directly
-
Adds
parseResultIdFromResponse
, a convenience function that extracts theoperationId
from the batch analysis response.// Example const initialResponse = await client .path("/documentModels/{modelId}:analyzeBatch", "prebuilt-layout") .post({ contentType: "application/json", body: { azureBlobSource: { containerUrl: batchTrainingFilesContainerUrl(), }, resultContainerUrl: batchTrainingFilesResultContainerUrl(), resultPrefix: "result", }, }); if (isUnexpected(initialResponse)) { throw initialResponse.body.error; } const batchResultId = parseResultIdFromResponse(initialResponse); const response = await client .path( "/documentModels/{modelId}/analyzeBatchResults/{resultId}", "prebuilt-layout", batchResultId ) .get();
-
Changes the following interfaces as follows:
AnalyzeBatchDocumentsBodyParam
:- Updates
body
to be required.
- Updates
AnalyzeBatchOperationOutput
:- Adds
resultId
.
- Adds
AnalyzeDocumentBodyParam
:- Changes
body
from optional to required.
- Changes
DocumentClassifierDetailsOutput
:- Adds
modifiedDateTime
.
- Adds
DocumentModelDetailsOutput
:- Adds
modifiedDateTime
.
- Adds
-
Introduces new interfaces to define query parameters for document analysis requests, allowing customizable
style
andexplode
options:- AnalyzeBatchDocumentsFeaturesQueryParam: Accepts DocumentAnalysisFeature[] values.
- AnalyzeBatchDocumentsOutputQueryParam: Accepts AnalyzeOutputOption[] values.
- AnalyzeBatchDocumentsQueryFieldsQueryParam: Accepts string[] values.
- AnalyzeDocumentFeaturesQueryParam: Accepts DocumentAnalysisFeature[] values.
- AnalyzeDocumentFromStreamFeaturesQueryParam: Accepts DocumentAnalysisFeature[] values.
Breaking Changes
- Removes the
poller.getOperationId()
for a given polling operation. UseparseResultIdFromResponse
to extract theoperationId
directly. getLongRunningPoller
function is not async anymore, do notawait
on it.
Other Changes
The following types are renamed
CopyAuthorization
toModelCopyAuthorization
ErrorResponseOutput
toDocumentIntelligenceErrorResponseOutput
ErrorModelOutput
toDocumentIntelligenceErrorOutput
InnerErrorOutput
toDocumentIntelligenceInnerErrorOutput
WarningOutput
toDocumentIntelligenceWarningOutput
ContentFormat
toDocumentContentFormat
ContentFormatOutput
toDocumentContentFormatOutput
OperationDetailsOutputParent
toDocumentIntelligenceOperationDetailsOutputParent
OperationDetailsOutput
toDocumentIntelligenceOperationDetailsOutput
OperationStatusOutput
toDocumentIntelligenceOperationStatusOutput
ResourceDetailsOutput
toDocumentIntelligenceResourceDetailsOutput
PagedOperationDetailsOutput
toPagedDocumentIntelligenceOperationDetailsOutput
GetResourceInfo
toGetResourceDetails