@azure/ai-form-recognizer 4.0.0-beta.4 → 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 (92) hide show
  1. package/README.md +206 -184
  2. package/dist/index.js +588 -1992
  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/documentAnalysisClient.js +30 -227
  7. package/dist-esm/src/documentAnalysisClient.js.map +1 -1
  8. package/dist-esm/src/documentModel.js +71 -0
  9. package/dist-esm/src/documentModel.js.map +1 -0
  10. package/dist-esm/src/documentModelAdministrationClient.js +59 -59
  11. package/dist-esm/src/documentModelAdministrationClient.js.map +1 -1
  12. package/dist-esm/src/generated/generatedClient.js +63 -101
  13. package/dist-esm/src/generated/generatedClient.js.map +1 -1
  14. package/dist-esm/src/generated/models/index.js +40 -9
  15. package/dist-esm/src/generated/models/index.js.map +1 -1
  16. package/dist-esm/src/generated/models/mappers.js +207 -205
  17. package/dist-esm/src/generated/models/mappers.js.map +1 -1
  18. package/dist-esm/src/generated/models/parameters.js +4 -38
  19. package/dist-esm/src/generated/models/parameters.js.map +1 -1
  20. package/dist-esm/src/index.js +1 -1
  21. package/dist-esm/src/index.js.map +1 -1
  22. package/dist-esm/src/lro/{training.js → administration.js} +4 -4
  23. package/dist-esm/src/lro/administration.js.map +1 -0
  24. package/dist-esm/src/lro/{analyze.js → analysis.js} +12 -11
  25. package/dist-esm/src/lro/analysis.js.map +1 -0
  26. package/dist-esm/src/models/documentElements.js.map +1 -1
  27. package/dist-esm/src/models/index.js.map +1 -1
  28. package/dist-esm/src/options/AnalyzeDocumentsOptions.js.map +1 -1
  29. package/dist-esm/src/options/{CopyModelOptions.js → BeginCopyModelOptions.js} +1 -1
  30. package/dist-esm/src/options/BeginCopyModelOptions.js.map +1 -0
  31. package/dist-esm/src/options/BuildModelOptions.js.map +1 -1
  32. package/dist-esm/src/options/DeleteModelOptions.js.map +1 -1
  33. package/dist-esm/src/options/FormRecognizerClientOptions.js +3 -2
  34. package/dist-esm/src/options/FormRecognizerClientOptions.js.map +1 -1
  35. package/dist-esm/src/options/{GetInfoOptions.js → GetResourceDetailsOptions.js} +1 -1
  36. package/dist-esm/src/options/GetResourceDetailsOptions.js.map +1 -0
  37. package/dist-esm/src/options/index.js.map +1 -1
  38. package/dist-esm/src/util.js.map +1 -1
  39. package/package.json +16 -10
  40. package/types/ai-form-recognizer.d.ts +388 -1753
  41. package/dist-esm/src/generated/generatedClientContext.js +0 -41
  42. package/dist-esm/src/generated/generatedClientContext.js.map +0 -1
  43. package/dist-esm/src/lro/analyze.js.map +0 -1
  44. package/dist-esm/src/lro/training.js.map +0 -1
  45. package/dist-esm/src/models/GeneralDocumentResult.js +0 -13
  46. package/dist-esm/src/models/GeneralDocumentResult.js.map +0 -1
  47. package/dist-esm/src/models/LayoutResult.js +0 -15
  48. package/dist-esm/src/models/LayoutResult.js.map +0 -1
  49. package/dist-esm/src/models/ReadResult.js +0 -18
  50. package/dist-esm/src/models/ReadResult.js.map +0 -1
  51. package/dist-esm/src/options/CopyModelOptions.js.map +0 -1
  52. package/dist-esm/src/options/GetInfoOptions.js.map +0 -1
  53. package/dist-esm/src/prebuilt/index.js +0 -9
  54. package/dist-esm/src/prebuilt/index.js.map +0 -1
  55. package/dist-esm/src/prebuilt/modelSchemas/businessCard.js +0 -5
  56. package/dist-esm/src/prebuilt/modelSchemas/businessCard.js.map +0 -1
  57. package/dist-esm/src/prebuilt/modelSchemas/data/prebuilt-businessCard.json.js +0 -93
  58. package/dist-esm/src/prebuilt/modelSchemas/data/prebuilt-businessCard.json.js.map +0 -1
  59. package/dist-esm/src/prebuilt/modelSchemas/data/prebuilt-document.json.js +0 -12
  60. package/dist-esm/src/prebuilt/modelSchemas/data/prebuilt-document.json.js.map +0 -1
  61. package/dist-esm/src/prebuilt/modelSchemas/data/prebuilt-healthInsuranceCard.us.json.js +0 -153
  62. package/dist-esm/src/prebuilt/modelSchemas/data/prebuilt-healthInsuranceCard.us.json.js.map +0 -1
  63. package/dist-esm/src/prebuilt/modelSchemas/data/prebuilt-idDocument.json.js +0 -89
  64. package/dist-esm/src/prebuilt/modelSchemas/data/prebuilt-idDocument.json.js.map +0 -1
  65. package/dist-esm/src/prebuilt/modelSchemas/data/prebuilt-invoice.json.js +0 -144
  66. package/dist-esm/src/prebuilt/modelSchemas/data/prebuilt-invoice.json.js.map +0 -1
  67. package/dist-esm/src/prebuilt/modelSchemas/data/prebuilt-layout.json.js +0 -12
  68. package/dist-esm/src/prebuilt/modelSchemas/data/prebuilt-layout.json.js.map +0 -1
  69. package/dist-esm/src/prebuilt/modelSchemas/data/prebuilt-read.json.js +0 -12
  70. package/dist-esm/src/prebuilt/modelSchemas/data/prebuilt-read.json.js.map +0 -1
  71. package/dist-esm/src/prebuilt/modelSchemas/data/prebuilt-receipt.json.js +0 -341
  72. package/dist-esm/src/prebuilt/modelSchemas/data/prebuilt-receipt.json.js.map +0 -1
  73. package/dist-esm/src/prebuilt/modelSchemas/data/prebuilt-tax.us.w2.json.js +0 -155
  74. package/dist-esm/src/prebuilt/modelSchemas/data/prebuilt-tax.us.w2.json.js.map +0 -1
  75. package/dist-esm/src/prebuilt/modelSchemas/data/prebuilt-vaccinationCard.json.js +0 -50
  76. package/dist-esm/src/prebuilt/modelSchemas/data/prebuilt-vaccinationCard.json.js.map +0 -1
  77. package/dist-esm/src/prebuilt/modelSchemas/healthInsuranceCard.js +0 -5
  78. package/dist-esm/src/prebuilt/modelSchemas/healthInsuranceCard.js.map +0 -1
  79. package/dist-esm/src/prebuilt/modelSchemas/idDocument.js +0 -5
  80. package/dist-esm/src/prebuilt/modelSchemas/idDocument.js.map +0 -1
  81. package/dist-esm/src/prebuilt/modelSchemas/invoice.js +0 -5
  82. package/dist-esm/src/prebuilt/modelSchemas/invoice.js.map +0 -1
  83. package/dist-esm/src/prebuilt/modelSchemas/receipt.js +0 -5
  84. package/dist-esm/src/prebuilt/modelSchemas/receipt.js.map +0 -1
  85. package/dist-esm/src/prebuilt/modelSchemas/vaccinationCard.js +0 -5
  86. package/dist-esm/src/prebuilt/modelSchemas/vaccinationCard.js.map +0 -1
  87. package/dist-esm/src/prebuilt/modelSchemas/w2.js +0 -5
  88. package/dist-esm/src/prebuilt/modelSchemas/w2.js.map +0 -1
  89. package/dist-esm/src/prebuilt/models.js +0 -150
  90. package/dist-esm/src/prebuilt/models.js.map +0 -1
  91. package/dist-esm/src/prebuilt/schema.js +0 -4
  92. package/dist-esm/src/prebuilt/schema.js.map +0 -1
package/dist/index.js CHANGED
@@ -39,7 +39,7 @@ const DEFAULT_COGNITIVE_SCOPE = "https://cognitiveservices.azure.com/.default";
39
39
  /**
40
40
  * @internal
41
41
  */
42
- const SDK_VERSION = "4.0.0-beta.4";
42
+ const SDK_VERSION = "4.0.0";
43
43
 
