@azure/ai-form-recognizer 4.0.0-beta.6 → 4.0.0

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.
Files changed (29) hide show
  1. package/README.md +20 -22
  2. package/dist/index.js +274 -327
  3. package/dist/index.js.map +1 -1
  4. package/dist-esm/src/constants.js +1 -1
  5. package/dist-esm/src/constants.js.map +1 -1
  6. package/dist-esm/src/documentModel.js.map +1 -1
  7. package/dist-esm/src/documentModelAdministrationClient.js +32 -32
  8. package/dist-esm/src/documentModelAdministrationClient.js.map +1 -1
  9. package/dist-esm/src/generated/generatedClient.js +33 -54
  10. package/dist-esm/src/generated/generatedClient.js.map +1 -1
  11. package/dist-esm/src/generated/models/index.js +2 -14
  12. package/dist-esm/src/generated/models/index.js.map +1 -1
  13. package/dist-esm/src/generated/models/mappers.js +189 -189
  14. package/dist-esm/src/generated/models/mappers.js.map +1 -1
  15. package/dist-esm/src/generated/models/parameters.js +4 -38
  16. package/dist-esm/src/generated/models/parameters.js.map +1 -1
  17. package/dist-esm/src/index.js.map +1 -1
  18. package/dist-esm/src/lro/administration.js +3 -3
  19. package/dist-esm/src/lro/administration.js.map +1 -1
  20. package/dist-esm/src/lro/analysis.js +2 -2
  21. package/dist-esm/src/lro/analysis.js.map +1 -1
  22. package/dist-esm/src/models/documentElements.js.map +1 -1
  23. package/dist-esm/src/options/BuildModelOptions.js.map +1 -1
  24. package/dist-esm/src/options/DeleteModelOptions.js.map +1 -1
  25. package/dist-esm/src/options/FormRecognizerClientOptions.js +3 -2
  26. package/dist-esm/src/options/FormRecognizerClientOptions.js.map +1 -1
  27. package/dist-esm/src/options/index.js.map +1 -1
  28. package/package.json +1 -1
  29. package/types/ai-form-recognizer.d.ts +108 -65
