@azure-rest/ai-document-intelligence 1.0.0-alpha.20250401.1 → 1.0.0-alpha.20250403.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,270 @@
1
+ <!-- dev-tool snippets ignore -->
2
+
3
+ # Release History
4
+
5
+ ## 1.0.0 (2024-12-16)
6
+
7
+ ### Features Added
8
+
9
+ - Adds `streamToUint8Array`, a convenience function that buffers a `NodeJS.ReadableStream` in a `Uint8Array`. It can be used to read the pdf and png responses from the results of an analysis.
10
+
11
+ ```ts
12
+ import DocumentIntelligence from "@azure-rest/ai-document-intelligence";
13
+ import { streamToUint8Array } from "@azure-rest/ai-document-intelligence";
14
+
15
+ const client = DocumentIntelligence("<DOCUMENT_INTELLIGENCE_ENDPOINT>", {
16
+ key: "<DOCUMENT_INTELLIGENCE_API_KEY>",
17
+ });
18
+
19
+ // Do analysis on you document and get the resultId, figureId
20
+
21
+ // Example for the figures api that provides an image output
22
+ const output = await client
23
+ .path(
24
+ "/documentModels/{modelId}/analyzeResults/{resultId}/figures/{figureId}",
25
+ "prebuilt-layout",
26
+ resultId,
27
+ figureId,
28
+ )
29
+ .get()
30
+ .asNodeStream(); // output.body would be NodeJS.ReadableStream
31
+
32
+ if (output.status !== "200" || !output.body) {
33
+ throw new Error("The response was unexpected, expected NodeJS.ReadableStream in the body.");
34
+ }
35
+
36
+ const imageData = await streamToUint8Array(output.body);
37
+ fs.promises.writeFile(`./figures/${figureId}.png`, imageData); // Or you can consume the NodeJS.ReadableStream directly
38
+ ```
39
+
40
+ - Adds `parseResultIdFromResponse`, a convenience function that extracts the `operationId` from the batch analysis response.
41
+
42
+ ```js
43
+ // Example
44
+ const initialResponse = await client
45
+ .path("/documentModels/{modelId}:analyzeBatch", "prebuilt-layout")
46
+ .post({
47
+ contentType: "application/json",
48
+ body: {
49
+ azureBlobSource: {
50
+ containerUrl: batchTrainingFilesContainerUrl(),
51
+ },
52
+ resultContainerUrl: batchTrainingFilesResultContainerUrl(),
53
+ resultPrefix: "result",
54
+ },
55
+ });
56
+
57
+ if (isUnexpected(initialResponse)) {
58
+ throw initialResponse.body.error;
59
+ }
60
+ const batchResultId = parseResultIdFromResponse(initialResponse);
61
+
62
+ const response = await client
63
+ .path(
64
+ "/documentModels/{modelId}/analyzeBatchResults/{resultId}",
65
+ "prebuilt-layout",
66
+ batchResultId,
67
+ )
68
+ .get();
69
+ ```
70
+
71
+ - Changes the following interfaces as follows:
72
+
73
+ - `AnalyzeBatchDocumentsBodyParam`:
74
+ - Updates `body` to be required.
75
+ - `AnalyzeBatchOperationOutput`:
76
+ - Adds `resultId`.
77
+ - `AnalyzeDocumentBodyParam`:
78
+ - Changes `body` from optional to required.
79
+ - `DocumentClassifierDetailsOutput`:
80
+ - Adds `modifiedDateTime`.
81
+ - `DocumentModelDetailsOutput`:
82
+ - Adds `modifiedDateTime`.
83
+
84
+ - Introduces new interfaces to define query parameters for document analysis requests, allowing customizable `style` and `explode` options:
85
+ - **AnalyzeBatchDocumentsFeaturesQueryParam**: Accepts DocumentAnalysisFeature[] values.
86
+ - **AnalyzeBatchDocumentsOutputQueryParam**: Accepts AnalyzeOutputOption[] values.
87
+ - **AnalyzeBatchDocumentsQueryFieldsQueryParam**: Accepts string[] values.
88
+ - **AnalyzeDocumentFeaturesQueryParam**: Accepts DocumentAnalysisFeature[] values.
89
+ - **AnalyzeDocumentFromStreamFeaturesQueryParam**: Accepts DocumentAnalysisFeature[] values.
90
+
91
+ ### Breaking Changes
92
+
93
+ - Removes the `poller.getOperationId()` for a given polling operation. Use `parseResultIdFromResponse` to extract the `operationId` directly.
94
+ - `getLongRunningPoller` function is not async anymore, do not `await` on it.
95
+
96
+ ### Other Changes
97
+
98
+ The following types are renamed
99
+
100
+ - `CopyAuthorization` to `ModelCopyAuthorization`
101
+ - `ErrorResponseOutput` to `DocumentIntelligenceErrorResponseOutput`
102
+ - `ErrorModelOutput` to `DocumentIntelligenceErrorOutput`
103
+ - `InnerErrorOutput` to `DocumentIntelligenceInnerErrorOutput`
104
+ - `WarningOutput` to `DocumentIntelligenceWarningOutput`
105
+ - `ContentFormat` to `DocumentContentFormat`
106
+ - `ContentFormatOutput` to `DocumentContentFormatOutput`
107
+ - `OperationDetailsOutputParent` to `DocumentIntelligenceOperationDetailsOutputParent`
108
+ - `OperationDetailsOutput` to `DocumentIntelligenceOperationDetailsOutput`
109
+ - `OperationStatusOutput` to `DocumentIntelligenceOperationStatusOutput`
110
+ - `ResourceDetailsOutput` to `DocumentIntelligenceResourceDetailsOutput`
111
+ - `PagedOperationDetailsOutput` to `PagedDocumentIntelligenceOperationDetailsOutput`
112
+ - `GetResourceInfo` to `GetResourceDetails`
113
+ - `AnalyzeResultOperationOutput` to `AnalyzeOperationOutput`
114
+ - `FontWeightOutput` to `DocumentFontWeightOutput`
115
+ - `FontStyleOutput` to `DocumentFontStyleOutput`
116
+ - `DocumentOutput` to `AnalyzedDocumentOutput`
117
+ - `CopyAuthorizationOutput` to `ModelCopyAuthorizationOutput`
118
+
119
+ ## 1.0.0-beta.3 (2024-08-20)
120
+
121
+ ### Features Added
122
+
123
+ - Added support for the Analyze Batch Documents API with the long-running operations, `/documentModels/{modelId}:analyzeBatch`.
124
+ - Added support for method `/documentModels/{modelId}/analyzeResults/{resultId}/pdf`.
125
+ - Added support for method `/documentModels/{modelId}/analyzeResults/{resultId}/figures/{figureId}`.
126
+ - Added support for the analysis method to specify other kinds of output through `AnalyzeDocumentFromStreamBodyParam#output` param : can be `pdf` and `figures`.
127
+ - Added property `id` to `Output` model.
128
+ - Added support for the Copy Classifier API with method `/documentClassifiers:authorizeCopy`.
129
+ - Added method `/documentClassifiers/{classifierId}:copyTo`.
130
+ - Added new enum type to `DocumentBuildMode`: `generative`.
131
+ - Added property `warnings` to `AnalyzeResultOutput ` model.
132
+ - Added properties `classifierId`, `split`, and `trainingHours` to `DocumentModelDetailsOutput` model.
133
+ - Added properties `confidenceThreshold`, `features`, `maxDocumentsToAnalyze`, `modelId`, and `queryFields` to `DocumentTypeDetailsOutput` model.
134
+ - Added properties `allowOverwrite` and `maxTrainingHours` to `BuildDocumentModelRequest` model.
135
+ - Added parameter `pages` to `ClassifyDocument` overloads.
136
+ - Added properties `classifierId`, `docTypes`, and `split` to `ComposeDocumentModelRequest`.
137
+ - Added property `allowOverwrite` to `BuildDocumentClassifierRequest`.
138
+ - Added property `getOperationId()` method to the pollers.
139
+
140
+ ### Other Changes
141
+
142
+ - The `@azure-rest/ai-document-intelligence` Rest Level Client Library, now targets the Azure AI Document Intelligence service API version `2024-07-31-preview`. Support for `2024-02-29-preview` has been removed.
143
+ - Removed support for extracting lists from analyzed documents:
144
+ - Removed models `DocumentListOutput` and `DocumentListItemOutput`.
145
+ - Removed property `lists` from `AnalyzeResultOutput`.
146
+ - Changes to the Compose Document API:
147
+ - Removed model `ComponentDocumentModelDetails`.
148
+ - Removed property `componentModels` from `ComposeDocumentModelRequest`.
149
+ - `ComposeDocumentModelRequest` now requires a map of `DocumentTypeDetails` and a classifier ID.
150
+ - Removed model `QuotaDetailsOutput`.
151
+ - Removed property `customNeuralDocumentModelBuilds` from `ResourceDetailsOutput`.
152
+ - Removed required property `fieldSchema` and from `DocumentTypeDetailsOuput`.
153
+ - `DocumentFieldType` is now a required property of `DocumentFieldSchema`.
154
+
155
+ ## 1.0.0-beta.2 (2024-03-06)
156
+
157
+ ### Features Added
158
+
159
+ - Support for "retry-after" header has been added for long-running operations, including `/documentModels/{modelId}:analyze`, `/documentModels:build`, and `/documentClassifiers:build`.
160
+ - `BuildDocumentClassifierContent` now includes a new property, `baseClassifierId`.
161
+ - `DocumentClassifierDetailsOutput` now includes a new property, `baseClassifierId`.
162
+ - A new property, `warnings`, has been added to `DocumentModelDetailsOutput` and `DocumentClassifierDetailsOutput`, represents an array of objects with `code`, `message`, and `target`.
163
+ - `DocumentFieldOutput` now includes a new property, `valueSelectionGroup`.
164
+ - A new member, `"completed"`, has been added to `OperationDetails#status`.
165
+
166
+ ### Breaking Changes
167
+
168
+ - The `@azure-rest/ai-document-intelligence` Rest Level Client Library, previously known as Form Recognizer, now targets the Azure AI Document Intelligence service API version `"2024-02-29-preview"`. Please note that support for `2023-10-31-preview` has been discontinued.
169
+
170
+ ## 1.0.0-beta.1 (2023-11-16)
171
+
172
+ ### Features Added
173
+
174
+ This marks the first preview of `@azure-rest/ai-document-intelligence` Rest Level Client Library for the Azure AI Document Intelligence service (formerly known as Form Recognizer), targeting service API version `"2023-10-31-preview"`.
175
+
176
+ _**Note: Form Recognizer has been rebranded to Document Intelligence.**_
177
+
178
+ - Updates all REST API operation paths from `{endpoint}/formrecognizer` to `{endpoint}/documentintelligence`. SDK would handle this change automatically, users would not have to do additional work to support this.
179
+ - `@azure-rest/ai-document-intelligence` is the new package, replacing `@azure/ai-form-recognizer` package. The new package supports a Rest Level Client, which is part of the new generation of Azure SDKs to simplify the development experience. The new package is not compatible with the previous `@azure/ai-form-recognizer` package without necessary changes to your code.
180
+ - **Breaking Changes (with the `@azure/ai-form-recognizer` SDK)** - API shapes have been designed from scratch to support the new Rest Level Client for the Document Intelligence service. Please refer to the [Readme](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/documentintelligence/ai-document-intelligence-rest/README.md) and [Samples](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/documentintelligence/ai-document-intelligence-rest/samples) for more understanding.
181
+
182
+ ### `"2023-10-31-preview"` Service API version
183
+
184
+ The new `"2023-10-31-preview"` service version comes with some new features and a few breaking changes when compared to the API versions supported by the `@azure/ai-form-recognizer` library.
185
+
186
+ **New Features**
187
+
188
+ - **Markdown content format**
189
+
190
+ Supports output with Markdown content format along with the default plain _text_. For now, this is only supported for "prebuilt-layout". Markdown content format is deemed a more friendly format for LLM consumption in a chat or automation use scenario.
191
+
192
+ Service follows the GFM spec ([GitHub Flavored Markdown](https://github.github.com/gfm/)) for the Markdown format. Also introduces a new _contentFormat_ property with value "text" or "markdown" to indicate the result content format.
193
+
194
+ ```ts
195
+ import DocumentIntelligence from "@azure-rest/ai-document-intelligence";
196
+ const client = DocumentIntelligence(process.env["DOCUMENT_INTELLIGENCE_ENDPOINT"], {
197
+ key: process.env["DOCUMENT_INTELLIGENCE_API_KEY"],
198
+ });
199
+
200
+ const initialResponse = await client
201
+ .path("/documentModels/{modelId}:analyze", "prebuilt-layout")
202
+ .post({
203
+ contentType: "application/json",
204
+ body: {
205
+ urlSource:
206
+ "https://raw.githubusercontent.com/Azure/azure-sdk-for-js/6704eff082aaaf2d97c1371a28461f512f8d748a/sdk/formrecognizer/ai-form-recognizer/assets/forms/Invoice_1.pdf",
207
+ },
208
+ queryParameters: { outputContentFormat: "markdown" }, // <-- new query parameter
209
+ });
210
+ ```
211
+
212
+ - **Query Fields**
213
+
214
+ When this feature flag is specified, the service will further extract the values of the fields specified via the queryFields query parameter to supplement any existing fields defined by the model as fallback.
215
+
216
+ ```ts
217
+ await client.path("/documentModels/{modelId}:analyze", "prebuilt-layout").post({
218
+ contentType: "application/json",
219
+ body: { urlSource: "..." },
220
+ queryParameters: {
221
+ features: ["queryFields"],
222
+ queryFields: ["NumberOfGuests", "StoreNumber"],
223
+ }, // <-- new query parameter
224
+ });
225
+ ```
226
+
227
+ - **Split Options**
228
+
229
+ In the previous API versions supported by the older `@azure/ai-form-recognizer` library, document splitting and classification operation (`"/documentClassifiers/{classifierId}:analyze"`) always tried to split the input file into multiple documents.
230
+
231
+ To enable a wider set of scenarios, service introduces a "split" query parameter with the new "2023-10-31-preview" service version. The following values are supported:
232
+
233
+ - `split: "auto"`
234
+
235
+ Let service determine where to split.
236
+
237
+ - `split: "none"`
238
+
239
+ The entire file is treated as a single document. No splitting is performed.
240
+
241
+ - `split: "perPage"`
242
+
243
+ Each page is treated as a separate document. Each empty page is kept as its own document.
244
+
245
+ **Breaking Changes**
246
+
247
+ - **prebuilt-receipt** - Currency related fields have been updated. Currency symbol ("$") and code ("USD") are returned along with the amount as shown below.
248
+
249
+ ```json
250
+ {
251
+ "content": "$123.45",
252
+ "confidence": 0.995,
253
+ "type": "currency",
254
+ "valueCurrency": {
255
+ "amount": 123.45,
256
+ "currencySymbol": "$",
257
+ "currencyCode": "USD"
258
+ },
259
+ ...
260
+ }
261
+ ```
262
+
263
+ **Retirements/Deprecations**
264
+
265
+ - `"prebuilt-businessCard"` model is retired.
266
+ - `"prebuilt-document"` model is retired, this model is essentially `"prebuilt-layout"` with `features: ["keyValuePairs"]` specified. _(This is only supported as an optional feature for "prebuilt-layout" and "prebuilt-invoice".)_
267
+
268
+ If you wish to still use these models, please rely on the older `@azure/ai-form-recognizer` library through the older service API versions.
269
+
270
+ If you were using the old `@azure/ai-form-recognizer` package, please refer [MIGRATION_GUIDE.MD](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/documentintelligence/ai-document-intelligence-rest/MIGRATION-FR_v4-DI_v1.md) for more details.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azure-rest/ai-document-intelligence",
3
- "version": "1.0.0-alpha.20250401.1",
3
+ "version": "1.0.0-alpha.20250403.1",
4
4
  "description": "Document Intelligence Rest Client",
5
5
  "engines": {
6
6
  "node": ">=18.0.0"
@@ -35,7 +35,9 @@
35
35
  "files": [
36
36
  "dist/",
37
37
  "README.md",
38
- "LICENSE"
38
+ "LICENSE",
39
+ "review/",
40
+ "CHANGELOG.md"
39
41
  ],
40
42
  "sdk-type": "client",
41
43
  "repository": "github:Azure/azure-sdk-for-js",