44
44
  /*
45
45
  * Copyright (c) Microsoft Corporation.
@@ -171,14 +171,14 @@ const AnalyzeResultOperation = {
171
171
  allowedValues: ["notStarted", "running", "failed", "succeeded"]
172
172
  }
173
173
  },
174
- createdDateTime: {
174
+ createdOn: {
175
175
  serializedName: "createdDateTime",
176
176
  required: true,
177
177
  type: {
178
178
  name: "DateTime"
179
179
  }
180
180
  },
181
- lastUpdatedDateTime: {
181
+ lastUpdatedOn: {
182
182
  serializedName: "lastUpdatedDateTime",
183
183
  required: true,
184
184
  type: {
@@ -331,13 +331,6 @@ const DocumentPage = {
331
331
  name: "Composite",
332
332
  className: "DocumentPage",
333
333
  modelProperties: {
334
- kind: {
335
- serializedName: "kind",
336
- required: true,
337
- type: {
338
- name: "String"
339
- }
340
- },
341
334
  pageNumber: {
342
335
  constraints: {
343
336
  InclusiveMinimum: 1
@@ -419,18 +412,6 @@ const DocumentPage = {
419
412
  }
420
413
  }
421
414
  },
422
- images: {
423
- serializedName: "images",
424
- type: {
425
- name: "Sequence",
426
- element: {
427
- type: {
428
- name: "Composite",
429
- className: "DocumentImage"
430
- }
431
- }
432
- }
433
- },
434
415
  lines: {
435
416
  serializedName: "lines",
436
417
  type: {
@@ -568,56 +549,6 @@ const DocumentSelectionMark = {
568
549
  }
569
550
  }
570
551
  };
571
- const DocumentImage = {
572
- type: {
573
- name: "Composite",
574
- className: "DocumentImage",
575
- modelProperties: {
576
- polygon: {
577
- serializedName: "polygon",
578
- type: {
579
- name: "Sequence",
580
- element: {
581
- constraints: {
582
- InclusiveMinimum: 0
583
- },
584
- type: {
585
- name: "Number"
586
- }
587
- }
588
- }
589
- },
590
- span: {
591
- serializedName: "span",
592
- type: {
593
- name: "Composite",
594
- className: "DocumentSpan"
595
- }
596
- },
597
- pageRef: {
598
- constraints: {
599
- InclusiveMinimum: 0
600
- },
601
- serializedName: "pageRef",
602
- required: true,
603
- type: {
604
- name: "Number"
605
- }
606
- },
607
- confidence: {
608
- constraints: {
609
- InclusiveMaximum: 1,
610
- InclusiveMinimum: 0
611
- },
612
- serializedName: "confidence",
613
- required: true,
614
- type: {
615
- name: "Number"
616
- }
617
- }
618
- }
619
- }
620
- };
621
552
  const DocumentLine = {
622
553
  type: {
623
554
  name: "Composite",
@@ -777,25 +708,6 @@ const DocumentTable = {
777
708
  }
778
709
  }
779
710
  },
780
- caption: {
781
- serializedName: "caption",
782
- type: {
783
- name: "Composite",
784
- className: "DocumentCaption"
785
- }
786
- },
787
- footnotes: {
788
- serializedName: "footnotes",
789
- type: {
790
- name: "Sequence",
791
- element: {
792
- type: {
793
- name: "Composite",
794
- className: "DocumentFootnote"
795
- }
796
- }
797
- }
798
- },
799
711
  boundingRegions: {
800
712
  serializedName: "boundingRegions",
801
713
  type: {
@@ -905,86 +817,6 @@ const DocumentTableCell = {
905
817
  }
906
818
  }
907
819
  };
908
- const DocumentCaption = {
909
- type: {
910
- name: "Composite",
911
- className: "DocumentCaption",
912
- modelProperties: {
913
- content: {
914
- serializedName: "content",
915
- required: true,
916
- type: {
917
- name: "String"
918
- }
919
- },
920
- boundingRegions: {
921
- serializedName: "boundingRegions",
922
- type: {
923
- name: "Sequence",
924
- element: {
925
- type: {
926
- name: "Composite",
927
- className: "BoundingRegion"
928
- }
929
- }
930
- }
931
- },
932
- spans: {
933
- serializedName: "spans",
934
- required: true,
935
- type: {
936
- name: "Sequence",
937
- element: {
938
- type: {
939
- name: "Composite",
940
- className: "DocumentSpan"
941
- }
942
- }
943
- }
944
- }
945
- }
946
- }
947
- };
948
- const DocumentFootnote = {
949
- type: {
950
- name: "Composite",
951
- className: "DocumentFootnote",
952
- modelProperties: {
953
- content: {
954
- serializedName: "content",
955
- required: true,
956
- type: {
957
- name: "String"
958
- }
959
- },
960
- boundingRegions: {
961
- serializedName: "boundingRegions",
962
- type: {
963
- name: "Sequence",
964
- element: {
965
- type: {
966
- name: "Composite",
967
- className: "BoundingRegion"
968
- }
969
- }
970
- }
971
- },
972
- spans: {
973
- serializedName: "spans",
974
- required: true,
975
- type: {
976
- name: "Sequence",
977
- element: {
978
- type: {
979
- name: "Composite",
980
- className: "DocumentSpan"
981
- }
982
- }
983
- }
984
- }
985
- }
986
- }
987
- };
988
820
  const DocumentKeyValuePair = {
989
821
  type: {
990
822
  name: "Composite",
@@ -1520,7 +1352,7 @@ const ComposeDocumentModelRequest = {
1520
1352
  element: {
1521
1353
  type: {
1522
1354
  name: "Composite",
1523
- className: "ComponentModelInfo"
1355
+ className: "ComponentDocumentModelDetails"
1524
1356
  }
1525
1357
  }
1526
1358
  }
@@ -1535,10 +1367,10 @@ const ComposeDocumentModelRequest = {
1535
1367
  }
1536
1368
  }
1537
1369
  };
1538
- const ComponentModelInfo = {
1370
+ const ComponentDocumentModelDetails = {
1539
1371
  type: {
1540
1372
  name: "Composite",
1541
- className: "ComponentModelInfo",
1373
+ className: "ComponentDocumentModelDetails",
1542
1374
  modelProperties: {
1543
1375
  modelId: {
1544
1376
  constraints: {
@@ -1653,7 +1485,7 @@ const GetOperationsResponse = {
1653
1485
  element: {
1654
1486
  type: {
1655
1487
  name: "Composite",
1656
- className: "OperationInfo"
1488
+ className: "OperationSummary"
1657
1489
  }
1658
1490
  }
1659
1491
  }
@@ -1667,10 +1499,95 @@ const GetOperationsResponse = {
1667
1499
  }
1668
1500
  }
1669
1501
  };
1670
- const OperationInfo = {
1502
+ const OperationSummary = {
1503
+ type: {
1504
+ name: "Composite",
1505
+ className: "OperationSummary",
1506
+ modelProperties: {
1507
+ operationId: {
1508
+ serializedName: "operationId",
1509
+ required: true,
1510
+ type: {
1511
+ name: "String"
1512
+ }
1513
+ },
1514
+ status: {
1515
+ serializedName: "status",
1516
+ required: true,
1517
+ type: {
1518
+ name: "Enum",
1519
+ allowedValues: [
1520
+ "notStarted",
1521
+ "running",
1522
+ "failed",
1523
+ "succeeded",
1524
+ "canceled"
1525
+ ]
1526
+ }
1527
+ },
1528
+ percentCompleted: {
1529
+ constraints: {
1530
+ InclusiveMaximum: 100,
1531
+ InclusiveMinimum: 0
1532
+ },
1533
+ serializedName: "percentCompleted",
1534
+ type: {
1535
+ name: "Number"
1536
+ }
1537
+ },
1538
+ createdOn: {
1539
+ serializedName: "createdDateTime",
1540
+ required: true,
1541
+ type: {
1542
+ name: "DateTime"
1543
+ }
1544
+ },
1545
+ lastUpdatedOn: {
1546
+ serializedName: "lastUpdatedDateTime",
1547
+ required: true,
1548
+ type: {
1549
+ name: "DateTime"
1550
+ }
1551
+ },
1552
+ kind: {
1553
+ serializedName: "kind",
1554
+ required: true,
1555
+ type: {
1556
+ name: "String"
1557
+ }
1558
+ },
1559
+ resourceLocation: {
1560
+ serializedName: "resourceLocation",
1561
+ required: true,
1562
+ type: {
1563
+ name: "String"
1564
+ }
1565
+ },
1566
+ apiVersion: {
1567
+ serializedName: "apiVersion",
1568
+ type: {
1569
+ name: "String"
1570
+ }
1571
+ },
1572
+ tags: {
1573
+ serializedName: "tags",
1574
+ type: {
1575
+ name: "Dictionary",
1576
+ value: { type: { name: "String" } }
1577
+ }
1578
+ }
1579
+ }
1580
+ }
1581
+ };
1582
+ const OperationDetails = {
1671
1583
  type: {
1672
1584
  name: "Composite",
1673
- className: "OperationInfo",
1585
+ className: "OperationDetails",
1586
+ uberParent: "OperationDetails",
1587
+ polymorphicDiscriminator: {
1588
+ serializedName: "kind",
1589
+ clientName: "kind"
1590
+ },
1674
1591
  modelProperties: {
1675
1592
  operationId: {
1676
1593
  serializedName: "operationId",
@@ -1703,14 +1620,14 @@ const OperationInfo = {
1703
1620
  name: "Number"
1704
1621
  }
1705
1622
  },
1706
- createdDateTime: {
1623
+ createdOn: {
1707
1624
  serializedName: "createdDateTime",
1708
1625
  required: true,
1709
1626
  type: {
1710
1627
  name: "DateTime"
1711
1628
  }
1712
1629
  },
1713
- lastUpdatedDateTime: {
1630
+ lastUpdatedOn: {
1714
1631
  serializedName: "lastUpdatedDateTime",
1715
1632
  required: true,
1716
1633
  type: {
@@ -1743,14 +1660,21 @@ const OperationInfo = {
1743
1660
  name: "Dictionary",
1744
1661
  value: { type: { name: "String" } }
1745
1662
  }
1663
+ },
1664
+ error: {
1665
+ serializedName: "error",
1666
+ type: {
1667
+ name: "Composite",
1668
+ className: "ErrorModel"
1669
+ }
1746
1670
  }
1747
1671
  }
1748
1672
  }
1749
1673
  };
1750
- const GetModelsResponse = {
1674
+ const GetDocumentModelsResponse = {
1751
1675
  type: {
1752
1676
  name: "Composite",
1753
- className: "GetModelsResponse",
1677
+ className: "GetDocumentModelsResponse",
1754
1678
  modelProperties: {
1755
1679
  value: {
1756
1680
  serializedName: "value",
@@ -1760,7 +1684,7 @@ const GetModelsResponse = {
1760
1684
  element: {
1761
1685
  type: {
1762
1686
  name: "Composite",
1763
- className: "ModelSummary"
1687
+ className: "DocumentModelSummary"
1764
1688
  }
1765
1689
  }
1766
1690
  }
@@ -1774,10 +1698,10 @@ const GetModelsResponse = {
1774
1698
  }
1775
1699
  }
1776
1700
  };
1777
- const ModelSummary = {
1701
+ const DocumentModelSummary = {
1778
1702
  type: {
1779
1703
  name: "Composite",
1780
- className: "ModelSummary",
1704
+ className: "DocumentModelSummary",
1781
1705
  modelProperties: {
1782
1706
  modelId: {
1783
1707
  constraints: {
@@ -1798,7 +1722,7 @@ const ModelSummary = {
1798
1722
  name: "String"
1799
1723
  }
1800
1724
  },
1801
- createdDateTime: {
1725
+ createdOn: {
1802
1726
  serializedName: "createdDateTime",
1803
1727
  required: true,
1804
1728
  type: {
@@ -1821,11 +1745,21 @@ const ModelSummary = {
1821
1745
  }
1822
1746
  }
1823
1747
  };
1824
- const DocTypeInfo = {
1748
+ const DocumentModelDetails = {
1825
1749
  type: {
1826
1750
  name: "Composite",
1827
- className: "DocTypeInfo",
1751
+ className: "DocumentModelDetails",
1828
1752
  modelProperties: {
1753
+ modelId: {
1754
+ constraints: {
1755
+ Pattern: new RegExp("[a-zA-Z0-9][a-zA-Z0-9._~-]{1,63}")
1756
+ },
1757
+ serializedName: "modelId",
1758
+ required: true,
1759
+ type: {
1760
+ name: "String"
1761
+ }
1762
+ },
1829
1763
  description: {
1830
1764
  constraints: {
1831
1765
  MaxLength: 4096
@@ -1835,15 +1769,61 @@ const DocTypeInfo = {
1835
1769
  name: "String"
1836
1770
  }
1837
1771
  },
1838
- buildMode: {
1839
- serializedName: "buildMode",
1772
+ createdOn: {
1773
+ serializedName: "createdDateTime",
1774
+ required: true,
1840
1775
  type: {
1841
- name: "String"
1776
+ name: "DateTime"
1842
1777
  }
1843
1778
  },
1844
- fieldSchema: {
1845
- serializedName: "fieldSchema",
1846
- required: true,
1779
+ apiVersion: {
1780
+ serializedName: "apiVersion",
1781
+ type: {
1782
+ name: "String"
1783
+ }
1784
+ },
1785
+ tags: {
1786
+ serializedName: "tags",
1787
+ type: {
1788
+ name: "Dictionary",
1789
+ value: { type: { name: "String" } }
1790
+ }
1791
+ },
1792
+ docTypes: {
1793
+ serializedName: "docTypes",
1794
+ type: {
1795
+ name: "Dictionary",
1796
+ value: {
1797
+ type: { name: "Composite", className: "DocumentTypeDetails" }
1798
+ }
1799
+ }
1800
+ }
1801
+ }
1802
+ }
1803
+ };
1804
+ const DocumentTypeDetails = {
1805
+ type: {
1806
+ name: "Composite",
1807
+ className: "DocumentTypeDetails",
1808
+ modelProperties: {
1809
+ description: {
1810
+ constraints: {
1811
+ MaxLength: 4096
1812
+ },
1813
+ serializedName: "description",
1814
+ type: {
1815
+ name: "String"
1816
+ }
1817
+ },
1818
+ buildMode: {
1819
+ serializedName: "buildMode",
1820
+ type: {
1821
+ name: "String"
1822
+ }
1823
+ },
1824
+ fieldSchema: {
1825
+ serializedName: "fieldSchema",
1826
+ required: true,
1847
1827
  type: {
1848
1828
  name: "Dictionary",
1849
1829
  value: {
@@ -1907,25 +1887,25 @@ const DocumentFieldSchema = {
1907
1887
  }
1908
1888
  }
1909
1889
  };
1910
- const GetInfoResponse = {
1890
+ const ResourceDetails = {
1911
1891
  type: {
1912
1892
  name: "Composite",
1913
- className: "GetInfoResponse",
1893
+ className: "ResourceDetails",
1914
1894
  modelProperties: {
1915
1895
  customDocumentModels: {
1916
1896
  serializedName: "customDocumentModels",
1917
1897
  type: {
1918
1898
  name: "Composite",
1919
- className: "CustomDocumentModelsInfo"
1899
+ className: "CustomDocumentModelsDetails"
1920
1900
  }
1921
1901
  }
1922
1902
  }
1923
1903
  }
1924
1904
  };
1925
- const CustomDocumentModelsInfo = {
1905
+ const CustomDocumentModelsDetails = {
1926
1906
  type: {
1927
1907
  name: "Composite",
1928
- className: "CustomDocumentModelsInfo",
1908
+ className: "CustomDocumentModelsDetails",
1929
1909
  modelProperties: {
1930
1910
  count: {
1931
1911
  serializedName: "count",
@@ -1944,34 +1924,50 @@ const CustomDocumentModelsInfo = {
1944
1924
  }
1945
1925
  }
1946
1926
  };
1947
- const GetOperationResponse = {
1927
+ const DocumentModelBuildOperationDetails = {
1928
+ serializedName: "documentModelBuild",
1948
1929
  type: {
1949
1930
  name: "Composite",
1950
- className: "GetOperationResponse",
1951
- modelProperties: Object.assign(Object.assign({}, OperationInfo.type.modelProperties), { error: {
1952
- serializedName: "error",
1931
+ className: "DocumentModelBuildOperationDetails",
1932
+ uberParent: "OperationDetails",
1933
+ polymorphicDiscriminator: OperationDetails.type.polymorphicDiscriminator,
1934
+ modelProperties: Object.assign(Object.assign({}, OperationDetails.type.modelProperties), { result: {
1935
+ serializedName: "result",
1953
1936
  type: {
1954
1937
  name: "Composite",
1955
- className: "ErrorModel"
1938
+ className: "DocumentModelDetails"
1956
1939
  }
1957
- }, result: {
1940
+ } })
1941
+ }
1942
+ };
1943
+ const DocumentModelComposeOperationDetails = {
1944
+ serializedName: "documentModelCompose",
1945
+ type: {
1946
+ name: "Composite",
1947
+ className: "DocumentModelComposeOperationDetails",
1948
+ uberParent: "OperationDetails",
1949
+ polymorphicDiscriminator: OperationDetails.type.polymorphicDiscriminator,
1950
+ modelProperties: Object.assign(Object.assign({}, OperationDetails.type.modelProperties), { result: {
1958
1951
  serializedName: "result",
1959
1952
  type: {
1960
- name: "Dictionary",
1961
- value: { type: { name: "any" } }
1953
+ name: "Composite",
1954
+ className: "DocumentModelDetails"
1962
1955
  }
1963
1956
  } })
1964
1957
  }
1965
1958
  };
1966
- const ModelInfo = {
1959
+ const DocumentModelCopyToOperationDetails = {
1960
+ serializedName: "documentModelCopyTo",
1967
1961
  type: {
1968
1962
  name: "Composite",
1969
- className: "ModelInfo",
1970
- modelProperties: Object.assign(Object.assign({}, ModelSummary.type.modelProperties), { docTypes: {
1971
- serializedName: "docTypes",
1963
+ className: "DocumentModelCopyToOperationDetails",
1964
+ uberParent: "OperationDetails",
1965
+ polymorphicDiscriminator: OperationDetails.type.polymorphicDiscriminator,
1966
+ modelProperties: Object.assign(Object.assign({}, OperationDetails.type.modelProperties), { result: {
1967
+ serializedName: "result",
1972
1968
  type: {
1973
- name: "Dictionary",
1974
- value: { type: { name: "Composite", className: "DocTypeInfo" } }
1969
+ name: "Composite",
1970
+ className: "DocumentModelDetails"
1975
1971
  }
1976
1972
  } })
1977
1973
  }
@@ -2032,6 +2028,12 @@ const GeneratedClientCopyDocumentModelToHeaders = {
2032
2028
  }
2033
2029
  }
2034
2030
  };
2031
+ let discriminators = {
2032
+ OperationDetails: OperationDetails,
2033
+ "OperationDetails.documentModelBuild": DocumentModelBuildOperationDetails,
2034
+ "OperationDetails.documentModelCompose": DocumentModelComposeOperationDetails,
2035
+ "OperationDetails.documentModelCopyTo": DocumentModelCopyToOperationDetails
2036
+ };
2035
2037
 
2036
2038
  var Mappers = /*#__PURE__*/Object.freeze({
2037
2039
  __proto__: null,
@@ -2045,14 +2047,11 @@ var Mappers = /*#__PURE__*/Object.freeze({
2045
2047
  DocumentSpan: DocumentSpan,
2046
2048
  DocumentWord: DocumentWord,
2047
2049
  DocumentSelectionMark: DocumentSelectionMark,
2048
- DocumentImage: DocumentImage,
2049
2050
  DocumentLine: DocumentLine,
2050
2051
  DocumentParagraph: DocumentParagraph,
2051
2052
  BoundingRegion: BoundingRegion,
2052
2053
  DocumentTable: DocumentTable,
2053
2054
  DocumentTableCell: DocumentTableCell,
2054
- DocumentCaption: DocumentCaption,
2055
- DocumentFootnote: DocumentFootnote,
2056
2055
  DocumentKeyValuePair: DocumentKeyValuePair,
2057
2056
  DocumentKeyValueElement: DocumentKeyValueElement,
2058
2057
  DocumentStyle: DocumentStyle,
@@ -2064,23 +2063,27 @@ var Mappers = /*#__PURE__*/Object.freeze({
2064
2063
  BuildDocumentModelRequest: BuildDocumentModelRequest,
2065
2064
  AzureBlobContentSource: AzureBlobContentSource,
2066
2065
  ComposeDocumentModelRequest: ComposeDocumentModelRequest,
2067
- ComponentModelInfo: ComponentModelInfo,
2066
+ ComponentDocumentModelDetails: ComponentDocumentModelDetails,
2068
2067
  AuthorizeCopyRequest: AuthorizeCopyRequest,
2069
2068
  CopyAuthorization: CopyAuthorization,
2070
2069
  GetOperationsResponse: GetOperationsResponse,
2071
- OperationInfo: OperationInfo,
2072
- GetModelsResponse: GetModelsResponse,
2073
- ModelSummary: ModelSummary,
2074
- DocTypeInfo: DocTypeInfo,
2070
+ OperationSummary: OperationSummary,
2071
+ OperationDetails: OperationDetails,
2072
+ GetDocumentModelsResponse: GetDocumentModelsResponse,
2073
+ DocumentModelSummary: DocumentModelSummary,
2074
+ DocumentModelDetails: DocumentModelDetails,
2075
+ DocumentTypeDetails: DocumentTypeDetails,
2075
2076
  DocumentFieldSchema: DocumentFieldSchema,
2076
- GetInfoResponse: GetInfoResponse,
2077
- CustomDocumentModelsInfo: CustomDocumentModelsInfo,
2078
- GetOperationResponse: GetOperationResponse,
2079
- ModelInfo: ModelInfo,
2077
+ ResourceDetails: ResourceDetails,
2078
+ CustomDocumentModelsDetails: CustomDocumentModelsDetails,
2079
+ DocumentModelBuildOperationDetails: DocumentModelBuildOperationDetails,
2080
+ DocumentModelComposeOperationDetails: DocumentModelComposeOperationDetails,
2081
+ DocumentModelCopyToOperationDetails: DocumentModelCopyToOperationDetails,
2080
2082
  GeneratedClientAnalyzeDocumentHeaders: GeneratedClientAnalyzeDocumentHeaders,
2081
2083
  GeneratedClientBuildDocumentModelHeaders: GeneratedClientBuildDocumentModelHeaders,
2082
2084
  GeneratedClientComposeDocumentModelHeaders: GeneratedClientComposeDocumentModelHeaders,
2083
- GeneratedClientCopyDocumentModelToHeaders: GeneratedClientCopyDocumentModelToHeaders
2085
+ GeneratedClientCopyDocumentModelToHeaders: GeneratedClientCopyDocumentModelToHeaders,
2086
+ discriminators: discriminators
2084
2087
  });
2085
2088
 
2086
2089
  /*
@@ -2100,9 +2103,6 @@ const contentType = {
2100
2103
  allowedValues: [
2101
2104
  "application/octet-stream",
2102
2105
  "application/pdf",
2103
- "application/vnd.openxmlformats-officedocument.presentationml.presentation",
2104
- "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
2105
- "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
2106
2106
  "image/bmp",
2107
2107
  "image/heif",
2108
2108
  "image/jpeg",
@@ -2133,37 +2133,6 @@ const accept = {
2133
2133
  }
2134
2134
  };
2135
2135
  const contentType1 = {
2136
- parameterPath: "contentType",
2137
- mapper: {
2138
- defaultValue: "text/html",
2139
- isConstant: true,
2140
- serializedName: "Content-Type",
2141
- type: {
2142
- name: "String"
2143
- }
2144
- }
2145
- };
2146
- const analyzeRequest1 = {
2147
- parameterPath: ["options", "analyzeRequest"],
2148
- mapper: {
2149
- serializedName: "analyzeRequest",
2150
- type: {
2151
- name: "String"
2152
- }
2153
- }
2154
- };
2155
- const accept1 = {
2156
- parameterPath: "accept",
2157
- mapper: {
2158
- defaultValue: "application/json",
2159
- isConstant: true,
2160
- serializedName: "Accept",
2161
- type: {
2162
- name: "String"
2163
- }
2164
- }
2165
- };
2166
- const contentType2 = {
2167
2136
  parameterPath: "contentType",
2168
2137
  mapper: {
2169
2138
  defaultValue: "application/json",
@@ -2174,11 +2143,11 @@ const contentType2 = {
2174
2143
  }
2175
2144
  }
2176
2145
  };
2177
- const analyzeRequest2 = {
2146
+ const analyzeRequest1 = {
2178
2147
  parameterPath: ["options", "analyzeRequest"],
2179
2148
  mapper: AnalyzeDocumentRequest
2180
2149
  };
2181
- const accept2 = {
2150
+ const accept1 = {
2182
2151
  parameterPath: "accept",
2183
2152
  mapper: {
2184
2153
  defaultValue: "application/json",
@@ -2246,7 +2215,7 @@ const stringIndexType = {
2246
2215
  const apiVersion = {
2247
2216
  parameterPath: "apiVersion",
2248
2217
  mapper: {
2249
- defaultValue: "2022-06-30-preview",
2218
+ defaultValue: "2022-08-31",
2250
2219
  isConstant: true,
2251
2220
  serializedName: "api-version",
2252
2221
  type: {
@@ -2264,7 +2233,7 @@ const resultId = {
2264
2233
  }
2265
2234
  }
2266
2235
  };
2267
- const contentType3 = {
2236
+ const contentType2 = {
2268
2237
  parameterPath: ["options", "contentType"],
2269
2238
  mapper: {
2270
2239
  defaultValue: "application/json",
@@ -2422,7 +2391,7 @@ class GeneratedClient extends coreClient__namespace.ServiceClient {
2422
2391
  const defaults = {
2423
2392
  requestContentType: "application/json; charset=utf-8"
2424
2393
  };
2425
- const packageDetails = `azsdk-js-ai-form-recognizer/4.0.0-beta.4`;
2394
+ const packageDetails = `azsdk-js-ai-form-recognizer/4.0.0`;
2426
2395
  const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
2427
2396
  ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`
2428
2397
  : `${packageDetails}`;
@@ -2449,7 +2418,7 @@ class GeneratedClient extends coreClient__namespace.ServiceClient {
2449
2418
  // Parameter assignments
2450
2419
  this.endpoint = endpoint;
2451
2420
  // Assigning values to Constant parameters
2452
- this.apiVersion = options.apiVersion || "2022-06-30-preview";
2421
+ this.apiVersion = options.apiVersion || "2022-08-31";
2453
2422
  this.addCustomApiVersionPolicy(options.apiVersion);
2454
2423
  }
2455
2424
  /** A function that adds a policy that sets the api-version (or equivalent) to reflect the library version. */
@@ -2464,7 +2433,7 @@ class GeneratedClient extends coreClient__namespace.ServiceClient {
2464
2433
  if (param.length > 1) {
2465
2434
  const newParams = param[1].split("&").map((item) => {
2466
2435
  if (item.indexOf("api-version") > -1) {
2467
- return item.replace(/(?<==).*$/, apiVersion);
2436
+ return "api-version=" + apiVersion;
2468
2437
  }
2469
2438
  else {
2470
2439
  return item;
@@ -2526,11 +2495,11 @@ class GeneratedClient extends coreClient__namespace.ServiceClient {
2526
2495
  });
2527
2496
  }
2528
2497
  /**
2529
- * List all models
2498
+ * List all document models
2530
2499
  * @param options The options parameters.
2531
2500
  */
2532
- listModels(options) {
2533
- const iter = this.getModelsPagingAll(options);
2501
+ listDocumentModels(options) {
2502
+ const iter = this.getDocumentModelsPagingAll(options);
2534
2503
  return {
2535
2504
  next() {
2536
2505
  return iter.next();
@@ -2539,27 +2508,27 @@ class GeneratedClient extends coreClient__namespace.ServiceClient {
2539
2508
  return this;
2540
2509
  },
2541
2510
  byPage: () => {
2542
- return this.getModelsPagingPage(options);
2511
+ return this.getDocumentModelsPagingPage(options);
2543
2512
  }
2544
2513
  };
2545
2514
  }
2546
- getModelsPagingPage(options) {
2547
- return tslib.__asyncGenerator(this, arguments, function* getModelsPagingPage_1() {
2548
- let result = yield tslib.__await(this._getModels(options));
2515
+ getDocumentModelsPagingPage(options) {
2516
+ return tslib.__asyncGenerator(this, arguments, function* getDocumentModelsPagingPage_1() {
2517
+ let result = yield tslib.__await(this._getDocumentModels(options));
2549
2518
  yield yield tslib.__await(result.value || []);
2550
2519
  let continuationToken = result.nextLink;
2551
2520
  while (continuationToken) {
2552
- result = yield tslib.__await(this._getModelsNext(continuationToken, options));
2521
+ result = yield tslib.__await(this._getDocumentModelsNext(continuationToken, options));
2553
2522
  continuationToken = result.nextLink;
2554
2523
  yield yield tslib.__await(result.value || []);
2555
2524
  }
2556
2525
  });
2557
2526
  }
2558
- getModelsPagingAll(options) {
2559
- return tslib.__asyncGenerator(this, arguments, function* getModelsPagingAll_1() {
2527
+ getDocumentModelsPagingAll(options) {
2528
+ return tslib.__asyncGenerator(this, arguments, function* getDocumentModelsPagingAll_1() {
2560
2529
  var e_2, _a;
2561
2530
  try {
2562
- for (var _b = tslib.__asyncValues(this.getModelsPagingPage(options)), _c; _c = yield tslib.__await(_b.next()), !_c.done;) {
2531
+ for (var _b = tslib.__asyncValues(this.getDocumentModelsPagingPage(options)), _c; _c = yield tslib.__await(_b.next()), !_c.done;) {
2563
2532
  const page = _c.value;
2564
2533
  yield tslib.__await(yield* tslib.__asyncDelegator(tslib.__asyncValues(page)));
2565
2534
  }
@@ -2574,7 +2543,7 @@ class GeneratedClient extends coreClient__namespace.ServiceClient {
2574
2543
  });
2575
2544
  }
2576
2545
  /**
2577
- * Analyzes document with model.
2546
+ * Analyzes document with document model.
2578
2547
  * @param args Includes all the parameters for this operation.
2579
2548
  */
2580
2549
  analyzeDocument(...args) {
@@ -2583,12 +2552,6 @@ class GeneratedClient extends coreClient__namespace.ServiceClient {
2583
2552
  let options;
2584
2553
  if (args[1] === "application/octet-stream" ||
2585
2554
  args[1] === "application/pdf" ||
2586
- args[1] ===
2587
- "application/vnd.openxmlformats-officedocument.presentationml.presentation" ||
2588
- args[1] ===
2589
- "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" ||
2590
- args[1] ===
2591
- "application/vnd.openxmlformats-officedocument.wordprocessingml.document" ||
2592
2555
  args[1] === "image/bmp" ||
2593
2556
  args[1] === "image/heif" ||
2594
2557
  args[1] === "image/jpeg" ||
@@ -2602,15 +2565,6 @@ class GeneratedClient extends coreClient__namespace.ServiceClient {
2602
2565
  };
2603
2566
  options = args[2];
2604
2567
  }
2605
- else if (args[1] === "text/html") {
2606
- operationSpec = analyzeDocument$textOperationSpec;
2607
- operationArguments = {
2608
- modelId: args[0],
2609
- contentType: args[1],
2610
- options: args[2]
2611
- };
2612
- options = args[2];
2613
- }
2614
2568
  else if (args[1] === "application/json") {
2615
2569
  operationSpec = analyzeDocument$jsonOperationSpec;
2616
2570
  operationArguments = {
@@ -2628,7 +2582,7 @@ class GeneratedClient extends coreClient__namespace.ServiceClient {
2628
2582
  }
2629
2583
  /**
2630
2584
  * Gets the result of document analysis.
2631
- * @param modelId Unique model name.
2585
+ * @param modelId Unique document model name.
2632
2586
  * @param resultId Analyze operation result ID.
2633
2587
  * @param options The options parameters.
2634
2588
  */
@@ -2644,7 +2598,7 @@ class GeneratedClient extends coreClient__namespace.ServiceClient {
2644
2598
  return this.sendOperationRequest({ buildRequest, options }, buildDocumentModelOperationSpec);
2645
2599
  }
2646
2600
  /**
2647
- * Creates a new model from document types of existing models.
2601
+ * Creates a new document model from document types of existing document models.
2648
2602
  * @param composeRequest Compose request parameters.
2649
2603
  * @param options The options parameters.
2650
2604
  */
@@ -2652,8 +2606,8 @@ class GeneratedClient extends coreClient__namespace.ServiceClient {
2652
2606
  return this.sendOperationRequest({ composeRequest, options }, composeDocumentModelOperationSpec);
2653
2607
  }
2654
2608
  /**
2655
- * Generates authorization to copy a model to this location with specified modelId and optional
2656
- * description.
2609
+ * Generates authorization to copy a document model to this location with specified modelId and
2610
+ * optional description.
2657
2611
  * @param authorizeCopyRequest Authorize copy request parameters.
2658
2612
  * @param options The options parameters.
2659
2613
  */
@@ -2661,8 +2615,8 @@ class GeneratedClient extends coreClient__namespace.ServiceClient {
2661
2615
  return this.sendOperationRequest({ authorizeCopyRequest, options }, authorizeCopyDocumentModelOperationSpec);
2662
2616
  }
2663
2617
  /**
2664
- * Copies model to the target resource, region, and modelId.
2665
- * @param modelId Unique model name.
2618
+ * Copies document model to the target resource, region, and modelId.
2619
+ * @param modelId Unique document model name.
2666
2620
  * @param copyToRequest Copy to request parameters.
2667
2621
  * @param options The options parameters.
2668
2622
  */
@@ -2685,34 +2639,34 @@ class GeneratedClient extends coreClient__namespace.ServiceClient {
2685
2639
  return this.sendOperationRequest({ operationId, options }, getOperationOperationSpec);
2686
2640
  }
2687
2641
  /**
2688
- * List all models
2642
+ * List all document models
2689
2643
  * @param options The options parameters.
2690
2644
  */
2691
- _getModels(options) {
2692
- return this.sendOperationRequest({ options }, getModelsOperationSpec);
2645
+ _getDocumentModels(options) {
2646
+ return this.sendOperationRequest({ options }, getDocumentModelsOperationSpec);
2693
2647
  }
2694
2648
  /**
2695
- * Gets detailed model information.
2696
- * @param modelId Unique model name.
2649
+ * Gets detailed document model information.
2650
+ * @param modelId Unique document model name.
2697
2651
  * @param options The options parameters.
2698
2652
  */
2699
- getModel(modelId, options) {
2700
- return this.sendOperationRequest({ modelId, options }, getModelOperationSpec);
2653
+ getDocumentModel(modelId, options) {
2654
+ return this.sendOperationRequest({ modelId, options }, getDocumentModelOperationSpec);
2701
2655
  }
2702
2656
  /**
2703
- * Deletes model.
2704
- * @param modelId Unique model name.
2657
+ * Deletes document model.
2658
+ * @param modelId Unique document model name.
2705
2659
  * @param options The options parameters.
2706
2660
  */
2707
- deleteModel(modelId, options) {
2708
- return this.sendOperationRequest({ modelId, options }, deleteModelOperationSpec);
2661
+ deleteDocumentModel(modelId, options) {
2662
+ return this.sendOperationRequest({ modelId, options }, deleteDocumentModelOperationSpec);
2709
2663
  }
2710
2664
  /**
2711
- * Return basic info about the current resource.
2665
+ * Return information about the current resource.
2712
2666
  * @param options The options parameters.
2713
2667
  */
2714
- getInfo(options) {
2715
- return this.sendOperationRequest({ options }, getInfoOperationSpec);
2668
+ getResourceDetails(options) {
2669
+ return this.sendOperationRequest({ options }, getResourceDetailsOperationSpec);
2716
2670
  }
2717
2671
  /**
2718
2672
  * GetOperationsNext
@@ -2723,12 +2677,12 @@ class GeneratedClient extends coreClient__namespace.ServiceClient {
2723
2677
  return this.sendOperationRequest({ nextLink, options }, getOperationsNextOperationSpec);
2724
2678
  }
2725
2679
  /**
2726
- * GetModelsNext
2727
- * @param nextLink The nextLink from the previous successful call to the GetModels method.
2680
+ * GetDocumentModelsNext
2681
+ * @param nextLink The nextLink from the previous successful call to the GetDocumentModels method.
2728
2682
  * @param options The options parameters.
2729
2683
  */
2730
- _getModelsNext(nextLink, options) {
2731
- return this.sendOperationRequest({ nextLink, options }, getModelsNextOperationSpec);
2684
+ _getDocumentModelsNext(nextLink, options) {
2685
+ return this.sendOperationRequest({ nextLink, options }, getDocumentModelsNextOperationSpec);
2732
2686
  }
2733
2687
  }
2734
2688
  // Operation Specifications
@@ -2756,7 +2710,7 @@ const analyzeDocument$binaryOperationSpec = {
2756
2710
  mediaType: "binary",
2757
2711
  serializer
2758
2712
  };
2759
- const analyzeDocument$textOperationSpec = {
2713
+ const analyzeDocument$jsonOperationSpec = {
2760
2714
  path: "/documentModels/{modelId}:analyze",
2761
2715
  httpMethod: "POST",
2762
2716
  responses: {
@@ -2776,29 +2730,6 @@ const analyzeDocument$textOperationSpec = {
2776
2730
  ],
2777
2731
  urlParameters: [endpoint, modelId],
2778
2732
  headerParameters: [contentType1, accept1],
2779
- mediaType: "text",
2780
- serializer
2781
- };
2782
- const analyzeDocument$jsonOperationSpec = {
2783
- path: "/documentModels/{modelId}:analyze",
2784
- httpMethod: "POST",
2785
- responses: {
2786
- 202: {
2787
- headersMapper: GeneratedClientAnalyzeDocumentHeaders
2788
- },
2789
- default: {
2790
- bodyMapper: ErrorResponse
2791
- }
2792
- },
2793
- requestBody: analyzeRequest2,
2794
- queryParameters: [
2795
- pages,
2796
- locale,
2797
- stringIndexType,
2798
- apiVersion
2799
- ],
2800
- urlParameters: [endpoint, modelId],
2801
- headerParameters: [contentType2, accept2],
2802
2733
  mediaType: "json",
2803
2734
  serializer
2804
2735
  };
@@ -2815,7 +2746,7 @@ const getAnalyzeDocumentResultOperationSpec = {
2815
2746
  },
2816
2747
  queryParameters: [apiVersion],
2817
2748
  urlParameters: [endpoint, modelId, resultId],
2818
- headerParameters: [accept2],
2749
+ headerParameters: [accept1],
2819
2750
  serializer
2820
2751
  };
2821
2752
  const buildDocumentModelOperationSpec = {
@@ -2832,7 +2763,7 @@ const buildDocumentModelOperationSpec = {
2832
2763
  requestBody: buildRequest,
2833
2764
  queryParameters: [apiVersion],
2834
2765
  urlParameters: [endpoint],
2835
- headerParameters: [accept2, contentType3],
2766
+ headerParameters: [accept1, contentType2],
2836
2767
  mediaType: "json",
2837
2768
  serializer
2838
2769
  };
@@ -2850,7 +2781,7 @@ const composeDocumentModelOperationSpec = {
2850
2781
  requestBody: composeRequest,
2851
2782
  queryParameters: [apiVersion],
2852
2783
  urlParameters: [endpoint],
2853
- headerParameters: [accept2, contentType3],
2784
+ headerParameters: [accept1, contentType2],
2854
2785
  mediaType: "json",
2855
2786
  serializer
2856
2787
  };
@@ -2868,7 +2799,7 @@ const authorizeCopyDocumentModelOperationSpec = {
2868
2799
  requestBody: authorizeCopyRequest,
2869
2800
  queryParameters: [apiVersion],
2870
2801
  urlParameters: [endpoint],
2871
- headerParameters: [accept2, contentType3],
2802
+ headerParameters: [accept1, contentType2],
2872
2803
  mediaType: "json",
2873
2804
  serializer
2874
2805
  };
@@ -2886,7 +2817,7 @@ const copyDocumentModelToOperationSpec = {
2886
2817
  requestBody: copyToRequest,
2887
2818
  queryParameters: [apiVersion],
2888
2819
  urlParameters: [endpoint, modelId],
2889
- headerParameters: [accept2, contentType3],
2820
+ headerParameters: [accept1, contentType2],
2890
2821
  mediaType: "json",
2891
2822
  serializer
2892
2823
  };
@@ -2903,7 +2834,7 @@ const getOperationsOperationSpec = {
2903
2834
  },
2904
2835
  queryParameters: [apiVersion],
2905
2836
  urlParameters: [endpoint],
2906
- headerParameters: [accept2],
2837
+ headerParameters: [accept1],
2907
2838
  serializer
2908
2839
  };
2909
2840
  const getOperationOperationSpec = {
@@ -2911,7 +2842,7 @@ const getOperationOperationSpec = {
2911
2842
  httpMethod: "GET",
2912
2843
  responses: {
2913
2844
  200: {
2914
- bodyMapper: GetOperationResponse
2845
+ bodyMapper: OperationDetails
2915
2846
  },
2916
2847
  default: {
2917
2848
  bodyMapper: ErrorResponse
@@ -2919,15 +2850,15 @@ const getOperationOperationSpec = {
2919
2850
  },
2920
2851
  queryParameters: [apiVersion],
2921
2852
  urlParameters: [endpoint, operationId],
2922
- headerParameters: [accept2],
2853
+ headerParameters: [accept1],
2923
2854
  serializer
2924
2855
  };
2925
- const getModelsOperationSpec = {
2856
+ const getDocumentModelsOperationSpec = {
2926
2857
  path: "/documentModels",
2927
2858
  httpMethod: "GET",
2928
2859
  responses: {
2929
2860
  200: {
2930
- bodyMapper: GetModelsResponse
2861
+ bodyMapper: GetDocumentModelsResponse
2931
2862
  },
2932
2863
  default: {
2933
2864
  bodyMapper: ErrorResponse
@@ -2935,15 +2866,15 @@ const getModelsOperationSpec = {
2935
2866
  },
2936
2867
  queryParameters: [apiVersion],
2937
2868
  urlParameters: [endpoint],
2938
- headerParameters: [accept2],
2869
+ headerParameters: [accept1],
2939
2870
  serializer
2940
2871
  };
2941
- const getModelOperationSpec = {
2872
+ const getDocumentModelOperationSpec = {
2942
2873
  path: "/documentModels/{modelId}",
2943
2874
  httpMethod: "GET",
2944
2875
  responses: {
2945
2876
  200: {
2946
- bodyMapper: ModelInfo
2877
+ bodyMapper: DocumentModelDetails
2947
2878
  },
2948
2879
  default: {
2949
2880
  bodyMapper: ErrorResponse
@@ -2951,10 +2882,10 @@ const getModelOperationSpec = {
2951
2882
  },
2952
2883
  queryParameters: [apiVersion],
2953
2884
  urlParameters: [endpoint, modelId],
2954
- headerParameters: [accept2],
2885
+ headerParameters: [accept1],
2955
2886
  serializer
2956
2887
  };
2957
- const deleteModelOperationSpec = {
2888
+ const deleteDocumentModelOperationSpec = {
2958
2889
  path: "/documentModels/{modelId}",
2959
2890
  httpMethod: "DELETE",
2960
2891
  responses: {
@@ -2965,15 +2896,15 @@ const deleteModelOperationSpec = {
2965
2896
  },
2966
2897
  queryParameters: [apiVersion],
2967
2898
  urlParameters: [endpoint, modelId],
2968
- headerParameters: [accept2],
2899
+ headerParameters: [accept1],
2969
2900
  serializer
2970
2901
  };
2971
- const getInfoOperationSpec = {
2902
+ const getResourceDetailsOperationSpec = {
2972
2903
  path: "/info",
2973
2904
  httpMethod: "GET",
2974
2905
  responses: {
2975
2906
  200: {
2976
- bodyMapper: GetInfoResponse
2907
+ bodyMapper: ResourceDetails
2977
2908
  },
2978
2909
  default: {
2979
2910
  bodyMapper: ErrorResponse
@@ -2981,7 +2912,7 @@ const getInfoOperationSpec = {
2981
2912
  },
2982
2913
  queryParameters: [apiVersion],
2983
2914
  urlParameters: [endpoint],
2984
- headerParameters: [accept2],
2915
+ headerParameters: [accept1],
2985
2916
  serializer
2986
2917
  };
2987
2918
  const getOperationsNextOperationSpec = {
@@ -2997,15 +2928,15 @@ const getOperationsNextOperationSpec = {
2997
2928
  },
2998
2929
  queryParameters: [apiVersion],
2999
2930
  urlParameters: [endpoint, nextLink],
3000
- headerParameters: [accept2],
2931
+ headerParameters: [accept1],
3001
2932
  serializer
3002
2933
  };
3003
- const getModelsNextOperationSpec = {
2934
+ const getDocumentModelsNextOperationSpec = {
3004
2935
  path: "{nextLink}",
3005
2936
  httpMethod: "GET",
3006
2937
  responses: {
3007
2938
  200: {
3008
- bodyMapper: GetModelsResponse
2939
+ bodyMapper: GetDocumentModelsResponse
3009
2940
  },
3010
2941
  default: {
3011
2942
  bodyMapper: ErrorResponse
@@ -3013,7 +2944,7 @@ const getModelsNextOperationSpec = {
3013
2944
  },
3014
2945
  queryParameters: [apiVersion],
3015
2946
  urlParameters: [endpoint, nextLink],
3016
- headerParameters: [accept2],
2947
+ headerParameters: [accept1],
3017
2948
  serializer
3018
2949
  };
3019
2950
 
@@ -3030,9 +2961,10 @@ const FormRecognizerApiVersion = {
3030
2961
  * If using a beta package version, this will be identical to the latest preview version. Otherwise, it will be
3031
2962
  * identical to the latest stable version.
3032
2963
  */
3033
- Latest: "2022-06-30-preview",
2964
+ Latest: "2022-08-31",
3034
2965
  // TODO (GA): Add a `Stable` version selector that picks the latest GA version, even in beta packages, and an exact
3035
2966
  // version entry for the GA version.
2967
+ Stable: "2022-08-31",
3036
2968
  };
3037
2969
  /**
3038
2970
  * Supported values of StringIndexType.
@@ -3055,14 +2987,12 @@ const StringIndexType = {
3055
2987
  */
3056
2988
  const DEFAULT_GENERATED_CLIENT_OPTIONS = {
3057
2989
  stringIndexType: StringIndexType.Utf16CodeUnit,
3058
- apiVersion: FormRecognizerApiVersion.Latest,
2990
+ apiVersion: FormRecognizerApiVersion.Stable,
3059
2991
  };
3060
2992
 
3061
2993
  // Copyright (c) Microsoft Corporation.
3062
2994
  // This is used for URL request processing.
3063
2995
  const SERIALIZER = coreClient.createSerializer(Mappers, false);
3064
- /** @internal */
3065
- const identity = (x) => x;
3066
2996
  /**
3067
2997
  * Type-strong uncapitalization.
3068
2998
  * @internal
@@ -3202,6 +3132,7 @@ function toDocumentLineFromGenerated(generated, page) {
3202
3132
  return Object.assign(Object.assign({}, word), { polygon: toBoundingPolygon(word.polygon) });
3203
3133
  })) !== null && _b !== void 0 ? _b : []);
3204
3134
  };
3135
+ generated.polygon = toBoundingPolygon(generated.polygon);
3205
3136
  Object.defineProperty(generated, "words", {
3206
3137
  enumerable: false,
3207
3138
  });
@@ -3288,19 +3219,19 @@ function* fastGetChildren(spans, childrenArray) {
3288
3219
  * Convert a generated AnalyzeResult into a convenience layer AnalyzeResult.
3289
3220
  * @internal
3290
3221
  */
3291
- function toAnalyzeResultFromGenerated(result, mapDocuments) {
3292
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
3222
+ function toAnalyzeResultFromGenerated(result) {
3223
+ var _a, _b, _c, _d;
3293
3224
  return {
3294
3225
  apiVersion: result.apiVersion,
3295
3226
  modelId: result.modelId,
3296
3227
  content: result.content,
3297
3228
  pages: result.pages.map((page) => toDocumentPageFromGenerated(page)),
3298
- tables: (_b = (_a = result.tables) === null || _a === void 0 ? void 0 : _a.map((table) => toDocumentTableFromGenerated(table))) !== null && _b !== void 0 ? _b : [],
3299
- keyValuePairs: (_d = (_c = result.keyValuePairs) === null || _c === void 0 ? void 0 : _c.map((pair) => toKeyValuePairFromGenerated(pair))) !== null && _d !== void 0 ? _d : [],
3300
- languages: (_e = result.languages) !== null && _e !== void 0 ? _e : [],
3301
- styles: (_f = result.styles) !== null && _f !== void 0 ? _f : [],
3302
- documents: (_h = (_g = result.documents) === null || _g === void 0 ? void 0 : _g.map((doc) => mapDocuments(doc))) !== null && _h !== void 0 ? _h : [],
3303
- paragraphs: (_k = (_j = result.paragraphs) === null || _j === void 0 ? void 0 : _j.map((para) => (Object.assign(Object.assign({}, para), { boundingRegions: toBoundingRegions(para.boundingRegions) })))) !== null && _k !== void 0 ? _k : [],
3229
+ tables: (_a = result.tables) === null || _a === void 0 ? void 0 : _a.map((table) => toDocumentTableFromGenerated(table)),
3230
+ keyValuePairs: (_b = result.keyValuePairs) === null || _b === void 0 ? void 0 : _b.map((pair) => toKeyValuePairFromGenerated(pair)),
3231
+ languages: result.languages,
3232
+ styles: result.styles,
3233
+ paragraphs: (_c = result.paragraphs) === null || _c === void 0 ? void 0 : _c.map((para) => (Object.assign(Object.assign({}, para), { boundingRegions: toBoundingRegions(para.boundingRegions) }))),
3234
+ documents: (_d = result.documents) === null || _d === void 0 ? void 0 : _d.map(toAnalyzedDocumentFromGenerated),
3304
3235
  };
3305
3236
  }
3306
3237
  /**
@@ -3311,8 +3242,8 @@ function toDocumentAnalysisPollOperationState(definition, modelId, operationLoca
3311
3242
  return {
3312
3243
  status: response.status,
3313
3244
  modelId: modelId,
3314
- lastUpdatedOn: response.lastUpdatedDateTime,
3315
- createdOn: response.createdDateTime,
3245
+ lastUpdatedOn: response.lastUpdatedOn,
3246
+ createdOn: response.createdOn,
3316
3247
  operationLocation,
3317
3248
  result: response.analyzeResult && definition.transformResult(response.analyzeResult),
3318
3249
  error: response.error && new FormRecognizerError(response.error),
@@ -3434,1578 +3365,179 @@ async function lro(spec, pollingInterval) {
3434
3365
  }
3435
3366
 
3436
3367
  // Copyright (c) Microsoft Corporation.
3437
- // Licensed under the MIT license.
3438
3368
  /**
3439
- * Extract from an AnalyzeResult the fields that are produced from layout analysis.
3440
- * @internal
3369
+ * A client for interacting with the Form Recognizer service's analysis features.
3370
+ *
3371
+ * ### Examples:
3372
+ *
3373
+ * The Form Recognizer service and clients support two means of authentication:
3374
+ *
3375
+ * #### Azure Active Directory
3376
+ *
3377
+ * ```javascript
3378
+ * import { DocumentAnalysisClient } from "@azure/ai-form-recognizer";
3379
+ * import { DefaultAzureCredential } from "@azure/identity";
3380
+ *
3381
+ * const endpoint = "https://<resource name>.cognitiveservices.azure.com";
3382
+ * const credential = new DefaultAzureCredential();
3383
+ *
3384
+ * const client = new DocumentAnalysisClient(endpoint, credential);
3385
+ * ```
3386
+ *
3387
+ * #### API Key (Subscription Key)
3388
+ *
3389
+ * ```javascript
3390
+ * import { DocumentAnalysisClient, AzureKeyCredential } from "@azure/ai-form-recognizer";
3391
+ *
3392
+ * const endpoint = "https://<resource name>.cognitiveservices.azure.com";
3393
+ * const credential = new AzureKeyCredential("<api key>");
3394
+ *
3395
+ * const client = new DocumentAnalysisClient(endpoint, credential);
3396
+ * ```
3441
3397
  */
3442
- function toLayoutResult(analyzeResult) {
3443
- const { pages, tables, styles } = analyzeResult;
3444
- return {
3445
- pages,
3446
- tables,
3447
- styles,
3448
- };
3398
+ class DocumentAnalysisClient {
3399
+ constructor(endpoint, credential, options = {}) {
3400
+ var _a;
3401
+ this._restClient = makeServiceClient(endpoint, credential, options);
3402
+ this._tracing = coreTracing.createTracingClient({
3403
+ packageName: "@azure/ai-form-recognizer",
3404
+ packageVersion: SDK_VERSION,
3405
+ namespace: "Microsoft.CognitiveServices",
3406
+ });
3407
+ this._apiVersion = (_a = options.apiVersion) !== null && _a !== void 0 ? _a : DEFAULT_GENERATED_CLIENT_OPTIONS.apiVersion;
3408
+ }
3409
+ async beginAnalyzeDocument(model, document, options = {}) {
3410
+ return this._tracing.withSpan("DocumentAnalysisClient.beginAnalyzeDocument", options, this.analyze.bind(this, model, document));
3411
+ }
3412
+ async beginAnalyzeDocumentFromUrl(model, documentUrl, options = {}) {
3413
+ return this._tracing.withSpan("DocumentAnalysisClient.beginAnalyzeDocumentFromUrl", options, this.analyze.bind(this, model, documentUrl));
3414
+ }
3415
+ /**
3416
+ * A helper method for running analysis polymorphically.
3417
+ * @internal
3418
+ * @param model - the model ID or DocumentModel to use for analysis
3419
+ * @param input - the string URL or request body to use
3420
+ * @param options - analysis options
3421
+ * @returns - an analysis poller
3422
+ */
3423
+ analyze(model, input, options) {
3424
+ const { modelId: initialModelId, apiVersion: requestApiVersion, transformResult, } = typeof model === "string"
3425
+ ? { modelId: model, apiVersion: undefined, transformResult: (v) => v }
3426
+ : model;
3427
+ if (requestApiVersion && requestApiVersion !== this._apiVersion) {
3428
+ throw new Error([
3429
+ `API Version mismatch: the provided model wants version: ${requestApiVersion}, but the client is using ${this._apiVersion}.`,
3430
+ "The API version of the model must match the client's API version.",
3431
+ ].join("\n"));
3432
+ }
3433
+ return this.createAnalysisPoller(input, {
3434
+ initialModelId,
3435
+ options,
3436
+ transformResult: (result) => transformResult(toAnalyzeResultFromGenerated(result)),
3437
+ });
3438
+ }
3439
+ /**
3440
+ * Create an LRO poller that handles analysis operations.
3441
+ *
3442
+ * This is the meat of all analysis polling operations.
3443
+ *
3444
+ * @param input - either a string for URL inputs or a FormRecognizerRequestBody to upload a file directly to the Form
3445
+ * Recognizer API
3446
+ * @param definition - operation definition (initial model ID, operation transforms, request options)
3447
+ * @returns - an analysis poller that produces the given return types according to the operation spec
3448
+ */
3449
+ async createAnalysisPoller(input, definition) {
3450
+ const { resumeFrom } = definition.options;
3451
+ // TODO: what should we do if resumeFrom.modelId is different from initialModelId?
3452
+ // And what do we do with the redundant input??
3453
+ const getAnalyzeResult = (operationLocation) => this._tracing.withSpan("DocumentAnalysisClient.createAnalysisPoller-getAnalyzeResult", definition.options, (finalOptions) => this._restClient.sendOperationRequest({
3454
+ options: finalOptions,
3455
+ }, {
3456
+ path: operationLocation,
3457
+ httpMethod: "GET",
3458
+ responses: {
3459
+ 200: {
3460
+ bodyMapper: AnalyzeResultOperation,
3461
+ },
3462
+ default: {
3463
+ bodyMapper: ErrorResponse,
3464
+ },
3465
+ },
3466
+ // URL is fully-formed, so we don't need any query parameters
3467
+ headerParameters: [accept1],
3468
+ serializer: SERIALIZER,
3469
+ }));
3470
+ const toInit =
3471
+ // If the user gave us a stored token, we'll poll it again
3472
+ resumeFrom !== undefined
3473
+ ? async () => this._tracing.withSpan("DocumentAnalysisClient.createAnalysisPoller-resume", definition.options, async () => {
3474
+ const { operationLocation, modelId } = JSON.parse(resumeFrom);
3475
+ const result = await getAnalyzeResult(operationLocation);
3476
+ return toDocumentAnalysisPollOperationState(definition, modelId, operationLocation, result);
3477
+ })
3478
+ : // Otherwise, we'll start a new operation from the initialModelId
3479
+ async () => this._tracing.withSpan("DocumentAnalysisClient.createAnalysisPoller-start", definition.options, async () => {
3480
+ const [contentType, analyzeRequest] = toAnalyzeRequest(input);
3481
+ const { operationLocation } = await this._restClient.analyzeDocument(definition.initialModelId, contentType, Object.assign(Object.assign({}, definition.options), { analyzeRequest }));
3482
+ if (operationLocation === undefined) {
3483
+ throw new Error("Unable to start analysis operation: no Operation-Location received.");
3484
+ }
3485
+ const result = await getAnalyzeResult(operationLocation);
3486
+ return toDocumentAnalysisPollOperationState(definition, definition.initialModelId, operationLocation, result);
3487
+ });
3488
+ const poller = await lro({
3489
+ init: toInit,
3490
+ poll: async ({ operationLocation, modelId }) => this._tracing.withSpan("DocumentAnalysisClient.createAnalysisPoller-poll", {}, async () => {
3491
+ const result = await getAnalyzeResult(operationLocation);
3492
+ return toDocumentAnalysisPollOperationState(definition, modelId, operationLocation, result);
3493
+ }),
3494
+ serialize: ({ operationLocation, modelId }) => JSON.stringify({ modelId, operationLocation }),
3495
+ }, definition.options.updateIntervalInMs);
3496
+ if (definition.options.onProgress !== undefined) {
3497
+ poller.onProgress(definition.options.onProgress);
3498
+ definition.options.onProgress(poller.getOperationState());
3499
+ }
3500
+ return poller;
3501
+ }
3449
3502
  }
3450
-
3451
- // Copyright (c) Microsoft Corporation.
3452
3503
  /**
3453
- * Extract from an AnalyzeResult the fields that are produced from General Document extraction (`"prebuilt-document"`).
3454
- *
3504
+ * Produce an appropriate pair of content-type and analyzeRequest value for the analysis request.
3455
3505
  * @internal
3456
3506
  */
3457
- function toGeneralDocumentResult(analyzeResult) {
3458
- const { keyValuePairs } = analyzeResult;
3459
- return Object.assign(Object.assign({}, toLayoutResult(analyzeResult)), { keyValuePairs });
3507
+ function toAnalyzeRequest(input) {
3508
+ if (typeof input === "string") {
3509
+ return [
3510
+ "application/json",
3511
+ {
3512
+ urlSource: input,
3513
+ },
3514
+ ];
3515
+ }
3516
+ else {
3517
+ return ["application/octet-stream", input];
3518
+ }
3460
3519
  }
3461
3520
 
3462
3521
  // Copyright (c) Microsoft Corporation.
3463
- // Licensed under the MIT license.
3464
3522
  /**
3465
- * Extract from an AnalyzeResult the fields that are produced from document reading.
3523
+ * Convert an operation result into a training poller state.
3466
3524
  * @internal
3467
3525
  */
3468
- function toReadResult(analyzeResult) {
3469
- const { apiVersion, modelId, content, pages, languages, styles } = analyzeResult;
3470
- return {
3471
- apiVersion,
3472
- modelId,
3473
- content,
3474
- pages,
3475
- languages,
3476
- styles,
3477
- };
3478
- }
3479
-
3480
- // Copyright (c) Microsoft Corporation.
3481
- // Licensed under the MIT license.
3482
- /**
3483
- * The schema of the prebuilt-businessCard model.
3484
- */
3485
- const modelInfo$6 = {
3486
- modelId: "prebuilt-businessCard",
3487
- description: "Prebuilt model to extract key information from English business cards, including personal contact info, company name, job title, and more.",
3488
- createdDateTime: "2022-06-30T00:00:00.000Z",
3489
- apiVersion: "2022-06-30-preview",
3490
- docTypes: {
3491
- businessCard: {
3492
- buildMode: "template",
3493
- fieldSchema: {
3494
- ContactNames: {
3495
- type: "array",
3496
- items: {
3497
- type: "object",
3498
- properties: {
3499
- FirstName: {
3500
- type: "string",
3501
- },
3502
- LastName: {
3503
- type: "string",
3504
- },
3505
- },
3506
- },
3507
- },
3508
- CompanyNames: {
3509
- type: "array",
3510
- items: {
3511
- type: "string",
3512
- },
3513
- },
3514
- JobTitles: {
3515
- type: "array",
3516
- items: {
3517
- type: "string",
3518
- },
3519
- },
3520
- Departments: {
3521
- type: "array",
3522
- items: {
3523
- type: "string",
3524
- },
3525
- },
3526
- Addresses: {
3527
- type: "array",
3528
- items: {
3529
- type: "string",
3530
- },
3531
- },
3532
- WorkPhones: {
3533
- type: "array",
3534
- items: {
3535
- type: "phoneNumber",
3536
- },
3537
- },
3538
- MobilePhones: {
3539
- type: "array",
3540
- items: {
3541
- type: "phoneNumber",
3542
- },
3543
- },
3544
- Faxes: {
3545
- type: "array",
3546
- items: {
3547
- type: "phoneNumber",
3548
- },
3549
- },
3550
- OtherPhones: {
3551
- type: "array",
3552
- items: {
3553
- type: "phoneNumber",
3554
- },
3555
- },
3556
- Emails: {
3557
- type: "array",
3558
- items: {
3559
- type: "string",
3560
- },
3561
- },
3562
- Websites: {
3563
- type: "array",
3564
- items: {
3565
- type: "string",
3566
- },
3567
- },
3568
- },
3569
- },
3570
- },
3571
- };
3572
-
3573
- // Copyright (c) Microsoft Corporation.
3574
- // Licensed under the MIT license.
3575
- /**
3576
- * The schema of the prebuilt-healthInsuranceCard.us model.
3577
- */
3578
- const modelInfo$5 = {
3579
- modelId: "prebuilt-healthInsuranceCard.us",
3580
- description: "Prebuilt model to extract key information from US Health Insurance cards.",
3581
- createdDateTime: "2022-03-30T00:00:00.000Z",
3582
- apiVersion: "2022-06-30-preview",
3583
- docTypes: {
3584
- "healthInsuranceCard.us": {
3585
- buildMode: "template",
3586
- fieldSchema: {
3587
- Insurer: {
3588
- type: "string",
3589
- },
3590
- Member: {
3591
- type: "object",
3592
- properties: {
3593
- Name: {
3594
- type: "string",
3595
- },
3596
- DateOfBirth: {
3597
- type: "string",
3598
- },
3599
- Employer: {
3600
- type: "string",
3601
- },
3602
- Gender: {
3603
- type: "string",
3604
- },
3605
- IdNumberSuffix: {
3606
- type: "string",
3607
- },
3608
- },
3609
- },
3610
- Dependents: {
3611
- type: "array",
3612
- items: {
3613
- type: "object",
3614
- properties: {
3615
- Name: {
3616
- type: "string",
3617
- description: "Dependent name",
3618
- },
3619
- IdNumberSuffix: {
3620
- type: "string",
3621
- description: "Dependent Membership Identification Suffix",
3622
- },
3623
- },
3624
- },
3625
- },
3626
- IdNumber: {
3627
- type: "object",
3628
- properties: {
3629
- Prefix: {
3630
- type: "string",
3631
- },
3632
- Number: {
3633
- type: "string",
3634
- },
3635
- },
3636
- },
3637
- GroupNumber: {
3638
- type: "string",
3639
- },
3640
- PrescriptionInfo: {
3641
- type: "object",
3642
- properties: {
3643
- IssuerId: {
3644
- type: "string",
3645
- },
3646
- RxBIN: {
3647
- type: "string",
3648
- },
3649
- RxPCN: {
3650
- type: "string",
3651
- },
3652
- RxGrp: {
3653
- type: "string",
3654
- },
3655
- RxId: {
3656
- type: "string",
3657
- },
3658
- RxPlan: {
3659
- type: "string",
3660
- },
3661
- },
3662
- },
3663
- Pbm: {
3664
- type: "string",
3665
- },
3666
- EffectiveDate: {
3667
- type: "date",
3668
- },
3669
- Copays: {
3670
- type: "array",
3671
- items: {
3672
- type: "object",
3673
- properties: {
3674
- Benefit: {
3675
- type: "string",
3676
- description: "Co-Pay Benefit name",
3677
- },
3678
- Amount: {
3679
- type: "string",
3680
- description: "Co-Pay required amount",
3681
- },
3682
- },
3683
- },
3684
- },
3685
- Payer: {
3686
- type: "object",
3687
- properties: {
3688
- Id: {
3689
- type: "string",
3690
- },
3691
- Address: {
3692
- type: "string",
3693
- },
3694
- PhoneNumber: {
3695
- type: "phoneNumber",
3696
- },
3697
- },
3698
- },
3699
- MedicareMedicaidInfo: {
3700
- type: "object",
3701
- properties: {
3702
- PartAEffectiveDate: {
3703
- type: "string",
3704
- },
3705
- PartBEffectiveDate: {
3706
- type: "string",
3707
- },
3708
- },
3709
- },
3710
- Plan: {
3711
- type: "object",
3712
- properties: {
3713
- Number: {
3714
- type: "string",
3715
- },
3716
- Name: {
3717
- type: "string",
3718
- },
3719
- },
3720
- },
3721
- },
3722
- },
3723
- },
3724
- };
3725
-
3726
- // Copyright (c) Microsoft Corporation.
3727
- // Licensed under the MIT license.
3728
- /**
3729
- * The schema of the prebuilt-idDocument model.
3730
- */
3731
- const modelInfo$4 = {
3732
- modelId: "prebuilt-idDocument",
3733
- description: "Prebuilt model to extract key information from US driver licenses and international passports.",
3734
- createdDateTime: "2022-06-30T00:00:00.000Z",
3735
- apiVersion: "2022-06-30-preview",
3736
- docTypes: {
3737
- "idDocument.driverLicense": {
3738
- buildMode: "template",
3739
- fieldSchema: {
3740
- CountryRegion: {
3741
- type: "countryRegion",
3742
- },
3743
- Region: {
3744
- type: "string",
3745
- },
3746
- DocumentNumber: {
3747
- type: "string",
3748
- },
3749
- FirstName: {
3750
- type: "string",
3751
- },
3752
- LastName: {
3753
- type: "string",
3754
- },
3755
- Address: {
3756
- type: "string",
3757
- },
3758
- DateOfBirth: {
3759
- type: "date",
3760
- },
3761
- DateOfExpiration: {
3762
- type: "date",
3763
- },
3764
- Sex: {
3765
- type: "string",
3766
- },
3767
- Endorsements: {
3768
- type: "string",
3769
- },
3770
- Restrictions: {
3771
- type: "string",
3772
- },
3773
- VehicleClassifications: {
3774
- type: "string",
3775
- },
3776
- },
3777
- },
3778
- "idDocument.passport": {
3779
- buildMode: "template",
3780
- fieldSchema: {
3781
- MachineReadableZone: {
3782
- type: "object",
3783
- properties: {
3784
- FirstName: {
3785
- type: "string",
3786
- },
3787
- LastName: {
3788
- type: "string",
3789
- },
3790
- DocumentNumber: {
3791
- type: "string",
3792
- },
3793
- CountryRegion: {
3794
- type: "countryRegion",
3795
- },
3796
- Nationality: {
3797
- type: "countryRegion",
3798
- },
3799
- DateOfBirth: {
3800
- type: "date",
3801
- },
3802
- DateOfExpiration: {
3803
- type: "date",
3804
- },
3805
- Sex: {
3806
- type: "string",
3807
- },
3808
- },
3809
- },
3810
- },
3811
- },
3812
- },
3813
- };
3814
-
3815
- // Copyright (c) Microsoft Corporation.
3816
- // Licensed under the MIT license.
3817
- /**
3818
- * The schema of the prebuilt-invoice model.
3819
- */
3820
- const modelInfo$3 = {
3821
- modelId: "prebuilt-invoice",
3822
- description: "Prebuilt model to extract key information from English invoices, including customer, vendor, invoice ID, due date, total, and more.",
3823
- createdDateTime: "2022-06-30T00:00:00.000Z",
3824
- apiVersion: "2022-06-30-preview",
3825
- docTypes: {
3826
- invoice: {
3827
- buildMode: "template",
3828
- fieldSchema: {
3829
- CustomerName: {
3830
- type: "string",
3831
- },
3832
- CustomerId: {
3833
- type: "string",
3834
- },
3835
- PurchaseOrder: {
3836
- type: "string",
3837
- },
3838
- InvoiceId: {
3839
- type: "string",
3840
- },
3841
- InvoiceDate: {
3842
- type: "date",
3843
- },
3844
- DueDate: {
3845
- type: "date",
3846
- },
3847
- VendorName: {
3848
- type: "string",
3849
- },
3850
- VendorAddress: {
3851
- type: "string",
3852
- },
3853
- VendorAddressRecipient: {
3854
- type: "string",
3855
- },
3856
- CustomerAddress: {
3857
- type: "string",
3858
- },
3859
- CustomerAddressRecipient: {
3860
- type: "string",
3861
- },
3862
- BillingAddress: {
3863
- type: "string",
3864
- },
3865
- BillingAddressRecipient: {
3866
- type: "string",
3867
- },
3868
- ShippingAddress: {
3869
- type: "string",
3870
- },
3871
- ShippingAddressRecipient: {
3872
- type: "string",
3873
- },
3874
- SubTotal: {
3875
- type: "currency",
3876
- },
3877
- TotalTax: {
3878
- type: "currency",
3879
- },
3880
- InvoiceTotal: {
3881
- type: "currency",
3882
- },
3883
- AmountDue: {
3884
- type: "currency",
3885
- },
3886
- PreviousUnpaidBalance: {
3887
- type: "currency",
3888
- },
3889
- RemittanceAddress: {
3890
- type: "string",
3891
- },
3892
- RemittanceAddressRecipient: {
3893
- type: "string",
3894
- },
3895
- ServiceAddress: {
3896
- type: "string",
3897
- },
3898
- ServiceAddressRecipient: {
3899
- type: "string",
3900
- },
3901
- ServiceStartDate: {
3902
- type: "date",
3903
- },
3904
- ServiceEndDate: {
3905
- type: "date",
3906
- },
3907
- TotalVAT: {
3908
- type: "currency",
3909
- },
3910
- VendorTaxId: {
3911
- type: "string",
3912
- },
3913
- CustomerTaxId: {
3914
- type: "string",
3915
- },
3916
- PaymentTerm: {
3917
- type: "string",
3918
- },
3919
- Items: {
3920
- type: "array",
3921
- items: {
3922
- type: "object",
3923
- properties: {
3924
- Amount: {
3925
- type: "currency",
3926
- },
3927
- Date: {
3928
- type: "date",
3929
- },
3930
- Description: {
3931
- type: "string",
3932
- },
3933
- Quantity: {
3934
- type: "number",
3935
- },
3936
- ProductCode: {
3937
- type: "string",
3938
- },
3939
- Tax: {
3940
- type: "currency",
3941
- },
3942
- Unit: {
3943
- type: "string",
3944
- },
3945
- UnitPrice: {
3946
- type: "currency",
3947
- },
3948
- VAT: {
3949
- type: "currency",
3950
- },
3951
- },
3952
- },
3953
- },
3954
- },
3955
- },
3956
- },
3957
- };
3958
-
3959
- // Copyright (c) Microsoft Corporation.
3960
- // Licensed under the MIT license.
3961
- /**
3962
- * The schema of the prebuilt-receipt model.
3963
- */
3964
- const modelInfo$2 = {
3965
- modelId: "prebuilt-receipt",
3966
- description: "Prebuilt model to extract key information from English receipts, including merchant name, transaction date, transaction total, and more.",
3967
- createdDateTime: "2022-06-30T00:00:00.000Z",
3968
- apiVersion: "2022-06-30-preview",
3969
- docTypes: {
3970
- receipt: {
3971
- buildMode: "template",
3972
- fieldSchema: {
3973
- Locale: {
3974
- type: "string",
3975
- },
3976
- MerchantName: {
3977
- type: "string",
3978
- },
3979
- MerchantPhoneNumber: {
3980
- type: "phoneNumber",
3981
- },
3982
- MerchantAddress: {
3983
- type: "string",
3984
- },
3985
- Total: {
3986
- type: "number",
3987
- },
3988
- TransactionDate: {
3989
- type: "date",
3990
- },
3991
- TransactionTime: {
3992
- type: "time",
3993
- },
3994
- Subtotal: {
3995
- type: "number",
3996
- },
3997
- TotalTax: {
3998
- type: "number",
3999
- },
4000
- Tip: {
4001
- type: "number",
4002
- },
4003
- Items: {
4004
- type: "array",
4005
- items: {
4006
- type: "object",
4007
- properties: {
4008
- TotalPrice: {
4009
- type: "number",
4010
- },
4011
- Description: {
4012
- type: "string",
4013
- },
4014
- Quantity: {
4015
- type: "number",
4016
- },
4017
- Price: {
4018
- type: "number",
4019
- },
4020
- },
4021
- },
4022
- },
4023
- },
4024
- },
4025
- "receipt.retailMeal": {
4026
- buildMode: "template",
4027
- fieldSchema: {
4028
- Locale: {
4029
- type: "string",
4030
- },
4031
- MerchantName: {
4032
- type: "string",
4033
- },
4034
- MerchantPhoneNumber: {
4035
- type: "phoneNumber",
4036
- },
4037
- MerchantAddress: {
4038
- type: "string",
4039
- },
4040
- Total: {
4041
- type: "number",
4042
- },
4043
- TransactionDate: {
4044
- type: "date",
4045
- },
4046
- TransactionTime: {
4047
- type: "time",
4048
- },
4049
- Subtotal: {
4050
- type: "number",
4051
- },
4052
- TotalTax: {
4053
- type: "number",
4054
- },
4055
- Tip: {
4056
- type: "number",
4057
- },
4058
- Items: {
4059
- type: "array",
4060
- items: {
4061
- type: "object",
4062
- properties: {
4063
- TotalPrice: {
4064
- type: "number",
4065
- },
4066
- Description: {
4067
- type: "string",
4068
- },
4069
- Quantity: {
4070
- type: "number",
4071
- },
4072
- Price: {
4073
- type: "number",
4074
- },
4075
- },
4076
- },
4077
- },
4078
- },
4079
- },
4080
- "receipt.creditCard": {
4081
- buildMode: "template",
4082
- fieldSchema: {
4083
- Locale: {
4084
- type: "string",
4085
- },
4086
- MerchantName: {
4087
- type: "string",
4088
- },
4089
- MerchantPhoneNumber: {
4090
- type: "phoneNumber",
4091
- },
4092
- MerchantAddress: {
4093
- type: "string",
4094
- },
4095
- Total: {
4096
- type: "number",
4097
- },
4098
- TransactionDate: {
4099
- type: "date",
4100
- },
4101
- TransactionTime: {
4102
- type: "time",
4103
- },
4104
- Subtotal: {
4105
- type: "number",
4106
- },
4107
- TotalTax: {
4108
- type: "number",
4109
- },
4110
- Tip: {
4111
- type: "number",
4112
- },
4113
- Items: {
4114
- type: "array",
4115
- items: {
4116
- type: "object",
4117
- properties: {
4118
- TotalPrice: {
4119
- type: "number",
4120
- },
4121
- Description: {
4122
- type: "string",
4123
- },
4124
- Quantity: {
4125
- type: "number",
4126
- },
4127
- Price: {
4128
- type: "number",
4129
- },
4130
- },
4131
- },
4132
- },
4133
- },
4134
- },
4135
- "receipt.gas": {
4136
- buildMode: "template",
4137
- fieldSchema: {
4138
- Locale: {
4139
- type: "string",
4140
- },
4141
- MerchantName: {
4142
- type: "string",
4143
- },
4144
- MerchantPhoneNumber: {
4145
- type: "phoneNumber",
4146
- },
4147
- MerchantAddress: {
4148
- type: "string",
4149
- },
4150
- Total: {
4151
- type: "number",
4152
- },
4153
- TransactionDate: {
4154
- type: "date",
4155
- },
4156
- TransactionTime: {
4157
- type: "time",
4158
- },
4159
- Subtotal: {
4160
- type: "number",
4161
- },
4162
- TotalTax: {
4163
- type: "number",
4164
- },
4165
- Tip: {
4166
- type: "number",
4167
- },
4168
- Items: {
4169
- type: "array",
4170
- items: {
4171
- type: "object",
4172
- properties: {
4173
- TotalPrice: {
4174
- type: "number",
4175
- },
4176
- Description: {
4177
- type: "string",
4178
- },
4179
- Quantity: {
4180
- type: "number",
4181
- },
4182
- Price: {
4183
- type: "number",
4184
- },
4185
- },
4186
- },
4187
- },
4188
- },
4189
- },
4190
- "receipt.parking": {
4191
- buildMode: "template",
4192
- fieldSchema: {
4193
- Locale: {
4194
- type: "string",
4195
- },
4196
- MerchantName: {
4197
- type: "string",
4198
- },
4199
- MerchantPhoneNumber: {
4200
- type: "phoneNumber",
4201
- },
4202
- MerchantAddress: {
4203
- type: "string",
4204
- },
4205
- Total: {
4206
- type: "number",
4207
- },
4208
- TransactionDate: {
4209
- type: "date",
4210
- },
4211
- TransactionTime: {
4212
- type: "time",
4213
- },
4214
- Subtotal: {
4215
- type: "number",
4216
- },
4217
- TotalTax: {
4218
- type: "number",
4219
- },
4220
- Tip: {
4221
- type: "number",
4222
- },
4223
- Items: {
4224
- type: "array",
4225
- items: {
4226
- type: "object",
4227
- properties: {
4228
- TotalPrice: {
4229
- type: "number",
4230
- },
4231
- Description: {
4232
- type: "string",
4233
- },
4234
- Quantity: {
4235
- type: "number",
4236
- },
4237
- Price: {
4238
- type: "number",
4239
- },
4240
- },
4241
- },
4242
- },
4243
- },
4244
- },
4245
- "receipt.hotel": {
4246
- buildMode: "template",
4247
- fieldSchema: {
4248
- MerchantName: {
4249
- type: "string",
4250
- },
4251
- MerchantPhoneNumber: {
4252
- type: "phoneNumber",
4253
- },
4254
- MerchantAddress: {
4255
- type: "string",
4256
- },
4257
- Total: {
4258
- type: "number",
4259
- },
4260
- ArrivalDate: {
4261
- type: "date",
4262
- },
4263
- DepartureDate: {
4264
- type: "date",
4265
- },
4266
- Currency: {
4267
- type: "string",
4268
- },
4269
- MerchantAliases: {
4270
- type: "array",
4271
- items: {
4272
- type: "string",
4273
- },
4274
- },
4275
- Items: {
4276
- type: "array",
4277
- items: {
4278
- type: "object",
4279
- properties: {
4280
- TotalPrice: {
4281
- type: "number",
4282
- },
4283
- Description: {
4284
- type: "string",
4285
- },
4286
- Date: {
4287
- type: "date",
4288
- },
4289
- Category: {
4290
- type: "string",
4291
- },
4292
- },
4293
- },
4294
- },
4295
- },
4296
- },
4297
- },
4298
- };
4299
-
4300
- // Copyright (c) Microsoft Corporation.
4301
- // Licensed under the MIT license.
4302
- /**
4303
- * The schema of the prebuilt-vaccinationCard model.
4304
- */
4305
- const modelInfo$1 = {
4306
- modelId: "prebuilt-vaccinationCard",
4307
- description: "Prebuilt model to extract key information from the US CDC Covid-19 vaccination cards.",
4308
- createdDateTime: "2022-03-30T00:00:00.000Z",
4309
- apiVersion: "2022-06-30-preview",
4310
- docTypes: {
4311
- "vaccinationCard.covid.us": {
4312
- buildMode: "template",
4313
- fieldSchema: {
4314
- CardHolderInfo: {
4315
- type: "object",
4316
- properties: {
4317
- FirstName: {
4318
- type: "string",
4319
- },
4320
- LastNames: {
4321
- type: "string",
4322
- },
4323
- DateOfBirth: {
4324
- type: "date",
4325
- },
4326
- PatientNumber: {
4327
- type: "string",
4328
- },
4329
- },
4330
- },
4331
- Vaccines: {
4332
- type: "array",
4333
- items: {
4334
- type: "object",
4335
- properties: {
4336
- Manufacturer: {
4337
- type: "string",
4338
- },
4339
- DateAdministered: {
4340
- type: "date",
4341
- },
4342
- },
4343
- },
4344
- },
4345
- },
4346
- },
4347
- },
4348
- };
4349
-
4350
- // Copyright (c) Microsoft Corporation.
4351
- // Licensed under the MIT license.
4352
- /**
4353
- * The schema of the prebuilt-tax.us.w2 model.
4354
- */
4355
- const modelInfo = {
4356
- modelId: "prebuilt-tax.us.w2",
4357
- description: "Prebuilt model to extract key information from IRS US W2 tax forms (year 2018-2021)",
4358
- createdDateTime: "2022-06-30T00:00:00.000Z",
4359
- apiVersion: "2022-06-30-preview",
4360
- docTypes: {
4361
- "tax.us.w2": {
4362
- buildMode: "template",
4363
- fieldSchema: {
4364
- W2FormVariant: {
4365
- type: "string",
4366
- },
4367
- TaxYear: {
4368
- type: "string",
4369
- },
4370
- W2Copy: {
4371
- type: "string",
4372
- },
4373
- Employee: {
4374
- type: "object",
4375
- properties: {
4376
- SocialSecurityNumber: {
4377
- type: "string",
4378
- },
4379
- Name: {
4380
- type: "string",
4381
- },
4382
- Address: {
4383
- type: "address",
4384
- },
4385
- },
4386
- },
4387
- ControlNumber: {
4388
- type: "string",
4389
- },
4390
- Employer: {
4391
- type: "object",
4392
- properties: {
4393
- IdNumber: {
4394
- type: "string",
4395
- },
4396
- Name: {
4397
- type: "string",
4398
- },
4399
- Address: {
4400
- type: "address",
4401
- },
4402
- },
4403
- },
4404
- WagesTipsAndOtherCompensation: {
4405
- type: "number",
4406
- },
4407
- FederalIncomeTaxWithheld: {
4408
- type: "number",
4409
- },
4410
- SocialSecurityWages: {
4411
- type: "number",
4412
- },
4413
- SocialSecurityTaxWithheld: {
4414
- type: "number",
4415
- },
4416
- MedicareWagesAndTips: {
4417
- type: "number",
4418
- },
4419
- MedicareTaxWithheld: {
4420
- type: "number",
4421
- },
4422
- SocialSecurityTips: {
4423
- type: "number",
4424
- },
4425
- AllocatedTips: {
4426
- type: "number",
4427
- },
4428
- VerificationCode: {
4429
- type: "string",
4430
- },
4431
- DependentCareBenefits: {
4432
- type: "number",
4433
- },
4434
- NonQualifiedPlans: {
4435
- type: "number",
4436
- },
4437
- AdditionalInfo: {
4438
- type: "array",
4439
- items: {
4440
- type: "object",
4441
- properties: {
4442
- LetterCode: {
4443
- type: "string",
4444
- },
4445
- Amount: {
4446
- type: "number",
4447
- },
4448
- },
4449
- },
4450
- },
4451
- IsStatutoryEmployee: {
4452
- type: "string",
4453
- },
4454
- IsRetirementPlan: {
4455
- type: "string",
4456
- },
4457
- IsThirdPartySickPay: {
4458
- type: "string",
4459
- },
4460
- Other: {
4461
- type: "string",
4462
- },
4463
- StateTaxInfos: {
4464
- type: "array",
4465
- items: {
4466
- type: "object",
4467
- properties: {
4468
- State: {
4469
- type: "string",
4470
- },
4471
- EmployerStateIdNumber: {
4472
- type: "string",
4473
- },
4474
- "StateWagesTipsEtc ": {
4475
- type: "number",
4476
- },
4477
- "StateIncomeTax ": {
4478
- type: "number",
4479
- },
4480
- },
4481
- },
4482
- },
4483
- LocalTaxInfos: {
4484
- type: "array",
4485
- items: {
4486
- type: "object",
4487
- properties: {
4488
- LocalWagesTipsEtc: {
4489
- type: "number",
4490
- },
4491
- LocalIncomeTax: {
4492
- type: "number",
4493
- },
4494
- LocalityName: {
4495
- type: "string",
4496
- },
4497
- },
4498
- },
4499
- },
4500
- },
4501
- },
4502
- },
4503
- };
4504
-
4505
- // Copyright (c) Microsoft Corporation.
4506
- // This symbol is used to index the transformation function. We might replace this with a normal string property key
4507
- // later, but for now this symbol allows us to hide it.
4508
- const fromDocument = Symbol("fromDocument");
4509
- /**
4510
- * Checks a field value against a schema and converts it into a strong idiomatic DocumentField,
4511
- * @internal
4512
- * @param fieldName - the name of the field (used in diagnostics)
4513
- * @param schema - the field's schema
4514
- * @param field - the raw DocumentField value
4515
- * @returns
4516
- */
4517
- function extractField(fieldName, schema, field) {
4518
- if (schema.type !== field.kind) {
4519
- throw new Error(`Schema violation: ${fieldName} had type "${field.kind}", but expected "${schema.type}"`);
4520
- }
4521
- // Objects need to be handled specially, so that we can camelCase the field names.
4522
- if (field.kind === "object") {
4523
- const result = {};
4524
- for (const [subFieldName, subFieldSchema] of Object.entries(schema.properties)) {
4525
- if (field.properties[subFieldName] !== undefined && field.properties[subFieldName] !== null) {
4526
- result[isAcronymic(subFieldName) ? subFieldName : uncapitalize(subFieldName)] =
4527
- extractField(fieldName + "." + subFieldName, subFieldSchema, field.properties[subFieldName]);
4528
- }
4529
- }
4530
- return Object.assign(Object.assign({}, field), { properties: result });
4531
- }
4532
- else if (field.kind === "array") {
4533
- return Object.assign(Object.assign({}, field), { values: field.values.map((val, idx) => extractField(fieldName + "[" + idx + "]", schema.items, val)) });
4534
- }
4535
- else
4536
- return field;
4537
- }
4538
- /**
4539
- * Create a model that can extract documents using the given schema.
4540
- * @internal
4541
- * @param schema - model schema contents (see modelSchemas directory)
4542
- * @returns - a DocumentModel that encodes the schema
4543
- */
4544
- function createModelFromSchema(schema) {
4545
- return {
4546
- modelId: schema.modelId,
4547
- [fromDocument]: (documentValue) => {
4548
- const document = documentValue;
4549
- const result = {};
4550
- const model = schema.docTypes[document.docType];
4551
- if (model === undefined) {
4552
- throw new Error(`Unexpected document type "${document.docType}" in result using model "${schema.modelId}"`);
4553
- }
4554
- for (const [fieldName, fieldSchema] of Object.entries(model.fieldSchema)) {
4555
- if (document.fields &&
4556
- document.fields[fieldName] !== undefined &&
4557
- document.fields[fieldName] !== null) {
4558
- result[isAcronymic(fieldName) ? fieldName : uncapitalize(fieldName)] = extractField(fieldName, fieldSchema, toDocumentField(document.fields[fieldName]));
4559
- }
4560
- }
4561
- return {
4562
- docType: document.docType,
4563
- fields: result,
4564
- };
4565
- },
4566
- };
4567
- }
4568
- /**
4569
- * Extract the mapper from a model object.
4570
- * @internal
4571
- * @param model - a DocumentModel object
4572
- * @returns - a function that transforms base AnalyzeResult Document objects into the DocumentModel's Document objects
4573
- */
4574
- function getMapper(model) {
4575
- return model[fromDocument];
4576
- }
4577
- /**
4578
- * **Deprecation Warning**: This object, along with all of its fields, is deprecated and will be replaced prior to a
4579
- * stable release of `@azure/ai-form-recognizer` 4.0.0. Please see
4580
- * [the deprecation notice](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/formrecognizer/ai-form-recognizer/README.md#prebuiltmodels-deprecation)
4581
- * in the README for more information.
4582
- *
4583
- * Prebuilt models with well-known document types and corresponding field schemas.
4584
- *
4585
- * These prebuilt `DocumentModel` objects can be used with the `beginAnalyzeDocuments` method to extract documents with
4586
- * a stronger TypeScript result type and property names that have been converted to use a JavaScript naming convention.
4587
- *
4588
- * ### Example:
4589
- *
4590
- * ```javascript
4591
- * import { AzureKeyCredential, DocumentAnalysisClient, PrebuiltModels } from "@azure/ai-form-recognizer";
4592
- *
4593
- * const credential = new AzureKeyCredential("<API key>">);
4594
- * const client = new DocumentAnalysisClient("<endpoint>", credential);
4595
- *
4596
- * const poller = await client.beginAnalyzeDocuments(PrebuiltModels.Receipt, "<receipt file URL>");
4597
- *
4598
- * // Extract the first document from the response, which should be a receipt
4599
- * const { documents: [receipt] } = await poller.pollUntilDone();
4600
- *
4601
- * // If we had used the model ID "prebuilt-receipt" instead of the `PrebuiltModels.Receipt` data structure, then the
4602
- * // fields of the receipt would be in PascalCase (rather than camelCase), and the TypeScript type of the fields would
4603
- * // not be as strict. This reduces the burden of casting fields to the appropriate types.
4604
- *
4605
- * console.log("The type of this receipt is:", receipt.fields.receiptType?.value)
4606
- * ```
4607
- *
4608
- * @deprecated will be removed and replaced with auto-generated code in the next stable version
4609
- */
4610
- const PrebuiltModels = {
4611
- /**
4612
- * @deprecated will be removed and replaced with auto-generated code in the next stable version
4613
- */
4614
- BusinessCard: createModelFromSchema(modelInfo$6),
4615
- /**
4616
- * @deprecated will be removed and replaced with auto-generated code in the next stable version
4617
- */
4618
- IdentityDocument: createModelFromSchema(modelInfo$4),
4619
- /**
4620
- * @deprecated will be removed and replaced with auto-generated code in the next stable version
4621
- */
4622
- Invoice: createModelFromSchema(modelInfo$3),
4623
- /**
4624
- * @deprecated will be removed and replaced with auto-generated code in the next stable version
4625
- */
4626
- Receipt: createModelFromSchema(modelInfo$2),
4627
- /**
4628
- * @deprecated will be removed and replaced with auto-generated code in the next stable version
4629
- */
4630
- TaxUsW2: createModelFromSchema(modelInfo),
4631
- /**
4632
- * @deprecated will be removed and replaced with auto-generated code in the next stable version
4633
- */
4634
- VaccinationCard: createModelFromSchema(modelInfo$1),
4635
- /**
4636
- * @deprecated will be removed and replaced with auto-generated code in the next stable version
4637
- */
4638
- HealthInsuranceCardUs: createModelFromSchema(modelInfo$5),
4639
- };
4640
-
4641
- // Copyright (c) Microsoft Corporation.
4642
- /**
4643
- * A client for interacting with the Form Recognizer service's analysis features.
4644
- *
4645
- * ### Examples:
4646
- *
4647
- * The Form Recognizer service and clients support two means of authentication:
4648
- *
4649
- * #### Azure Active Directory
4650
- *
4651
- * ```javascript
4652
- * import { DocumentAnalysisClient } from "@azure/ai-form-recognizer";
4653
- * import { DefaultAzureCredential } from "@azure/identity";
4654
- *
4655
- * const endpoint = "https://<resource name>.cognitiveservices.azure.com";
4656
- * const credential = new DefaultAzureCredential();
4657
- *
4658
- * const client = new DocumentAnalysisClient(endpoint, credential);
4659
- * ```
4660
- *
4661
- * #### API Key (Subscription Key)
4662
- *
4663
- * ```javascript
4664
- * import { DocumentAnalysisClient, AzureKeyCredential } from "@azure/ai-form-recognizer";
4665
- *
4666
- * const endpoint = "https://<resource name>.cognitiveservices.azure.com";
4667
- * const credential = new AzureKeyCredential("<api key>");
4668
- *
4669
- * const client = new DocumentAnalysisClient(endpoint, credential);
4670
- * ```
4671
- */
4672
- class DocumentAnalysisClient {
4673
- constructor(endpoint, credential, options = {}) {
4674
- this._restClient = makeServiceClient(endpoint, credential, options);
4675
- this._tracing = coreTracing.createTracingClient({
4676
- packageName: "@azure/ai-form-recognizer",
4677
- packageVersion: SDK_VERSION,
4678
- namespace: "Microsoft.CognitiveServices",
4679
- });
4680
- }
4681
- async beginAnalyzeDocument(model, input, options = {}) {
4682
- return this._tracing.withSpan("DocumentAnalysisClient.beginAnalyzeDocument", options, (finalOptions) => {
4683
- const initialModelId = typeof model === "string" ? model : model.modelId;
4684
- return this.createAnalysisPoller(input, {
4685
- initialModelId,
4686
- options: finalOptions,
4687
- transformResult: (result) => toAnalyzeResultFromGenerated(result, typeof model === "string" ? toAnalyzedDocumentFromGenerated : getMapper(model)),
4688
- });
4689
- });
4690
- }
4691
- /**
4692
- * **Deprecation Warning**: This method is deprecated and will be replaced prior to a stable release of
4693
- * `@azure/ai-form-recognizer` 4.0.0. Please see
4694
- * [the deprecation notice](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/formrecognizer/ai-form-recognizer/README.md#beginextractlayout-deprecation)
4695
- * in the README for more information.
4696
- *
4697
- * Extracts only the layout (basic OCR information) from an input file. The layout result includes information about
4698
- * the pages and their text contents, extracted tables, and identified text styles.
4699
- *
4700
- * ### Examples
4701
- *
4702
- * This method supports both URLs (string) and streamable request bodies ({@link FormRecognizerRequestBody}) such as
4703
- * Node.JS `ReadableStream` objects, browser `Blob`s, and `ArrayBuffer`s.
4704
- *
4705
- * #### From URL
4706
- *
4707
- * The Form Recognizer service will attempt to download a file using the submitted URL, so the URL must be accessible
4708
- * from the public internet. For example, a SAS token can be used to grant read access to a blob in Azure Storage, and
4709
- * the service will use the SAS-encoded URL to request the file.
4710
- *
4711
- * ```javascript
4712
- * // the URL must be publicly accessible
4713
- * const url = "<document url>";
4714
- *
4715
- * const poller = await client.beginExtractLayout(url);
4716
- *
4717
- * // The result is a long-running operation (poller), which must itself be polled until the operation completes
4718
- * const {
4719
- * pages, // pages extracted from the document, which contain lines and words
4720
- * tables, // extracted tables, organized into cells that contain their contents
4721
- * styles // text styles (ex. handwriting) that were observed in the document
4722
- * } = await poller.pollUntilDone();
4723
- * ```
4724
- *
4725
- * #### From Request Body
4726
- *
4727
- * Alternatively, if the file is local (or in memory in the browser), a binary object can be uploaded. The following
4728
- * example uses the Node.JS filesystem API.
4729
- *
4730
- * ```javascript
4731
- * import * as fs from "fs";
4732
- *
4733
- * const file = fs.createReadStream("path/to/file.pdf");
4734
- *
4735
- * const poller = await client.beginExtractLayout(file);
4736
- *
4737
- * // The result is a long-running operation (poller), which must itself be polled until the operation completes
4738
- * const {
4739
- * pages, // pages extracted from the document, which contain lines and words
4740
- * tables, // extracted tables, organized into cells that contain their contents
4741
- * styles // text styles (ex. handwriting) that were observed in the document
4742
- * } = await poller.pollUntilDone();
4743
- * ```
4744
- *
4745
- * @param input - a URL (string) to an input document accessible from the public internet, or a
4746
- * {@link FormRecognizerRequestBody} that will be uploaded with the request
4747
- * @param options - optional settings for the analysis operation and poller
4748
- * @returns a long-running operation (poller) that will eventually produce a layout result or an error
4749
- * @deprecated will be replaced in a future version (prior to a stable release)
4750
- */
4751
- async beginExtractLayout(input,
4752
- // eslint-disable-next-line @azure/azure-sdk/ts-naming-options
4753
- options = {}) {
4754
- return this._tracing.withSpan("DocumentAnalysisClient.beginExtractLayout", options, (finalOptions) => this.createAnalysisPoller(input, {
4755
- initialModelId: "prebuilt-layout",
4756
- options: finalOptions,
4757
- transformResult: (res) => toLayoutResult(toAnalyzeResultFromGenerated(res, identity)),
4758
- }));
4759
- }
4760
- /**
4761
- * **Deprecation Warning**: This method is deprecated and will be replaced prior to a stable release of
4762
- * `@azure/ai-form-recognizer` 4.0.0. Please see
4763
- * [the deprecation notice](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/formrecognizer/ai-form-recognizer/README.md#beginextractgeneraldocument-deprecation)
4764
- * in the README for more information.
4765
- *
4766
- * Extracts general document information from an input file. The general document result includes the information from
4767
- * layout analysis (pages, tables, and styles) as well as extracted key-value pairs and entities.
4768
- *
4769
- * ### Examples
4770
- *
4771
- * This method supports both URLs (string) and streamable request bodies ({@link FormRecognizerRequestBody}) such as
4772
- * Node.JS `ReadableStream` objects, browser `Blob`s, and `ArrayBuffer`s.
4773
- *
4774
- * #### From URL
4775
- *
4776
- * The Form Recognizer service will attempt to download a file using the submitted URL, so the URL must be accessible
4777
- * from the public internet. For example, a SAS token can be used to grant read access to a blob in Azure Storage, and
4778
- * the service will use the SAS-encoded URL to request the file.
4779
- *
4780
- * ```javascript
4781
- * // the URL must be publicly accessible
4782
- * const url = "<document url>";
4783
- *
4784
- * const poller = await client.beginExtractGeneralDocument(url);
4785
- *
4786
- * // The result is a long-running operation (poller), which must itself be polled until the operation completes
4787
- * const {
4788
- * // the operation produces the fields from the layout operation
4789
- * pages, // pages extracted from the document, which contain lines and words
4790
- * tables, // extracted tables, organized into cells that contain their contents
4791
- * styles, // text styles (ex. handwriting) that were observed in the document
4792
- *
4793
- * // it also produces the following fields in addition
4794
- * keyValuePairs, // extracted pairs of elements (directed associations from one element in the input to another)
4795
- * entities // extracted entities in the input's content, which are categorized (ex. "Location" or "Organization")
4796
- * } = await poller.pollUntilDone();
4797
- * ```
4798
- *
4799
- * #### From Request Body
4800
- *
4801
- * Alternatively, if the file is local (or in memory in the browser), a binary object can be uploaded. The following
4802
- * example uses the Node.JS filesystem API.
4803
- *
4804
- * ```javascript
4805
- * import * as fs from "fs";
4806
- *
4807
- * const file = fs.createReadStream("path/to/file.pdf");
4808
- *
4809
- * const poller = await client.beginExtractGeneralDocument(file);
4810
- *
4811
- * // The result is a long-running operation (poller), which must itself be polled until the operation completes
4812
- * const {
4813
- * // the operation produces the fields from the layout operation
4814
- * pages, // pages extracted from the document, which contain lines and words
4815
- * tables, // extracted tables, organized into cells that contain their contents
4816
- * styles, // text styles (ex. handwriting) that were observed in the document
4817
- *
4818
- * // it also produces the following fields in addition
4819
- * keyValuePairs, // extracted pairs of elements (directed associations from one element in the input to another)
4820
- * entities // extracted entities in the input's content, which are categorized (ex. "Location" or "Organization")
4821
- * } = await poller.pollUntilDone();
4822
- * ```
4823
- *
4824
- * @param input - a URL (string) to an input document accessible from the public internet, or a
4825
- * {@link FormRecognizerRequestBody} that will be uploaded with the request
4826
- * @param options - optional settings for the analysis operation and poller
4827
- * @returns a long-running operation (poller) that will eventually produce a general document result or an error
4828
- * @deprecated will be replaced in a future version (prior to a stable release)
4829
- */
4830
- async beginExtractGeneralDocument(input,
4831
- // eslint-disable-next-line @azure/azure-sdk/ts-naming-options
4832
- options = {}) {
4833
- return this._tracing.withSpan("DocumentAnalysisClient.beginExtractGeneralDocument", options, (finalOptions) => this.createAnalysisPoller(input, {
4834
- initialModelId: "prebuilt-document",
4835
- options: finalOptions,
4836
- transformResult: (res) => toGeneralDocumentResult(toAnalyzeResultFromGenerated(res, identity)),
4837
- }));
4838
- }
4839
- /**
4840
- * **Deprecation Warning**: This method is deprecated and will be replaced prior to a stable release of
4841
- * `@azure/ai-form-recognizer` 4.0.0. Please see
4842
- * [the deprecation notice](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/formrecognizer/ai-form-recognizer/README.md#beginreaddocument-deprecation)
4843
- * in the README for more information.
4844
- *
4845
- * Extracts textual information from a document such as the text contents of pages and identified written languages.
4846
- *
4847
- * ### Examples
4848
- *
4849
- * This method supports both URLs (string) and streamable request bodies ({@link FormRecognizerRequestBody}) such as
4850
- * Node.JS `ReadableStream` objects, browser `Blob`s, and `ArrayBuffer`s.
4851
- *
4852
- * #### From URL
4853
- *
4854
- * The Form Recognizer service will attempt to download a file using the submitted URL, so the URL must be accessible
4855
- * from the public internet. For example, a SAS token can be used to grant read access to a blob in Azure Storage, and
4856
- * the service will use the SAS-encoded URL to request the file.
4857
- *
4858
- * ```javascript
4859
- * // the URL must be publicly accessible
4860
- * const url = "<document url>";
4861
- *
4862
- * const poller = await client.beginReadDocument(url);
4863
- *
4864
- * // The result is a long-running operation (poller), which must itself be polled until the operation completes
4865
- * const {
4866
- * // This operation only produces `pages` and `languages`
4867
- * pages, // pages extracted from the document, which contain lines and words
4868
- * languages, // extracted spans identifying the written language of text in the document
4869
- * } = await poller.pollUntilDone();
4870
- * ```
4871
- *
4872
- * #### From Request Body
4873
- *
4874
- * Alternatively, if the file is local (or in memory in the browser), a binary object can be uploaded. The following
4875
- * example uses the Node.JS filesystem API.
4876
- *
4877
- * ```javascript
4878
- * import * as fs from "fs";
4879
- *
4880
- * const file = fs.createReadStream("path/to/file.pdf");
4881
- *
4882
- * const poller = await client.beginReadDocument(file);
4883
- *
4884
- * // The result is a long-running operation (poller), which must itself be polled until the operation completes
4885
- * const {
4886
- * // This operation only produces `pages` and `languages`
4887
- * pages, // pages extracted from the document, which contain lines and words
4888
- * languages, // extracted spans identifying the written language of text in the document
4889
- * } = await poller.pollUntilDone();
4890
- * ```
4891
- *
4892
- * @param input - a URL (string) to an input document accessible from the public internet, or a
4893
- * {@link FormRecognizerRequestBody} that will be uploaded with the request
4894
- * @param options - optional settings for the analysis operation and poller
4895
- * @returns a long-running operation (poller) that will eventually produce a read result or an error
4896
- * @deprecated will be replaced in a future version (prior to a stable release)
4897
- */
4898
- async beginReadDocument(input,
4899
- // eslint-disable-next-line @azure/azure-sdk/ts-naming-options
4900
- options = {}) {
4901
- return this._tracing.withSpan("DocumentAnalysisClient.beginReadDocument", options, (finalOptions) => this.createAnalysisPoller(input, {
4902
- initialModelId: "prebuilt-read",
4903
- options: finalOptions,
4904
- transformResult: (res) => toReadResult(toAnalyzeResultFromGenerated(res, identity)),
4905
- }));
4906
- }
4907
- /**
4908
- * Create an LRO poller that handles analysis operations.
4909
- *
4910
- * This is the meat of all analysis polling operations.
4911
- *
4912
- * @param input - either a string for URL inputs or a FormRecognizerRequestBody to upload a file directly to the Form
4913
- * Recognizer API
4914
- * @param definition - operation definition (initial model ID, operation transforms, request options)
4915
- * @returns - an analysis poller that produces the given return types according to the operation spec
4916
- */
4917
- async createAnalysisPoller(input, definition) {
4918
- const { resumeFrom } = definition.options;
4919
- // TODO: what should we do if resumeFrom.modelId is different from initialModelId?
4920
- // And what do we do with the redundant input??
4921
- const getAnalyzeResult = (operationLocation) => this._tracing.withSpan("DocumentAnalysisClient.createAnalysisPoller-getAnalyzeResult", definition.options, (finalOptions) => this._restClient.sendOperationRequest({
4922
- options: finalOptions,
4923
- }, {
4924
- path: operationLocation,
4925
- httpMethod: "GET",
4926
- responses: {
4927
- 200: {
4928
- bodyMapper: AnalyzeResultOperation,
4929
- },
4930
- default: {
4931
- bodyMapper: ErrorResponse,
4932
- },
4933
- },
4934
- // URL is fully-formed, so we don't need any query parameters
4935
- headerParameters: [accept1],
4936
- serializer: SERIALIZER,
4937
- }));
4938
- const toInit =
4939
- // If the user gave us a stored token, we'll poll it again
4940
- resumeFrom !== undefined
4941
- ? async () => this._tracing.withSpan("DocumentAnalysisClient.createAnalysisPoller-resume", definition.options, async () => {
4942
- const { operationLocation, modelId } = JSON.parse(resumeFrom);
4943
- const result = await getAnalyzeResult(operationLocation);
4944
- return toDocumentAnalysisPollOperationState(definition, modelId, operationLocation, result);
4945
- })
4946
- : // Otherwise, we'll start a new operation from the initialModelId
4947
- async () => this._tracing.withSpan("DocumentAnalysisClient.createAnalysisPoller-start", definition.options, async () => {
4948
- const [contentType, analyzeRequest] = toAnalyzeRequest(input);
4949
- const { operationLocation } = await this._restClient.analyzeDocument(definition.initialModelId, contentType, Object.assign(Object.assign({}, definition.options), { analyzeRequest }));
4950
- if (operationLocation === undefined) {
4951
- throw new Error("Unable to start analysis operation: no Operation-Location received.");
4952
- }
4953
- const result = await getAnalyzeResult(operationLocation);
4954
- return toDocumentAnalysisPollOperationState(definition, definition.initialModelId, operationLocation, result);
4955
- });
4956
- const poller = await lro({
4957
- init: toInit,
4958
- poll: async ({ operationLocation, modelId }) => this._tracing.withSpan("DocumentAnalysisClient.createAnalysisPoller-poll", {}, async () => {
4959
- const result = await getAnalyzeResult(operationLocation);
4960
- return toDocumentAnalysisPollOperationState(definition, modelId, operationLocation, result);
4961
- }),
4962
- serialize: ({ operationLocation, modelId }) => JSON.stringify({ modelId, operationLocation }),
4963
- }, definition.options.updateIntervalInMs);
4964
- if (definition.options.onProgress !== undefined) {
4965
- poller.onProgress(definition.options.onProgress);
4966
- definition.options.onProgress(poller.getOperationState());
4967
- }
4968
- return poller;
4969
- }
4970
- }
4971
- /**
4972
- * Produce an appropriate pair of content-type and analyzeRequest value for the analysis request.
4973
- * @internal
4974
- */
4975
- function toAnalyzeRequest(input) {
4976
- if (typeof input === "string") {
4977
- return [
4978
- "application/json",
4979
- {
4980
- urlSource: input,
4981
- },
4982
- ];
4983
- }
4984
- else {
4985
- return ["application/octet-stream", input];
4986
- }
4987
- }
4988
-
4989
- // Copyright (c) Microsoft Corporation.
4990
- /**
4991
- * Convert an operation result into a training poller state.
4992
- * @internal
4993
- */
4994
- async function toTrainingPollOperationState(response) {
4995
- var _a;
3526
+ async function toTrainingPollOperationState(response) {
3527
+ var _a;
4996
3528
  return {
4997
3529
  operationId: response.operationId,
4998
3530
  status: response.status,
4999
3531
  apiVersion: response.apiVersion,
5000
3532
  percentCompleted: (_a = response.percentCompleted) !== null && _a !== void 0 ? _a : 0,
5001
- lastUpdatedOn: response.lastUpdatedDateTime,
5002
- createdOn: response.createdDateTime,
5003
- result: response.result,
3533
+ lastUpdatedOn: response.lastUpdatedOn,
3534
+ createdOn: response.createdOn,
5004
3535
  error: response.error && new FormRecognizerError(response.error),
5005
3536
  isCancelled: response.status === "canceled",
5006
3537
  isCompleted: response.status === "succeeded",
5007
3538
  isStarted: response.status !== "notStarted",
5008
3539
  tags: response.tags,
3540
+ result: response.result,
5009
3541
  };
5010
3542
  }
5011
3543
 
@@ -5068,21 +3600,21 @@ class DocumentModelAdministrationClient {
5068
3600
  * const modelId = "aNewModel";
5069
3601
  * const containerUrl = "<training data container SAS URL>";
5070
3602
  *
5071
- * const poller = await client.beginBuildModel(modelId, containerUrl, {
3603
+ * const poller = await client.beginBuildDocumentModel(modelId, containerUrl, {
5072
3604
  * // Optionally, a text description may be attached to the model
5073
3605
  * description: "This is an example model!"
5074
3606
  * });
5075
3607
  *
5076
- * // Model building, like all other model creation operations, returns a poller that eventually produces a ModelInfo
3608
+ * // Model building, like all other model creation operations, returns a poller that eventually produces a ModelDetails
5077
3609
  * // object
5078
- * const modelInfo = await poller.pollUntilDone();
3610
+ * const modelDetails = await poller.pollUntilDone();
5079
3611
  *
5080
3612
  * const {
5081
3613
  * modelId, // identical to the modelId given when creating the model
5082
3614
  * description, // identical to the description given when creating the model
5083
- * createdDateTime, // the Date (timestamp) that the model was created
3615
+ * createdOn, // the Date (timestamp) that the model was created
5084
3616
  * docTypes // information about the document types in the model and their field schemas
5085
- * } = modelInfo;
3617
+ * } = modelDetails;
5086
3618
  * ```
5087
3619
  *
5088
3620
  * @param modelId - the unique ID of the model to create
@@ -5091,8 +3623,8 @@ class DocumentModelAdministrationClient {
5091
3623
  * @param options - optional settings for the model build operation
5092
3624
  * @returns a long-running operation (poller) that will eventually produce the created model information or an error
5093
3625
  */
5094
- async beginBuildModel(modelId, containerUrl, buildMode, options = {}) {
5095
- return this._tracing.withSpan("DocumentModelAdministrationClient.beginBuildModel", options, (finalOptions) => this.createTrainingPoller({
3626
+ async beginBuildDocumentModel(modelId, containerUrl, buildMode, options = {}) {
3627
+ return this._tracing.withSpan("DocumentModelAdministrationClient.beginBuildDocumentModel", options, (finalOptions) => this.createDocumentModelPoller({
5096
3628
  options: finalOptions,
5097
3629
  start: () => this._restClient.buildDocumentModel({
5098
3630
  modelId,
@@ -5122,20 +3654,20 @@ class DocumentModelAdministrationClient {
5122
3654
  *
5123
3655
  * // The resulting composed model can classify and extract data from documents
5124
3656
  * // conforming to any of the above document types
5125
- * const poller = await client.beginComposeModel(modelId, subModelIds, {
3657
+ * const poller = await client.beginComposeDocumentModel(modelId, subModelIds, {
5126
3658
  * description: "This is a composed model that can handle several document types."
5127
3659
  * });
5128
3660
  *
5129
3661
  * // Model composition, like all other model creation operations, returns a poller that eventually produces a
5130
- * // ModelInfo object
5131
- * const modelInfo = await poller.pollUntilDone();
3662
+ * // ModelDetails object
3663
+ * const modelDetails = await poller.pollUntilDone();
5132
3664
  *
5133
3665
  * const {
5134
3666
  * modelId, // identical to the modelId given when creating the model
5135
3667
  * description, // identical to the description given when creating the model
5136
- * createdDateTime, // the Date (timestamp) that the model was created
3668
+ * createdOn, // the Date (timestamp) that the model was created
5137
3669
  * docTypes // information about the document types of the composed submodels
5138
- * } = modelInfo;
3670
+ * } = modelDetails;
5139
3671
  * ```
5140
3672
  *
5141
3673
  * @param modelId - the unique ID of the model to create
@@ -5143,8 +3675,8 @@ class DocumentModelAdministrationClient {
5143
3675
  * @param options - optional settings for model creation
5144
3676
  * @returns a long-running operation (poller) that will eventually produce the created model information or an error
5145
3677
  */
5146
- async beginComposeModel(modelId, componentModelIds, options = {}) {
5147
- return this._tracing.withSpan("DocumentModelAdministrationClient.beginComposeModel", options, (finalOptions) => this.createTrainingPoller({
3678
+ async beginComposeDocumentModel(modelId, componentModelIds, options = {}) {
3679
+ return this._tracing.withSpan("DocumentModelAdministrationClient.beginComposeDocumentModel", options, (finalOptions) => this.createDocumentModelPoller({
5148
3680
  options: finalOptions,
5149
3681
  start: () => this._restClient.composeDocumentModel({
5150
3682
  modelId,
@@ -5201,16 +3733,16 @@ class DocumentModelAdministrationClient {
5201
3733
  * // Finally, use the _source_ client to copy the model and await the copy operation
5202
3734
  * const poller = await sourceClient.beginCopyModelTo("<source model ID>");
5203
3735
  *
5204
- * // Model copying, like all other model creation operations, returns a poller that eventually produces a ModelInfo
3736
+ * // Model copying, like all other model creation operations, returns a poller that eventually produces a ModelDetails
5205
3737
  * // object
5206
- * const modelInfo = await poller.pollUntilDone();
3738
+ * const modelDetails = await poller.pollUntilDone();
5207
3739
  *
5208
3740
  * const {
5209
3741
  * modelId, // identical to the modelId given when creating the copy authorization
5210
3742
  * description, // identical to the description given when creating the copy authorization
5211
- * createdDateTime, // the Date (timestamp) that the model was created
3743
+ * createdOn, // the Date (timestamp) that the model was created
5212
3744
  * docTypes // information about the document types of the model (identical to the original, source model)
5213
- * } = modelInfo;
3745
+ * } = modelDetails;
5214
3746
  * ```
5215
3747
  *
5216
3748
  * @param sourceModelId - the unique ID of the source model that will be copied
@@ -5219,23 +3751,23 @@ class DocumentModelAdministrationClient {
5219
3751
  * @returns a long-running operation (poller) that will eventually produce the copied model information or an error
5220
3752
  */
5221
3753
  async beginCopyModelTo(sourceModelId, authorization, options = {}) {
5222
- return this._tracing.withSpan("DocumentModelAdministrationClient.beginCopyModel", options, (finalOptions) => this.createTrainingPoller({
3754
+ return this._tracing.withSpan("DocumentModelAdministrationClient.beginCopyModel", options, (finalOptions) => this.createDocumentModelPoller({
5223
3755
  options: finalOptions,
5224
3756
  start: () => this._restClient.copyDocumentModelTo(sourceModelId, authorization, finalOptions),
5225
3757
  }));
5226
3758
  }
5227
3759
  /**
5228
- * Create an LRO poller that handles training operations.
3760
+ * Create an LRO poller that handles model creation operations.
5229
3761
  *
5230
- * This is the meat of all training polling operations.
3762
+ * This is the meat of the above model creation operations.
5231
3763
  *
5232
3764
  * @param definition - operation definition (start operation method, request options)
5233
- * @returns a training poller that produces a ModelInfo
3765
+ * @returns a model poller (produces a ModelDetails)
5234
3766
  */
5235
- async createTrainingPoller(definition) {
3767
+ async createDocumentModelPoller(definition) {
5236
3768
  const { resumeFrom } = definition.options;
5237
3769
  const toInit = resumeFrom === undefined
5238
- ? () => this._tracing.withSpan("DocumentModelAdministrationClient.createTrainingPoller-start", definition.options, async (options) => {
3770
+ ? () => this._tracing.withSpan("DocumentModelAdministrationClient.createDocumentModelPoller-start", definition.options, async (options) => {
5239
3771
  const { operationLocation } = await definition.start();
5240
3772
  if (operationLocation === undefined) {
5241
3773
  throw new Error("Unable to start model creation operation: no Operation-Location received.");
@@ -5247,7 +3779,7 @@ class DocumentModelAdministrationClient {
5247
3779
  httpMethod: "GET",
5248
3780
  responses: {
5249
3781
  200: {
5250
- bodyMapper: GetOperationResponse,
3782
+ bodyMapper: OperationDetails,
5251
3783
  },
5252
3784
  default: {
5253
3785
  bodyMapper: ErrorResponse,
@@ -5257,13 +3789,13 @@ class DocumentModelAdministrationClient {
5257
3789
  serializer: SERIALIZER,
5258
3790
  });
5259
3791
  })
5260
- : () => this._tracing.withSpan("DocumentModelAdministrationClient.createTrainingPoller-resume", definition.options, (options) => {
3792
+ : () => this._tracing.withSpan("DocumentModelAdministrationClient.createDocumentModelPoller-resume", definition.options, (options) => {
5261
3793
  const { operationId } = JSON.parse(resumeFrom);
5262
3794
  return this._restClient.getOperation(operationId, options);
5263
3795
  });
5264
3796
  const poller = await lro({
5265
3797
  init: async () => toTrainingPollOperationState(await toInit()),
5266
- poll: async ({ operationId }) => this._tracing.withSpan("DocumentModelAdminstrationClient.createTrainingPoller-poll", definition.options, async (options) => {
3798
+ poll: async ({ operationId }) => this._tracing.withSpan("DocumentModelAdminstrationClient.createDocumentModelPoller-poll", definition.options, async (options) => {
5267
3799
  const res = await this._restClient.getOperation(operationId, options);
5268
3800
  return toTrainingPollOperationState(res);
5269
3801
  }),
@@ -5285,32 +3817,32 @@ class DocumentModelAdministrationClient {
5285
3817
  * ```javascript
5286
3818
  * const {
5287
3819
  * // Information about the custom models in the current resource
5288
- * customDocumentModelInfo: {
3820
+ * customDocumentModelDetails: {
5289
3821
  * // The number of custom models in the current resource
5290
3822
  * count,
5291
3823
  * // The maximum number of models that the current resource can support
5292
3824
  * limit
5293
3825
  * }
5294
- * } = await client.getInfo();
3826
+ * } = await client.getResourceDetails();
5295
3827
  * ```
5296
3828
  *
5297
3829
  * @param options - optional settings for the request
5298
3830
  * @returns basic information about this client's resource
5299
3831
  */
5300
- getInfo(options = {}) {
5301
- return this._tracing.withSpan("DocumentModelAdministrationClient.getInfo", options, (finalOptions) => this._restClient.getInfo(finalOptions));
3832
+ getResourceDetails(options = {}) {
3833
+ return this._tracing.withSpan("DocumentModelAdministrationClient.getResourceDetails", options, (finalOptions) => this._restClient.getResourceDetails(finalOptions));
5302
3834
  }
5303
3835
  /**
5304
- * Retrieves information about a model ({@link ModelInfo}) by ID.
3836
+ * Retrieves information about a model ({@link ModelDetails}) by ID.
5305
3837
  *
5306
3838
  * This method can retrieve information about custom as well as prebuilt models.
5307
3839
  *
5308
3840
  * ### **Breaking Change**
5309
3841
  *
5310
3842
  * In previous versions of the Form Recognizer REST API and SDK, the `getModel` method could return any model, even
5311
- * one that failed to create due to errors. In the new service versions, `getModel` and `listModels` _only produce
5312
- * successfully created models_ (i.e. models that are "ready" for use). Failed models are now retrieved through the
5313
- * "operations" APIs, see {@link getOperation} and {@link listOperations}.
3843
+ * one that failed to create due to errors. In the new service versions, `getDocumentModel` and `listDocumentModels`
3844
+ * _only produce successfully created models_ (i.e. models that are "ready" for use). Failed models are now retrieved
3845
+ * through the "operations" APIs, see {@link getOperation} and {@link listOperations}.
5314
3846
  *
5315
3847
  * ### Example
5316
3848
  *
@@ -5319,9 +3851,9 @@ class DocumentModelAdministrationClient {
5319
3851
  * const modelId = "prebuilt-businessCard";
5320
3852
  *
5321
3853
  * const {
5322
- * modelId, // identical to the modelId given when calling `getModel`
3854
+ * modelId, // identical to the modelId given when calling `getDocumentModel`
5323
3855
  * description, // a textual description of the model, if provided during model creation
5324
- * createdDateTime, // the Date (timestamp) that the model was created
3856
+ * createdOn, // the Date (timestamp) that the model was created
5325
3857
  * // information about the document types in the model and their field schemas
5326
3858
  * docTypes: {
5327
3859
  * // the document type of the prebuilt business card model
@@ -5335,15 +3867,15 @@ class DocumentModelAdministrationClient {
5335
3867
  * fieldConfidence
5336
3868
  * }
5337
3869
  * }
5338
- * } = await client.getModel(modelId);
3870
+ * } = await client.getDocumentModel(modelId);
5339
3871
  * ```
5340
3872
  *
5341
3873
  * @param modelId - the unique ID of the model to query
5342
3874
  * @param options - optional settings for the request
5343
3875
  * @returns information about the model with the given ID
5344
3876
  */
5345
- getModel(modelId, options = {}) {
5346
- return this._tracing.withSpan("DocumentModelAdministrationClient.getModel", options, (finalOptions) => this._restClient.getModel(modelId, finalOptions));
3877
+ getDocumentModel(modelId, options = {}) {
3878
+ return this._tracing.withSpan("DocumentModelAdministrationClient.getDocumentModel", options, (finalOptions) => this._restClient.getDocumentModel(modelId, finalOptions));
5347
3879
  }
5348
3880
  /**
5349
3881
  * List summaries of models in the resource. Custom as well as prebuilt models will be included. This operation
@@ -5352,36 +3884,36 @@ class DocumentModelAdministrationClient {
5352
3884
  * The model summary ({@link ModelSummary}) includes only the basic information about the model, and does not include
5353
3885
  * information about the document types in the model (such as the field schemas and confidence values).
5354
3886
  *
5355
- * To access the full information about the model, use {@link getModel}.
3887
+ * To access the full information about the model, use {@link getDocumentModel}.
5356
3888
  *
5357
3889
  * ### **Breaking Change**
5358
3890
  *
5359
3891
  * In previous versions of the Form Recognizer REST API and SDK, the `listModels` method would return all models, even
5360
- * those that failed to create due to errors. In the new service versions, `listModels` and `getModels` _only produce
5361
- * successfully created models_ (i.e. models that are "ready" for use). Failed models are now retrieved through the
5362
- * "operations" APIs, see {@link getOperation} and {@link listOperations}.
3892
+ * those that failed to create due to errors. In the new service versions, `listDocumentModels` and `getDocumentModel`
3893
+ * _only produce successfully created models_ (i.e. models that are "ready" for use). Failed models are now retrieved
3894
+ * through the "operations" APIs, see {@link getOperation} and {@link listOperations}.
5363
3895
  *
5364
3896
  * ### Examples
5365
3897
  *
5366
3898
  * #### Async Iteration
5367
3899
  *
5368
3900
  * ```javascript
5369
- * for await (const summary of client.listModels()) {
3901
+ * for await (const summary of client.listDocumentModels()) {
5370
3902
  * const {
5371
3903
  * modelId, // The model's unique ID
5372
3904
  * description, // a textual description of the model, if provided during model creation
5373
3905
  * } = summary;
5374
3906
  *
5375
- * // You can get the full model info using `getModel`
5376
- * const model = await client.getModel(modelId);
3907
+ * // You can get the full model info using `getDocumentModel`
3908
+ * const model = await client.getDocumentModel(modelId);
5377
3909
  * }
5378
3910
  * ```
5379
3911
  *
5380
3912
  * #### By Page
5381
3913
  *
5382
3914
  * ```javascript
5383
- * // The listModels method is paged, and you can iterate by page using the `byPage` method.
5384
- * const pages = client.listModels().byPage();
3915
+ * // The listDocumentModels method is paged, and you can iterate by page using the `byPage` method.
3916
+ * const pages = client.listDocumentModels().byPage();
5385
3917
  *
5386
3918
  * for await (const page of pages) {
5387
3919
  * // Each page is an array of models and can be iterated synchronously
@@ -5391,8 +3923,8 @@ class DocumentModelAdministrationClient {
5391
3923
  * description, // a textual description of the model, if provided during model creation
5392
3924
  * } = summary;
5393
3925
  *
5394
- * // You can get the full model info using `getModel`
5395
- * const model = await client.getModel(modelId);
3926
+ * // You can get the full model info using `getDocumentModel`
3927
+ * const model = await client.getDocumentModel(modelId);
5396
3928
  * }
5397
3929
  * }
5398
3930
  * ```
@@ -5400,11 +3932,11 @@ class DocumentModelAdministrationClient {
5400
3932
  * @param options - optional settings for the model requests
5401
3933
  * @returns an async iterable of model summaries that supports paging
5402
3934
  */
5403
- listModels(options = {}) {
5404
- return this._restClient.listModels(options);
3935
+ listDocumentModels(options = {}) {
3936
+ return this._restClient.listDocumentModels(options);
5405
3937
  }
5406
3938
  /**
5407
- * Retrieves information about an operation (`OperationInfo`) by its ID.
3939
+ * Retrieves information about an operation (`OperationDetails`) by its ID.
5408
3940
  *
5409
3941
  * Operations represent non-analysis tasks, such as building, composing, or copying a model.
5410
3942
  *
@@ -5423,8 +3955,8 @@ class DocumentModelAdministrationClient {
5423
3955
  * kind, // the operation kind, one of "documentModelBuild", "documentModelCompose", or "documentModelCopyTo"
5424
3956
  * status, // the status of the operation, one of "notStarted", "running", "failed", "succeeded", or "canceled"
5425
3957
  * percentCompleted, // a number between 0 and 100 representing the progress of the operation
5426
- * createdDateTime, // a Date object that reflects the time when the operation was started
5427
- * lastUpdatedDateTime, // a Date object that reflects the time when the operation state was last modified
3958
+ * createdOn, // a Date object that reflects the time when the operation was started
3959
+ * lastUpdatedOn, // a Date object that reflects the time when the operation state was last modified
5428
3960
  * } = await client.getOperation(operationId);
5429
3961
  * ```
5430
3962
  */
@@ -5485,8 +4017,8 @@ class DocumentModelAdministrationClient {
5485
4017
  * @param modelId - the unique ID of the model to delete from the resource
5486
4018
  * @param options - optional settings for the request
5487
4019
  */
5488
- deleteModel(modelId, options = {}) {
5489
- return this._tracing.withSpan("DocumentModelAdministrationClient.deleteModel", options, (finalOptions) => this._restClient.deleteModel(modelId, finalOptions));
4020
+ deleteDocumentModel(modelId, options = {}) {
4021
+ return this._tracing.withSpan("DocumentModelAdministrationClient.deleteDocumentModel", options, (finalOptions) => this._restClient.deleteDocumentModel(modelId, finalOptions));
5490
4022
  }
5491
4023
  }
5492
4024
 
@@ -5509,19 +4041,83 @@ const DocumentModelBuildMode = {
5509
4041
  Neural: "neural",
5510
4042
  };
5511
4043
 
4044
+ // Copyright (c) Microsoft Corporation.
4045
+ /**
4046
+ * Checks a field value against a schema and converts it into a strong idiomatic DocumentField,
4047
+ * @internal
4048
+ * @param fieldName - the name of the field (used in diagnostics)
4049
+ * @param schema - the field's schema
4050
+ * @param field - the raw DocumentField value
4051
+ * @returns
4052
+ */
4053
+ function extractField(fieldName, schema, field) {
4054
+ if (schema.type !== field.kind) {
4055
+ throw new Error(`Schema violation: ${fieldName} had type "${field.kind}", but expected "${schema.type}"`);
4056
+ }
4057
+ // Objects need to be handled specially, so that we can camelCase the field names.
4058
+ if (field.kind === "object") {
4059
+ const result = {};
4060
+ for (const [subFieldName, subFieldSchema] of Object.entries(schema.properties)) {
4061
+ if (field.properties[subFieldName] !== undefined && field.properties[subFieldName] !== null) {
4062
+ result[isAcronymic(subFieldName) ? subFieldName : uncapitalize(subFieldName)] =
4063
+ extractField(fieldName + "." + subFieldName, subFieldSchema, field.properties[subFieldName]);
4064
+ }
4065
+ }
4066
+ return Object.assign(Object.assign({}, field), { properties: result });
4067
+ }
4068
+ else if (field.kind === "array") {
4069
+ return Object.assign(Object.assign({}, field), { values: field.values.map((val, idx) => extractField(fieldName + "[" + idx + "]", schema.items, val)) });
4070
+ }
4071
+ else
4072
+ return field;
4073
+ }
4074
+ /**
4075
+ * Create a DocumentModel that performs analysis using the given schema.
4076
+ *
4077
+ * The types of `documents` are created from the schema, so they are `unknown` unless they are asserted to be a
4078
+ * different type.
4079
+ *
4080
+ * @hidden
4081
+ * @param schema - model schema contents
4082
+ * @returns - a DocumentModel that encodes the schema
4083
+ */
4084
+ function createModelFromSchema(schema) {
4085
+ return {
4086
+ modelId: schema.modelId,
4087
+ apiVersion: schema.apiVersion,
4088
+ transformResult(baseResult) {
4089
+ var _a, _b, _c;
4090
+ const hasDocuments = Object.entries((_a = schema.docTypes) !== null && _a !== void 0 ? _a : {}).length > 0;
4091
+ const defaultDocuments = hasDocuments ? [] : undefined;
4092
+ return Object.assign(Object.assign({}, baseResult), { documents: (_c = (_b = baseResult.documents) === null || _b === void 0 ? void 0 : _b.map(toDocument)) !== null && _c !== void 0 ? _c : defaultDocuments });
4093
+ function toDocument(document) {
4094
+ var _a;
4095
+ const result = {};
4096
+ const model = (_a = schema.docTypes) === null || _a === void 0 ? void 0 : _a[document.docType];
4097
+ if (model === undefined) {
4098
+ throw new Error(`Unexpected document type "${document.docType}" in result using model "${schema.modelId}"`);
4099
+ }
4100
+ for (const [fieldName, fieldSchema] of Object.entries(model.fieldSchema)) {
4101
+ if (document.fields &&
4102
+ document.fields[fieldName] !== undefined &&
4103
+ document.fields[fieldName] !== null) {
4104
+ result[isAcronymic(fieldName) ? fieldName : uncapitalize(fieldName)] = extractField(fieldName, fieldSchema, document.fields[fieldName]);
4105
+ }
4106
+ }
4107
+ return Object.assign(Object.assign({}, document), { fields: result });
4108
+ }
4109
+ },
4110
+ };
4111
+ }
4112
+
5512
4113
  Object.defineProperty(exports, 'AzureKeyCredential', {
5513
4114
  enumerable: true,
5514
4115
  get: function () { return coreAuth.AzureKeyCredential; }
5515
4116
  });
5516
- exports.BusinessCardSchema = modelInfo$6;
5517
4117
  exports.DocumentAnalysisClient = DocumentAnalysisClient;
5518
4118
  exports.DocumentModelAdministrationClient = DocumentModelAdministrationClient;
5519
4119
  exports.DocumentModelBuildMode = DocumentModelBuildMode;
5520
4120
  exports.FormRecognizerApiVersion = FormRecognizerApiVersion;
5521
- exports.IdentityDocumentSchema = modelInfo$4;
5522
- exports.InvoiceSchema = modelInfo$3;
5523
- exports.PrebuiltModels = PrebuiltModels;
5524
- exports.ReceiptSchema = modelInfo$2;
5525
4121
  exports.StringIndexType = StringIndexType;
5526
- exports.TaxUsW2Schema = modelInfo;
4122
+ exports.createModelFromSchema = createModelFromSchema;
5527
4123
  //# sourceMappingURL=index.js.map