package/README.md CHANGED
@@ -16,14 +16,14 @@ Azure Cognitive Services [Form Recognizer](https://azure.microsoft.com/services/
16
16
 
17
17
  #### **_Breaking change advisory_ ⚠️**
18
18
 
19
- In version 4 (currently beta), this package introduces a full redesign of the Azure Form Recognizer client library. To leverage features of the newest Form Recognizer service API (version "2022-06-30-preview" and newer), the new SDK is required, and application code must be changed to use the new clients. Please see the [Migration Guide](https://github.com/azure/azure-sdk-for-js/blob/main/sdk/formrecognizer/ai-form-recognizer/MIGRATION-v3_v4.md) for detailed instructions on how to update application code from version 3.x of the Form Recognizer SDK to the new version (4.x). Additionally, the [CHANGELOG](https://github.com/azure/azure-sdk-for-js/blob/main/sdk/formrecognizer/ai-form-recognizer/CHANGELOG.md) contains an outline of the changes since version 3.x. This package targets Azure Form Recognizer service API version `2022-06-30-preview` and newer. To continue to use Form Recognizer API version 2.1, please use major version 3 of the client package (`@azure/ai-form-recognizer@^3.2.0`).
19
+ In version 4.0.0, this package introduces a full redesign of the Azure Form Recognizer client library. To leverage features of the newest Form Recognizer service API (version "2022-08-31" and newer), the new SDK is required, and application code must be changed to use the new clients. Please see the [Migration Guide](https://github.com/azure/azure-sdk-for-js/blob/main/sdk/formrecognizer/ai-form-recognizer/MIGRATION-v3_v4.md) for detailed instructions on how to update application code from version 3.x of the Form Recognizer SDK to the new version (4.x). Additionally, the [CHANGELOG](https://github.com/azure/azure-sdk-for-js/blob/main/sdk/formrecognizer/ai-form-recognizer/CHANGELOG.md) contains an outline of the changes since version 3.x. This package targets Azure Form Recognizer service API version `2022-08-31` and newer. To continue to use Form Recognizer API version 2.1, please use major version 3 of the client package (`@azure/ai-form-recognizer@^3.2.0`).
20
20
 
21
21
  ### Install the `@azure/ai-form-recognizer` package
22
22
 
23
23
  Install the Azure Form Recognizer client library for JavaScript with `npm`:
24
24
 
25
25
  ```bash
26
- npm install @azure/ai-form-recognizer@4.0.0-beta.5
26
+ npm install @azure/ai-form-recognizer
27
27
  ```
28
28
 
29
29
  ## Getting started
@@ -143,11 +143,11 @@ const client = new DocumentAnalysisClient("<endpoint>", new DefaultAzureCredenti
143
143
 
144
144
  `DocumentModelAdministrationClient` provides operations for managing (creating, reading, listing, and deleting) models in the Form Recognizer resource:
145
145
 
146
- - `beginBuildModel` starts an operation to create a new document model from your own training data set. The created model can extract fields according to a custom schema. The training data are expected to be located in an Azure Storage container and organized according to a particular convention. See the [service's documentation on creating a training data set][fr-build-training-set] for a more detailed explanation of applying labels to a training data set.
147
- - `beginComposeModel` starts an operation to compose multiple models into a single model. When used for custom form recognition, the new composed model will first perform a classification of the input documents to determine which of its submodels is most appropriate.
146
+ - `beginBuildDocumentModel` starts an operation to create a new document model from your own training data set. The created model can extract fields according to a custom schema. The training data are expected to be located in an Azure Storage container and organized according to a particular convention. See the [service's documentation on creating a training data set][fr-build-training-set] for a more detailed explanation of applying labels to a training data set.
147
+ - `beginComposeDocumentModel` starts an operation to compose multiple models into a single model. When used for custom form recognition, the new composed model will first perform a classification of the input documents to determine which of its submodels is most appropriate.
148
148
  - `beginCopyModelTo` starts an operation to copy a custom model from one Form Recognizer resource to another (or even to the same Form Recognizer resource). It requires a `CopyAuthorization` from the target Form Recognizer resource, which can be generated using the `getCopyAuthorization` method.
149
149
  - `getResourceDetails` retrieves information about the Form Recognizer resource's limits, such as the number of custom models and the maximum number of models the resource can support.
150
- - `getModel`, `listModels`, and `deleteModel` enable managing models in the resource.
150
+ - `getDocumentModel`, `listDocumentModels`, and `deleteDocumentModel` enable managing models in the resource.
151
151
  - `getOperation` and `listOperations` enable viewing the status of model creation operations, even those operations that are ongoing or that have failed. Operations are retained for 24 hours.
152
152
 
153
153
  Please note that models can also be created using the Form Recognizer service's graphical user interface: [Form Recognizer Studio (Preview)][fr-studio].
@@ -200,7 +200,7 @@ async function main() {
200
200
  const { documents, pages, tables } = await poller.pollUntilDone();
201
201
 
202
202
  console.log("Documents:");
203
- for (const document of documents) {
203
+ for (const document of documents || []) {
204
204
  console.log(`Type: ${document.docType}`);
205
205
  console.log("Fields:");
206
206
  for (const [name, field] of Object.entries(document.fields)) {
@@ -210,12 +210,12 @@ async function main() {
210
210
  }
211
211
  }
212
212
  console.log("Pages:");
213
- for (const page of pages) {
213
+ for (const page of pages || []) {
214
214
  console.log(`Page number: ${page.pageNumber} (${page.width}x${page.height} ${page.unit})`);
215
215
  }
216
216
 
217
217
  console.log("Tables:");
218
- for (const table of tables) {
218
+ for (const table of tables || []) {
219
219
  console.log(`- Table (${table.columnCount}x${table.rowCount})`);
220
220
  for (const cell of table.cells) {
221
221
  console.log(` - cell (${cell.rowIndex},${cell.columnIndex}) "${cell.content}"`);
@@ -239,7 +239,7 @@ The `beginAnalyzeDocument` method also supports extracting fields from certain t
239
239
  <a id="prebuiltmodels-removed"></a>
240
240
  **Breaking Change Warning** ⚠️: In previous `4.0.0-beta` versions of the Azure Form Recognizer SDK for JavaScript, prebuilt `DocumentModel` objects were exported from the package through an object named `PrebuiltModels`. This object has been removed and replaced with the [`DocumentModel` samples][samples-prebuilt], which you may use as part of your own project. This change will enable us to continue to provide timely updates and ensure stability as the number of supported prebuilt models increases and as their capabilities are enhanced.
241
241
 
242
- Example `DocumentModel` objects for the current service API version (`2022-06-30-preview`) can be found in [the `prebuilt` samples directory][samples-prebuilt]. In the following example, we'll use the `PrebuiltReceiptModel` from the [`prebuilt-receipt.ts`] file in that directory.
242
+ Example `DocumentModel` objects for the current service API version (`2022-08-31`) can be found in [the `prebuilt` samples directory][samples-prebuilt]. In the following example, we'll use the `PrebuiltReceiptModel` from the [`prebuilt-receipt.ts`] file in that directory.
243
243
 
244
244
  Since the main benefit of `DocumentModel`-based analysis is stronger TypeScript type constraints, the following sample is written in TypeScript using ECMAScript module syntax:
245
245
 
@@ -310,7 +310,6 @@ You are not limited to receipts! There are a few prebuilt models to choose from,
310
310
  - Identity Documents (such as driver licenses and passports), using [`PrebuiltIdDocumentModel`][samples-prebuilt-iddocument] or its model ID `"prebuilt-idDocument"`.
311
311
  - W2 Tax Forms (United States), using [`PrebuiltTaxUsW2Model`][samples-prebuilt-tax.us.w2] or its model ID `"prebuilt-tax.us.w2"`.
312
312
  - Health Insurance Cards (United States), using [`PrebuiltHealthInsuranceCardUsModel`][samples-prebuilt-healthinsurancecard.us] or its model ID `"prebuilt-healthInsuranceCard.us"`.
313
- - Vaccination Cards (currently supports US COVID-19 vaccination cards), using [`PrebuiltVaccinationCardModel`][samples-prebuilt-vaccinationcard] or its model ID `"prebuilt-vaccinationCard"`.
314
313
 
315
314
  Each of the above prebuilt models produces `documents` (extracted instances of the model's field schema). There are also three prebuilt models that do not have field schemas and therefore do not produce `documents`. They are:
316
315
 
@@ -320,7 +319,7 @@ Each of the above prebuilt models produces `documents` (extracted instances of t
320
319
 
321
320
  For information about the fields of all of these models, see [the service's documentation of the available prebuilt models](https://aka.ms/azsdk/formrecognizer/models).
322
321
 
323
- The fields of all prebuilt models may also be accessed programmatically using the `getModel` method (by their model IDs) of `DocumentModelAdministrationClient` and inspecting the `docTypes` field in the result.
322
+ The fields of all prebuilt models may also be accessed programmatically using the `getDocumentModel` method (by their model IDs) of `DocumentModelAdministrationClient` and inspecting the `docTypes` field in the result.
324
323
 
325
324
  ### Use the "layout" prebuilt
326
325
 
@@ -518,7 +517,7 @@ async function main() {
518
517
  // The second parameter is the SAS-encoded URL to an Azure Storage container with the training documents.
519
518
  // The third parameter is the build mode: one of "template" (the only mode prior to 4.0.0-beta.3) or "neural".
520
519
  // See https://aka.ms/azsdk/formrecognizer/buildmode for more information about build modes.
521
- const poller = await client.beginBuildModel("<model ID>", containerSasUrl, "template", {
520
+ const poller = await client.beginBuildDocumentModel("<model ID>", containerSasUrl, "template", {
522
521
  // The model description is optional and can be any text.
523
522
  description: "This is my new model!",
524
523
  onProgress: ({ status }) => {
@@ -529,7 +528,7 @@ async function main() {
529
528
 
530
529
  console.log("Model ID:", model.modelId);
531
530
  console.log("Description:", model.description);
532
- console.log("Created:", model.createdDateTime);
531
+ console.log("Created:", model.createdOn);
533
532
 
534
533
  // A model may contain several document types, which describe the possible object structures of fields extracted using
535
534
  // this model
@@ -571,10 +570,10 @@ async function main() {
571
570
  const apiKey = "<api key>";
572
571
  const client = new DocumentModelAdministrationClient(endpoint, new AzureKeyCredential(apiKey));
573
572
 
574
- // Produces an async iterable that supports paging (`PagedAsyncIterableIterator`). The `listModels` method will only
573
+ // Produces an async iterable that supports paging (`PagedAsyncIterableIterator`). The `listDocumentModels` method will only
575
574
  // iterate over model summaries, which do not include detailed schema information. Schema information is only returned
576
- // from `getModel` as part of the full model information.
577
- const models = client.listModels();
575
+ // from `getDocumentModel` as part of the full model information.
576
+ const models = client.listDocumentModels();
578
577
  let i = 1;
579
578
  for await (const summary of models) {
580
579
  console.log(`Model ${i++}:`, summary);
@@ -582,23 +581,23 @@ async function main() {
582
581
 
583
582
  // The iterable is paged, and the application can control the flow of paging if needed
584
583
  i = 1;
585
- for await (const page of client.listModels().byPage()) {
584
+ for await (const page of client.listDocumentModels().byPage()) {
586
585
  for (const summary of page) {
587
586
  console.log(`Model ${i++}`, summary);
588
587
  }
589
588
  }
590
589
 
591
590
  // We can also get a full ModelInfo by ID. Here we only show the basic information. See the documentation and the
592
- // `getModel` sample program for information about the `docTypes` field, which contains the model's document type
591
+ // `getDocumentModel` sample program for information about the `docTypes` field, which contains the model's document type
593
592
  // schemas.
594
- const model = await client.getModel("<model ID>");
593
+ const model = await client.getDocumentModel("<model ID>");
595
594
  console.log("ID", model.modelId);
596
- console.log("Created:", model.createdDateTime);
595
+ console.log("Created:", model.createdOn);
597
596
  console.log("Description: ", model.description ?? "<none>");
598
597
 
599
598
  // A model can also be deleted by its model ID. Once it is deleted, it CANNOT be recovered.
600
599
  const modelIdToDelete = "<model ID that should be deleted forever>";
601
- await client.deleteModel(modelIdToDelete);
600
+ await client.deleteDocumentModel(modelIdToDelete);
602
601
  }
603
602
 
604
603
  main().catch((err) => {
@@ -661,4 +660,3 @@ If you'd like to contribute to this library, please read the [contributing guide
661
660
  [samples-prebuilt-read]: https://github.com/azure/azure-sdk-for-js/blob/main/sdk/formrecognizer/ai-form-recognizer/samples-dev/prebuilt/prebuilt-read.ts
662
661
  [samples-prebuilt-receipt]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/formrecognizer/ai-form-recognizer/samples-dev/prebuilt/prebuilt-receipt.ts
663
662
  [samples-prebuilt-tax.us.w2]: https://github.com/azure/azure-sdk-for-js/blob/main/sdk/formrecognizer/ai-form-recognizer/samples-dev/prebuilt/prebuilt-tax.us.w2.ts
664
- [samples-prebuilt-vaccinationcard]: https://github.com/azure/azure-sdk-for-js/blob/main/sdk/formrecognizer/ai-form-recognizer/samples-dev/prebuilt/prebuilt-vaccinationCard.ts