@azure/ai-text-analytics 5.2.0-beta.2 → 6.0.0-alpha.20220518.3

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 (103) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +375 -133
  3. package/dist/index.js +2797 -4176
  4. package/dist/index.js.map +1 -1
  5. package/dist-esm/src/azureKeyCredentialPolicy.js +2 -2
  6. package/dist-esm/src/azureKeyCredentialPolicy.js.map +1 -1
  7. package/dist-esm/src/constants.js +16 -0
  8. package/dist-esm/src/constants.js.map +1 -0
  9. package/dist-esm/src/generated/generatedClient.js +80 -334
  10. package/dist-esm/src/generated/generatedClient.js.map +1 -1
  11. package/dist-esm/src/generated/index.js +1 -1
  12. package/dist-esm/src/generated/index.js.map +1 -1
  13. package/dist-esm/src/generated/models/index.js +106 -35
  14. package/dist-esm/src/generated/models/index.js.map +1 -1
  15. package/dist-esm/src/generated/models/mappers.js +1625 -2101
  16. package/dist-esm/src/generated/models/mappers.js.map +1 -1
  17. package/dist-esm/src/generated/models/parameters.js +18 -105
  18. package/dist-esm/src/generated/models/parameters.js.map +1 -1
  19. package/dist-esm/src/generated/operations/analyzeText.js +105 -0
  20. package/dist-esm/src/generated/operations/analyzeText.js.map +1 -0
  21. package/dist-esm/src/generated/operations/index.js +9 -0
  22. package/dist-esm/src/generated/operations/index.js.map +1 -0
  23. package/dist-esm/src/generated/operationsInterfaces/analyzeText.js +9 -0
  24. package/dist-esm/src/generated/operationsInterfaces/analyzeText.js.map +1 -0
  25. package/dist-esm/src/generated/operationsInterfaces/index.js +9 -0
  26. package/dist-esm/src/generated/operationsInterfaces/index.js.map +1 -0
  27. package/dist-esm/src/index.js +14 -5
  28. package/dist-esm/src/index.js.map +1 -1
  29. package/dist-esm/src/lro.js +195 -0
  30. package/dist-esm/src/lro.js.map +1 -0
  31. package/dist-esm/src/models.js +42 -0
  32. package/dist-esm/src/models.js.map +1 -0
  33. package/dist-esm/src/textAnalysisClient.js +197 -0
  34. package/dist-esm/src/textAnalysisClient.js.map +1 -0
  35. package/dist-esm/src/transforms.js +279 -0
  36. package/dist-esm/src/transforms.js.map +1 -0
  37. package/dist-esm/src/util.js +35 -141
  38. package/dist-esm/src/util.js.map +1 -1
  39. package/package.json +25 -33
  40. package/types/ai-text-analytics.d.ts +1402 -1421
  41. package/CHANGELOG.md +0 -162
  42. package/dist-esm/src/analyzeActionsResult.js +0 -205
  43. package/dist-esm/src/analyzeActionsResult.js.map +0 -1
  44. package/dist-esm/src/analyzeHealthcareEntitiesResult.js +0 -53
  45. package/dist-esm/src/analyzeHealthcareEntitiesResult.js.map +0 -1
  46. package/dist-esm/src/analyzeLro.js +0 -132
  47. package/dist-esm/src/analyzeLro.js.map +0 -1
  48. package/dist-esm/src/analyzeSentimentResult.js +0 -74
  49. package/dist-esm/src/analyzeSentimentResult.js.map +0 -1
  50. package/dist-esm/src/analyzeSentimentResultArray.js +0 -11
  51. package/dist-esm/src/analyzeSentimentResultArray.js.map +0 -1
  52. package/dist-esm/src/detectLanguageResult.js +0 -17
  53. package/dist-esm/src/detectLanguageResult.js.map +0 -1
  54. package/dist-esm/src/detectLanguageResultArray.js +0 -11
  55. package/dist-esm/src/detectLanguageResultArray.js.map +0 -1
  56. package/dist-esm/src/extractKeyPhrasesResult.js +0 -17
  57. package/dist-esm/src/extractKeyPhrasesResult.js.map +0 -1
  58. package/dist-esm/src/extractKeyPhrasesResultArray.js +0 -11
  59. package/dist-esm/src/extractKeyPhrasesResultArray.js.map +0 -1
  60. package/dist-esm/src/extractSummaryResult.js +0 -17
  61. package/dist-esm/src/extractSummaryResult.js.map +0 -1
  62. package/dist-esm/src/extractSummaryResultArray.js +0 -11
  63. package/dist-esm/src/extractSummaryResultArray.js.map +0 -1
  64. package/dist-esm/src/generated/generatedClientContext.js +0 -42
  65. package/dist-esm/src/generated/generatedClientContext.js.map +0 -1
  66. package/dist-esm/src/healthLro.js +0 -139
  67. package/dist-esm/src/healthLro.js.map +0 -1
  68. package/dist-esm/src/multiCategoryClassifyResult.js +0 -17
  69. package/dist-esm/src/multiCategoryClassifyResult.js.map +0 -1
  70. package/dist-esm/src/multiCategoryClassifyResultArray.js +0 -11
  71. package/dist-esm/src/multiCategoryClassifyResultArray.js.map +0 -1
  72. package/dist-esm/src/pollerModels.js +0 -4
  73. package/dist-esm/src/pollerModels.js.map +0 -1
  74. package/dist-esm/src/recognizeCategorizedEntitiesResult.js +0 -17
  75. package/dist-esm/src/recognizeCategorizedEntitiesResult.js.map +0 -1
  76. package/dist-esm/src/recognizeCategorizedEntitiesResultArray.js +0 -11
  77. package/dist-esm/src/recognizeCategorizedEntitiesResultArray.js.map +0 -1
  78. package/dist-esm/src/recognizeCustomEntitiesResult.js +0 -17
  79. package/dist-esm/src/recognizeCustomEntitiesResult.js.map +0 -1
  80. package/dist-esm/src/recognizeCustomEntitiesResultArray.js +0 -11
  81. package/dist-esm/src/recognizeCustomEntitiesResultArray.js.map +0 -1
  82. package/dist-esm/src/recognizeLinkedEntitiesResult.js +0 -17
  83. package/dist-esm/src/recognizeLinkedEntitiesResult.js.map +0 -1
  84. package/dist-esm/src/recognizeLinkedEntitiesResultArray.js +0 -11
  85. package/dist-esm/src/recognizeLinkedEntitiesResultArray.js.map +0 -1
  86. package/dist-esm/src/recognizePiiEntitiesResult.js +0 -18
  87. package/dist-esm/src/recognizePiiEntitiesResult.js.map +0 -1
  88. package/dist-esm/src/recognizePiiEntitiesResultArray.js +0 -11
  89. package/dist-esm/src/recognizePiiEntitiesResultArray.js.map +0 -1
  90. package/dist-esm/src/singleCategoryClassifyResult.js +0 -17
  91. package/dist-esm/src/singleCategoryClassifyResult.js.map +0 -1
  92. package/dist-esm/src/singleCategoryClassifyResultArray.js +0 -11
  93. package/dist-esm/src/singleCategoryClassifyResultArray.js.map +0 -1
  94. package/dist-esm/src/textAnalyticsAction.js +0 -4
  95. package/dist-esm/src/textAnalyticsAction.js.map +0 -1
  96. package/dist-esm/src/textAnalyticsClient.js +0 -511
  97. package/dist-esm/src/textAnalyticsClient.js.map +0 -1
  98. package/dist-esm/src/textAnalyticsOperationOptions.js +0 -4
  99. package/dist-esm/src/textAnalyticsOperationOptions.js.map +0 -1
  100. package/dist-esm/src/textAnalyticsResult.js +0 -94
  101. package/dist-esm/src/textAnalyticsResult.js.map +0 -1
  102. package/dist-esm/src/tracing.js +0 -12
  103. package/dist-esm/src/tracing.js.map +0 -1
package/CHANGELOG.md DELETED
@@ -1,162 +0,0 @@
1
- # Release History
2
-
3
- ## 5.2.0-beta.2 (2021-11-02)
4
-
5
- ### Features Added
6
-
7
- - We are now targeting the service's v3.2-preview.2 API as the default instead of v3.2-preview.1.
8
- - Adding support for a three new actions in `beginAnalyzeActions`: `recognizeCustomEntities`, `singleCategoryClassify`, and `multiCategoryClassify`. The new actions allow you to use custom models to perform entity recognition and classification actions.
9
-
10
- ### Other Changes
11
-
12
- - `beginAnalyzeActions` supports actions to be named and the name is now accessible in each action result.
13
- - `beginAnalyzeActions` supports multiple actions of the same type so you can pass a list of any particular action type, e.g.
14
-
15
- ```typescript
16
- await client.beginAnalyzeActions(docs, { recognizePiiEntitiesActions: [
17
- { modelVersion: "latest", actionName: "action1" },
18
- { modelVersion: "2021-01-15", actionName: "action2" }]
19
- });
20
- ```
21
-
22
- ## 5.2.0-beta.1 (2021-08-09)
23
-
24
- ### Features Added
25
-
26
- - We are now targeting the service's v3.2-preview.1 API as the default instead of v3.1.
27
- - `beginAnalyzeActions` now supports extract summary actions.
28
-
29
- ## 5.1.0 (2021-07-07)
30
-
31
- ### New Features
32
-
33
- - We are now targeting the service's v3.1 API as the default instead of v3.1-preview.5.
34
- - `beginAnalyzeHealthcareEntities` now works with Azure Active Directory credentials.
35
- - `categoriesFilter` support was added to `RecognizePiiEntitiesAction`.
36
- - Updated our internal core package dependencies to their latest versions in order to add support for Opentelemetry 1.0.0 which is compatible with the latest versions of our other client libraries.
37
- - Changed TS compilation target to ES2017 in order to produce smaller bundles and use more native platform features
38
-
39
- ### Breaking Changes
40
-
41
- - `PiiEntityDomainType` was renamed to `PiiEntityDomain`.
42
- - `domain` property of `RecognizePiiEntitiesAction` was renamed to `domainFilter`.
43
- - `beginAnalyzeActions` is now limited to accept up to one action only per type.
44
-
45
- ## 5.1.0-beta.6 (2021-05-18)
46
-
47
- ### New Features
48
-
49
- - With the dropping of support for Node.js versions that are no longer in LTS, the dependency on `@types/node` has been updated to version 12. Read our [support policy](https://github.com/Azure/azure-sdk-for-js/blob/main/SUPPORT.md) for more details.
50
- - We are now targeting the service's v3.1-preview.5 API as the default instead of v3.1-preview.4.
51
- - `beginAnalyzeActions` adds support for analyze sentiment actions.
52
- - `disableServiceLogs` parameter is added to most actions in `beginAnalyzeActions` that controls service-side logging.
53
-
54
- ### Breaking Changes
55
-
56
- - `beginAnalyzeBatchActions` was renamed to `beginAnalyzeActions`.
57
- - `TextElements_v8` is renamed to `TextElement_v8` in model `StringIndexType`.
58
-
59
- ### Key Bug Fixes
60
-
61
- - Results of entity linking actions were not returned correctly by `beginAnalyzeActions` and that is now fixed.
62
-
63
- ## 5.1.0-beta.5 (2021-03-11)
64
-
65
- - We are now targeting the service's v3.1-preview.4 API as the default instead of v3.1-preview.3.
66
- - [Breaking] Aspects in opinions mining are now called targets and each individual opinion is now called an assessment. The new naming simplifies the naming of different parts of the response.
67
- - `beginAnalyzeBatchActions` can now process recognize linked entities actions.
68
- - `beginAnalyzeHealthcareEntities` returns `entityRelations` per document, a list of relations between healthcare entities.
69
- - `beginAnalyzeHealthcareEntities` entities now include `assertions` instead of `isNegated` which gives more context about the respective entity.
70
- - [Breaking] `beginAnalyzeHealthcareEntities` no longer returns `relatedEntities`.
71
- - `recognizePiiEntities` takes a new option, `categoriesFilter`, that specifies a list of Pii categories to return.
72
- - [Breaking] `statistics` is no longer part of `PagedAnalyzeBatchActionsResult`.
73
-
74
- ## 5.1.0-beta.4 (2021-02-10)
75
-
76
- - [Breaking] `beginAnalyzeHealthcare` is renamed to `beginAnalyzeHealthcareEntities`.
77
- - [Breaking] `beginAnalyze` is renamed to `beginAnalyzeBatchActions`.
78
- - A new option to control how the offset is calculated by the service, `stringIndexType`, is added to `analyzeSentiment`, `recognizeEntities`, `recognizePiiEntities`, and `beginAnalyzeHealthcareEntities`. Furthermore, `stringIndexType` is added to task types `RecognizeEntitiesAction` and `RecognizePiiEntitiesAction`, which are the types of input actions to the `beginAnalyzeBatchActions` method. For more information, see [the Text Analytics documentation](https://docs.microsoft.com/azure/cognitive-services/text-analytics/concepts/text-offsets#offsets-in-api-version-31-preview).
79
- - [Breaking] The healthcare entities returned by `beginAnalyzeHealthcare` are now organized as a directed graph where the edges represent a certain type of healthcare relationship between the source and target entities. Edges are stored in the `relatedEntities` property.
80
- - [Breaking] The `links` property of `HealthcareEntity` is renamed to `dataSources`, a list of objects representing medical databases, where each object has `name` and `entityId` properties.
81
- - The poller for the `beginAnalyzeBatchActions` long-running operation gained the ability to return certain metadata information about the currently running operation (e.g., when the operation was created, will be expired, and last time it was updated, and also how many actions completed and failed so far). Also, the poller for `beginAnalyzeHealthcareEntities` gained a similar ability.
82
- - [Breaking] the words "operation" and "action" are used consistently in our names and documentation instead of "job" and "task" respectively.
83
-
84
- ## 5.1.0-beta.3 (2020-11-23)
85
-
86
- - We are now targeting the service's v3.1-preview.3 API as the default instead of v3.1-preview.2.
87
- - We introduced the `beginAnalyze` API which supports long-running batch process of Named Entity Recognition, Personally identifiable Information, and Key Phrase Extraction.
88
- - We now have added support for the recognition of healthcare entities with the introduction of the `beginAnalyzeHealthcare` API. Since the Health API is currently only available in a gated preview, you need to have your subscription on the service's allow list. Note that since this is a gated preview, AAD is not supported. For more information, see [the Text Analytics for Health documentation](https://docs.microsoft.com/azure/cognitive-services/text-analytics/how-tos/text-analytics-for-health?tabs=ner#request-access-to-the-public-preview).
89
-
90
- ## 5.1.0-beta.2 (2020-10-06)
91
-
92
- - [Breaking] The `length` property is removed from `SentenceSentiment`, `Entity`, `Match`, `PiiEntity`, and `CategorizedEntity` because the length information can be accessed from the text property itself using the string's length property.
93
-
94
- ## 5.1.0-beta.1 (2020-09-17)
95
-
96
- - We are now targeting the service's v3.1-preview.2 API as the default instead of v3.0.
97
- - We now have added support for opinion mining feature of Sentiment Analysis. To get this support, pass `includeOpinionMining` as True when calling the `analyzeSentiment` endpoint.
98
- - We have added the `recognizePiiEntities` API which returns entities containing personal information for a batch of documents and also returns the redacted text.
99
- - The `length` and `offset` properties are added to the `SentenceSentiment`, `Entity`, `Match`, `PiiEntity` and `CategorizedEntity` interfaces to represent the length of the sentence's text and its offset from the start of the document. The unit of distance used is UTF-16 code points.
100
- - The `text` property of the `SentenceSentiment` interface is no longer marked as optional because the service has always returned it. This interface is used exclusively as an output type so this change does not break existing code.
101
- - `bingEntitySearchApiId` property is now returned for entities returned by `recognizeLinkedEntities` API and is added to the `LinkedEntity` interface. This property is to be used in conjunction with the Bing Entity Search API to fetch additional relevant information about the returned entity.
102
-
103
- ## 5.0.1 (2020-08-18)
104
-
105
- - Handles REST exceptions with code InvalidDocumentBatch in a way that maintains backward compatibility.
106
-
107
- ## 5.0.0 (2020-07-27)
108
-
109
- - Updated the package version to be 5.0.0 instead of 1.0.0 in order to reduce confusion with older versions of the Azure Text Analytics SDKs.
110
-
111
- ## 1.0.0 (2020-06-09)
112
-
113
- - This release marks the general availability of the `@azure/ai-text-analytics` package.
114
-
115
- ## 1.0.0-preview.5 (2020-05-26)
116
-
117
- - [Breaking] Renamed all result array types that extend JavaScript's base `Array` class to end with the word `Array` instead of `Collection` (e.g. `AnalyzeSentimentResultCollection` is now `AnalyzeSentimentResultArray`)
118
- - [Breaking] Renamed `score` to `confidenceScore` in the `Match`, `Entity`, and `DetectedLanguage` types.
119
- - [Breaking] Removed the `graphemeOffset` and `graphemeLength` properties of the `Match`, `Entity`, and `SentenceSentiment` types.
120
- - [Breaking] Renamed the `graphemeCount` property of `TextDocumentStatistics` back to `characterCount`
121
- - Added a `text` property to `SentenceSentiment` that contains the sentence text
122
- - [Breaking] Removed the `warnings` property of `SentenceSentiment`.
123
- - Added `warnings` property to every document response object containing a list of `TextAnalyticsWarning` objects relevant to the corresponding document.
124
- - Migrated to using the Text Analytics v3.0 (General Availability) service endpoint.
125
-
126
- ## 1.0.0-preview.4 (2020-04-07)
127
-
128
- - Renamed the first parameter of all operation methods from `inputs` to `documents`
129
- - [Breaking] Removed PII entity detection methods from `TextAnalyticsClient` as well as all associated samples and documentation
130
- - [Breaking] Replaced `TextAnalyticsApiKeyCredential` with `AzureKeyCredential` (re-exported through this package from `@azure/core-auth`).
131
- - `TextAnalyticsClient` methods now throw an error when the `documents` parameter is not an array or empty before sending a request to the Text Analytics service.
132
-
133
- ## 1.0.0-preview.3 (2020-03-10)
134
-
135
- - [Breaking] Renamed `id` to `dataSourceEntityId` in the `LinkedEntity` type.
136
- - Added special handling for the string `"none"` as the `countryHint` parameter of the `TextAnalyticsClient.detectLanguage`. `"none"` is now treated the same as the empty string, and indicates that the default language detection model should be used.
137
- - [Breaking] Renamed `offset` to `graphemeOffset` and `length` to `graphemeLength` in fields of response objects as appropriate in order to make it clear that the offsets and lengths are in units of Unicode graphemes.
138
- - [Breaking] Renamed `sentimentScores` on both `DocumentSentiment` and `SentenceSentiment` to `confidenceScores`, and renamed the type `SentimentScorePerLabel` to `SentimentConfidenceScores`.
139
- - [Breaking] Renamed `characterCount` to `graphemeCount` in the `DocumentStatistics` interface, to align with the change to using `grapheme` in the lengths/offsets of response objects.
140
-
141
- ## 1.0.0-preview.2 (2020-02-11)
142
-
143
- - Added support for rotating API keys via the `TextAnalyticsApiKeyCredential.updateKey` method.
144
- - Added a discriminant type for `TextAnalyticsResult.error` to allow for easy differentiation between success and error types using `if (result.error) { ... }` in both TypeScript and JavaScript.
145
- - [Breaking] Removed the `Entity` type and added new return types `CategorizedEntity` and `PiiEntity` for the `recognizeEntities` and `recognizePiiEntities` methods respectively. These types are equivalent to the previous `Entity` type.
146
- - [Breaking] Removed the `detectedLanguages` property from `DetectLanguageResult`, as the service currently only returns one language.
147
- - [Breaking] Renamed the `detectLanguages` method to `detectLanguage`, as the `detectedLanguages` property was removed from the `DetectLanguageResult` return type.
148
- - [Breaking] Renamed `documentScores` and `sentenceScores` on the `DocumentSentiment` and `SentenceSentiment` types both to `sentimentScores`.
149
- - [Breaking] Renamed `type` and `subtype` to `category` and `subcategory` respectively in the `CategorizedEntity` and `PiiEntity` types.
150
- - [Breaking] Renamed `DocumentSentimentValue` and `SentenceSentimentValue` to `DocumentSentimentLabel` and `SentenceSentimentLabel` respectively.
151
- - [Breaking] Renamed `SentimentConfidenceScorePerLabel` to `SentimentScorePerLabel`.
152
- - [Breaking] Refactored `TextAnalyticsError` to flatten the error hierarchy and remove `innerError`. The new error model has properties for `code`, `message`, and an optional `target` only. The `code` property of `TextAnalyticsError` can now contain all of the codes from the previous `InnerErrorCodeValue` as well as those from the top-level `ErrorCodeValue`.
153
-
154
- ## 1.0.0-preview.1 (2020-01-09)
155
-
156
- - This release is a preview of our efforts to create a client library that is user friendly and
157
- idiomatic to the JavaScript ecosystem. The reasons for most of the changes in this update can be found in the
158
- [Azure SDK Design Guidelines for TypeScript](https://azure.github.io/azure-sdk/typescript_introduction.html).
159
- - Differences from previous public package `@azure/cognitiveservices-textanalytics`
160
- - Package name changed from `@azure/cognitiveservices-textanalytics` to `@azure/ai-text-analytics`.
161
- - Package targets version `3.0` of the service API.
162
- - Supports authentication via `@azure/identity`.
@@ -1,205 +0,0 @@
1
- // Copyright (c) Microsoft Corporation.
2
- // Licensed under the MIT license.
3
- import { makeAnalyzeSentimentResultArray } from "./analyzeSentimentResultArray";
4
- import { makeMultiCategoryClassifyResultArray } from "./multiCategoryClassifyResultArray";
5
- import { makeSingleCategoryClassifyResultArray } from "./singleCategoryClassifyResultArray";
6
- import { makeExtractKeyPhrasesResultArray } from "./extractKeyPhrasesResultArray";
7
- import { makeExtractSummaryResultArray } from "./extractSummaryResultArray";
8
- import { makeRecognizeCategorizedEntitiesResultArray } from "./recognizeCategorizedEntitiesResultArray";
9
- import { makeRecognizeCustomEntitiesResultArray } from "./recognizeCustomEntitiesResultArray";
10
- import { makeRecognizeLinkedEntitiesResultArray } from "./recognizeLinkedEntitiesResultArray";
11
- import { makeRecognizePiiEntitiesResultArray } from "./recognizePiiEntitiesResultArray";
12
- import { intoTextAnalyticsError } from "./textAnalyticsResult";
13
- /**
14
- * Converts the service task name (in the JSON pointer in an action error) to an action type name.
15
- * @param serviceActionType - The task type name the service uses.
16
- * @returns the action type name that the package uses
17
- * @internal
18
- */
19
- function convertTaskTypeToActionType(taskType) {
20
- switch (taskType) {
21
- case "entityRecognitionTasks": {
22
- return "RecognizeCategorizedEntities";
23
- }
24
- case "entityRecognitionPiiTasks": {
25
- return "RecognizePiiEntities";
26
- }
27
- case "keyPhraseExtractionTasks": {
28
- return "ExtractKeyPhrases";
29
- }
30
- case "entityLinkingTasks": {
31
- return "RecognizeLinkedEntities";
32
- }
33
- case "sentimentAnalysisTasks": {
34
- return "AnalyzeSentiment";
35
- }
36
- case "extractiveSummarizationTasks": {
37
- return "ExtractSummary";
38
- }
39
- case "customEntityRecognitionTasks": {
40
- return "RecognizeCustomEntities";
41
- }
42
- case "customSingleClassificationTasks": {
43
- return "SingleCategoryClassify";
44
- }
45
- case "customMultiClassificationTasks": {
46
- return "MultiCategoryClassify";
47
- }
48
- default: {
49
- throw new Error(`unexpected action type from the service: ${taskType}`);
50
- }
51
- }
52
- }
53
- /**
54
- * Converts a service action error to one with the JSON pointer converted to an action index.
55
- * @param erredActions - the action error the service sent
56
- * @returns an action error with an action type and index
57
- * @internal
58
- */
59
- export function parseActionError(erredActions) {
60
- if (erredActions.target) {
61
- const regex = new RegExp(/#\/tasks\/(entityRecognitionTasks|entityRecognitionPiiTasks|keyPhraseExtractionTasks|entityLinkingTasks|sentimentAnalysisTasks|extractiveSummarizationTasks|customEntityRecognitionTasks|customSingleClassificationTasks|customMultiClassificationTasks)\/(\d+)/);
62
- const result = regex.exec(erredActions.target);
63
- if (result !== null) {
64
- return {
65
- code: erredActions.code,
66
- message: erredActions.message,
67
- index: parseInt(result[2]),
68
- type: convertTaskTypeToActionType(result[1])
69
- };
70
- }
71
- else {
72
- throw new Error(`Pointer "${erredActions.target}" is not a valid action pointer`);
73
- }
74
- }
75
- else {
76
- throw new Error("expected an error with a target field referencing an action but did not get one");
77
- }
78
- }
79
- /**
80
- * Categorize each action error into a bucket according to its action type.
81
- * @param erredActions - list of action errors
82
- * @param recognizeEntitiesActionErrors - a list of recognize entities action errors to be filled from the errors list
83
- * @param recognizePiiEntitiesActionErrors - a list of recognize pii entities action errors to be filled from the errors list
84
- * @param extractKeyPhrasesActionErrors - a list of extract key phrases action errors to be filled from the errors list
85
- * @internal
86
- */
87
- function categorizeActionErrors(erredActions, recognizeEntitiesActionErrors, recognizePiiEntitiesActionErrors, extractKeyPhrasesActionErrors, recognizeLinkedEntitiesActionErrors, analyzeSentimentActionErrors, extractSummarySentencesActionErrors, recognizeCustomEntitiesActionErrors, singleCategoryClassifyActionErrors, multiCategoryClassifyActionErrors) {
88
- for (const error of erredActions) {
89
- const actionError = parseActionError(error);
90
- switch (actionError.type) {
91
- case "RecognizeCategorizedEntities": {
92
- recognizeEntitiesActionErrors.push(actionError);
93
- break;
94
- }
95
- case "RecognizePiiEntities": {
96
- recognizePiiEntitiesActionErrors.push(actionError);
97
- break;
98
- }
99
- case "ExtractKeyPhrases": {
100
- extractKeyPhrasesActionErrors.push(actionError);
101
- break;
102
- }
103
- case "RecognizeLinkedEntities": {
104
- recognizeLinkedEntitiesActionErrors.push(actionError);
105
- break;
106
- }
107
- case "AnalyzeSentiment": {
108
- analyzeSentimentActionErrors.push(actionError);
109
- break;
110
- }
111
- case "ExtractSummary": {
112
- extractSummarySentencesActionErrors.push(actionError);
113
- break;
114
- }
115
- case "RecognizeCustomEntities": {
116
- recognizeCustomEntitiesActionErrors.push(actionError);
117
- break;
118
- }
119
- case "SingleCategoryClassify": {
120
- singleCategoryClassifyActionErrors.push(actionError);
121
- break;
122
- }
123
- case "MultiCategoryClassify": {
124
- multiCategoryClassifyActionErrors.push(actionError);
125
- break;
126
- }
127
- }
128
- }
129
- }
130
- /**
131
- * @internal
132
- * @param error - the error the service sent for a task
133
- * @param lastUpdateDateTime - the time when this task failed
134
- */
135
- function createErredAction(error, lastUpdateDateTime, taskName) {
136
- return {
137
- error: intoTextAnalyticsError(error),
138
- failedOn: lastUpdateDateTime,
139
- actionName: taskName
140
- };
141
- }
142
- /**
143
- * Creates a list of results for any action.
144
- * @param documents - list of input documents
145
- * @param makeResultsArray - a function to convert the results of a service response to the SDK's one
146
- * @param succeededTasks - list of succeeded action results
147
- * @param erredActions - list of erred actions
148
- * @internal
149
- */
150
- function makeActionResult(documents, makeResultsArray, succeededTasks, erredActions) {
151
- let errorIndex = 0;
152
- function convertTasksToActions(actions, task) {
153
- const { results: actionResults, lastUpdateDateTime, taskName } = task;
154
- if (actionResults !== undefined) {
155
- const recognizeEntitiesResults = makeResultsArray(documents, actionResults);
156
- return [
157
- ...actions,
158
- {
159
- results: recognizeEntitiesResults,
160
- completedOn: lastUpdateDateTime,
161
- actionName: taskName
162
- }
163
- ];
164
- }
165
- else {
166
- return [
167
- ...actions,
168
- createErredAction(erredActions[errorIndex++], lastUpdateDateTime, taskName)
169
- ];
170
- }
171
- }
172
- return succeededTasks.reduce(convertTasksToActions, []);
173
- }
174
- /**
175
- * Creates the user-friendly action results object for the begin analyze actions operation.
176
- * @param response - the begin analyze actions operation response
177
- * @param documents - the list of input documents
178
- * @returns - the user-friendly action results object
179
- * @internal
180
- */
181
- export function createAnalyzeActionsResult(response, documents) {
182
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
183
- const recognizeEntitiesActionErrors = [];
184
- const recognizePiiEntitiesActionErrors = [];
185
- const extractKeyPhrasesActionErrors = [];
186
- const recognizeLinkedEntitiesActionErrors = [];
187
- const analyzeSentimentActionErrors = [];
188
- const extractSummarySentencesActionErrors = [];
189
- const recognizeCustomEntitiesActionErrors = [];
190
- const singleCategoryClassifyActionErrors = [];
191
- const multiCategoryClassifyActionErrors = [];
192
- categorizeActionErrors((_a = response === null || response === void 0 ? void 0 : response.errors) !== null && _a !== void 0 ? _a : [], recognizeEntitiesActionErrors, recognizePiiEntitiesActionErrors, extractKeyPhrasesActionErrors, recognizeLinkedEntitiesActionErrors, analyzeSentimentActionErrors, extractSummarySentencesActionErrors, recognizeCustomEntitiesActionErrors, singleCategoryClassifyActionErrors, multiCategoryClassifyActionErrors);
193
- return {
194
- recognizeEntitiesResults: makeActionResult(documents, makeRecognizeCategorizedEntitiesResultArray, (_b = response.tasks.entityRecognitionTasks) !== null && _b !== void 0 ? _b : [], recognizeEntitiesActionErrors),
195
- recognizePiiEntitiesResults: makeActionResult(documents, makeRecognizePiiEntitiesResultArray, (_c = response.tasks.entityRecognitionPiiTasks) !== null && _c !== void 0 ? _c : [], recognizePiiEntitiesActionErrors),
196
- extractKeyPhrasesResults: makeActionResult(documents, makeExtractKeyPhrasesResultArray, (_d = response.tasks.keyPhraseExtractionTasks) !== null && _d !== void 0 ? _d : [], extractKeyPhrasesActionErrors),
197
- recognizeLinkedEntitiesResults: makeActionResult(documents, makeRecognizeLinkedEntitiesResultArray, (_e = response.tasks.entityLinkingTasks) !== null && _e !== void 0 ? _e : [], recognizeLinkedEntitiesActionErrors),
198
- analyzeSentimentResults: makeActionResult(documents, makeAnalyzeSentimentResultArray, (_f = response.tasks.sentimentAnalysisTasks) !== null && _f !== void 0 ? _f : [], analyzeSentimentActionErrors),
199
- extractSummaryResults: makeActionResult(documents, makeExtractSummaryResultArray, (_g = response.tasks.extractiveSummarizationTasks) !== null && _g !== void 0 ? _g : [], extractSummarySentencesActionErrors),
200
- recognizeCustomEntitiesResults: makeActionResult(documents, makeRecognizeCustomEntitiesResultArray, (_h = response.tasks.customEntityRecognitionTasks) !== null && _h !== void 0 ? _h : [], recognizeCustomEntitiesActionErrors),
201
- singleCategoryClassifyResults: makeActionResult(documents, makeSingleCategoryClassifyResultArray, (_j = response.tasks.customSingleClassificationTasks) !== null && _j !== void 0 ? _j : [], singleCategoryClassifyActionErrors),
202
- multiCategoryClassifyResults: makeActionResult(documents, makeMultiCategoryClassifyResultArray, (_k = response.tasks.customMultiClassificationTasks) !== null && _k !== void 0 ? _k : [], multiCategoryClassifyActionErrors)
203
- };
204
- }
205
- //# sourceMappingURL=analyzeActionsResult.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"analyzeActionsResult.js","sourceRoot":"","sources":["../../src/analyzeActionsResult.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAEL,+BAA+B,EAChC,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAEL,oCAAoC,EACrC,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAEL,qCAAqC,EACtC,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAEL,gCAAgC,EACjC,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAEL,6BAA6B,EAC9B,MAAM,6BAA6B,CAAC;AAErC,OAAO,EACL,2CAA2C,EAE5C,MAAM,2CAA2C,CAAC;AACnD,OAAO,EACL,sCAAsC,EAEvC,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EACL,sCAAsC,EAEvC,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EACL,mCAAmC,EAEpC,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAa,sBAAsB,EAAsB,MAAM,uBAAuB,CAAC;AAwV9F;;;;;GAKG;AACH,SAAS,2BAA2B,CAAC,QAAgB;IACnD,QAAQ,QAAQ,EAAE;QAChB,KAAK,wBAAwB,CAAC,CAAC;YAC7B,OAAO,8BAA8B,CAAC;SACvC;QACD,KAAK,2BAA2B,CAAC,CAAC;YAChC,OAAO,sBAAsB,CAAC;SAC/B;QACD,KAAK,0BAA0B,CAAC,CAAC;YAC/B,OAAO,mBAAmB,CAAC;SAC5B;QACD,KAAK,oBAAoB,CAAC,CAAC;YACzB,OAAO,yBAAyB,C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,mCAAmC,CACpC;QACD,6BAA6B,EAAE,gBAAgB,CAC7C,SAAS,EACT,qCAAqC,EACrC,MAAA,QAAQ,CAAC,KAAK,CAAC,+BAA+B,mCAAI,EAAE,EACpD,kCAAkC,CACnC;QACD,4BAA4B,EAAE,gBAAgB,CAC5C,SAAS,EACT,oCAAoC,EACpC,MAAA,QAAQ,CAAC,KAAK,CAAC,8BAA8B,mCAAI,EAAE,EACnD,iCAAiC,CAClC;KACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { PagedAsyncIterableIterator } from \"@azure/core-paging\";\nimport {\n AnalyzeSentimentResultArray,\n makeAnalyzeSentimentResultArray\n} from \"./analyzeSentimentResultArray\";\nimport {\n MultiCategoryClassifyResultArray,\n makeMultiCategoryClassifyResultArray\n} from \"./multiCategoryClassifyResultArray\";\nimport {\n SingleCategoryClassifyResultArray,\n makeSingleCategoryClassifyResultArray\n} from \"./singleCategoryClassifyResultArray\";\nimport {\n ExtractKeyPhrasesResultArray,\n makeExtractKeyPhrasesResultArray\n} from \"./extractKeyPhrasesResultArray\";\nimport {\n ExtractSummaryResultArray,\n makeExtractSummaryResultArray\n} from \"./extractSummaryResultArray\";\nimport { AnalyzeJobState as GeneratedResponse, TextDocumentInput } from \"./generated/models\";\nimport {\n makeRecognizeCategorizedEntitiesResultArray,\n RecognizeCategorizedEntitiesResultArray\n} from \"./recognizeCategorizedEntitiesResultArray\";\nimport {\n makeRecognizeCustomEntitiesResultArray,\n RecognizeCustomEntitiesResultArray\n} from \"./recognizeCustomEntitiesResultArray\";\nimport {\n makeRecognizeLinkedEntitiesResultArray,\n RecognizeLinkedEntitiesResultArray\n} from \"./recognizeLinkedEntitiesResultArray\";\nimport {\n makeRecognizePiiEntitiesResultArray,\n RecognizePiiEntitiesResultArray\n} from \"./recognizePiiEntitiesResultArray\";\nimport { ErrorCode, intoTextAnalyticsError, TextAnalyticsError } from \"./textAnalyticsResult\";\n\n/**\n * The results of an analyze Actions operation.\n */\nexport interface AnalyzeActionsResult {\n /**\n * Array of the results for each categorized entities recognition action.\n */\n recognizeEntitiesResults: RecognizeCategorizedEntitiesActionResult[];\n /**\n * Array of the results for each Pii entities recognition action.\n */\n recognizePiiEntitiesResults: RecognizePiiEntitiesActionResult[];\n /**\n * Array of the results for each key phrases extraction action.\n */\n extractKeyPhrasesResults: ExtractKeyPhrasesActionResult[];\n /**\n * Array of the results for each linked entities recognition action.\n */\n recognizeLinkedEntitiesResults: RecognizeLinkedEntitiesActionResult[];\n /**\n * Array of the results for each analyze sentiment action.\n */\n analyzeSentimentResults: AnalyzeSentimentActionResult[];\n /**\n * Array of the results for each extract summary action.\n */\n extractSummaryResults: ExtractSummaryActionResult[];\n /**\n * Array of the results for each recognize custom entities action.\n */\n recognizeCustomEntitiesResults: RecognizeCustomEntitiesActionResult[];\n /**\n * Array of the results for each custom classify document single category action.\n */\n singleCategoryClassifyResults: SingleCategoryClassifyActionResult[];\n /**\n * Array of the results for each custom classify document multi category action.\n */\n multiCategoryClassifyResults: MultiCategoryClassifyActionResult[];\n}\n\n/**\n * The state of an action\n */\nexport interface TextAnalyticsActionState {\n /**\n * The name of the action.\n */\n actionName?: string;\n}\n\n/**\n * The state of a succeeded action.\n */\nexport interface TextAnalyticsActionSuccessState extends TextAnalyticsActionState {\n /**\n * When this action was completed by the service.\n */\n readonly completedOn: Date;\n /**\n * Discriminant to determine if that this is an error result.\n */\n readonly error?: undefined;\n}\n\n/**\n * The error of an analyze batch action.\n */\nexport interface TextAnalyticsActionErrorResult extends TextAnalyticsActionState {\n /**\n * When this action was completed by the service.\n */\n readonly failedOn: Date;\n /**\n * The Error for this action result.\n */\n readonly error: TextAnalyticsError;\n}\n\n/**\n * The error of a recognize categorized entities action.\n */\nexport type RecognizeCategorizedEntitiesActionErrorResult = TextAnalyticsActionErrorResult;\n\n/**\n * The results of a succeeded recognize categorized entities action.\n */\nexport interface RecognizeCategorizedEntitiesActionSuccessResult\n extends TextAnalyticsActionSuccessState {\n /**\n * Array of the results for each categorized entities recognition action.\n */\n results: RecognizeCategorizedEntitiesResultArray;\n}\n\n/**\n * The result of a recognize categorized entities action.\n */\nexport type RecognizeCategorizedEntitiesActionResult =\n | RecognizeCategorizedEntitiesActionSuccessResult\n | RecognizeCategorizedEntitiesActionErrorResult;\n\n/**\n * The error of a recognize pii entities action.\n */\nexport type RecognizePiiEntitiesActionErrorResult = TextAnalyticsActionErrorResult;\n\n/**\n * The results of a succeeded recognize pii entities action.\n */\nexport interface RecognizePiiEntitiesActionSuccessResult extends TextAnalyticsActionSuccessState {\n /**\n * Array of the results for each pii entities recognition action.\n */\n results: RecognizePiiEntitiesResultArray;\n}\n\n/**\n * The result of a recognize pii entities action.\n */\nexport type RecognizePiiEntitiesActionResult =\n | RecognizePiiEntitiesActionSuccessResult\n | RecognizePiiEntitiesActionErrorResult;\n\n/**\n * The error of a extract key phrases action.\n */\nexport type ExtractKeyPhrasesActionErrorResult = TextAnalyticsActionErrorResult;\n\n/**\n * The results of a succeeded extract key phrases action.\n */\nexport interface ExtractKeyPhrasesActionSuccessResult extends TextAnalyticsActionSuccessState {\n /**\n * Array of the results for each extract key phrases action.\n */\n results: ExtractKeyPhrasesResultArray;\n}\n\n/**\n * The result of a extract key phrases action.\n */\nexport type ExtractKeyPhrasesActionResult =\n | ExtractKeyPhrasesActionSuccessResult\n | ExtractKeyPhrasesActionErrorResult;\n\n/**\n * The error of a recognize linked entities action.\n */\nexport type RecognizeLinkedEntitiesActionErrorResult = TextAnalyticsActionErrorResult;\n\n/**\n * The results of a succeeded recognize linked entities action.\n */\nexport interface RecognizeLinkedEntitiesActionSuccessResult\n extends TextAnalyticsActionSuccessState {\n /**\n * Array of the results for each linked entities recognition action.\n */\n results: RecognizeLinkedEntitiesResultArray;\n}\n\n/**\n * The result of a recognize linked entities action.\n */\nexport type RecognizeLinkedEntitiesActionResult =\n | RecognizeLinkedEntitiesActionSuccessResult\n | RecognizeLinkedEntitiesActionErrorResult;\n\n/**\n * The error of an analyze sentiment action.\n */\nexport type AnalyzeSentimentActionErrorResult = TextAnalyticsActionErrorResult;\n\n/**\n * The results of a succeeded analyze sentiment action.\n */\nexport interface AnalyzeSentimentActionSuccessResult extends TextAnalyticsActionSuccessState {\n /**\n * Array of the results for each analyze sentiment action.\n */\n results: AnalyzeSentimentResultArray;\n}\n\n/**\n * The result of an analyze sentiment action.\n */\nexport type AnalyzeSentimentActionResult =\n | AnalyzeSentimentActionSuccessResult\n | AnalyzeSentimentActionErrorResult;\n\n/**\n * The error of an extract summary action.\n */\nexport type ExtractSummaryActionErrorResult = TextAnalyticsActionErrorResult;\n\n/**\n * The results of a succeeded extract summary action.\n */\nexport interface ExtractSummaryActionSuccessResult extends TextAnalyticsActionSuccessState {\n /**\n * Array of the results for each extract summary action.\n */\n results: ExtractSummaryResultArray;\n}\n\n/**\n * The result of an extract summary action.\n */\nexport type ExtractSummaryActionResult =\n | ExtractSummaryActionSuccessResult\n | ExtractSummaryActionErrorResult;\n\n/**\n * The error of a custom recognize entities action.\n */\nexport type RecongizeCustomEntitiesActionErrorResult = TextAnalyticsActionErrorResult;\n\n/**\n * The results of a succeeded custom recognize entities action.\n */\nexport interface RecongizeCustomEntitiesActionSuccessResult\n extends TextAnalyticsActionSuccessState {\n /**\n * Array of the results for each custom recognize entities action.\n */\n results: RecognizeCustomEntitiesResultArray;\n}\n\n/**\n * The result of a custom recognize entities action.\n */\nexport type RecognizeCustomEntitiesActionResult =\n | RecongizeCustomEntitiesActionSuccessResult\n | RecongizeCustomEntitiesActionErrorResult;\n\n/**\n * The error of a custom classify document single category action.\n */\nexport type SingleCategoryClassifyActionErrorResult = TextAnalyticsActionErrorResult;\n\n/**\n * The results of a succeeded custom classify document single category action.\n */\nexport interface SingleCategoryClassifyActionSuccessResult extends TextAnalyticsActionSuccessState {\n /**\n * Array of the results for each custom classify document single category action.\n */\n results: SingleCategoryClassifyResultArray;\n}\n\n/**\n * The result of a custom classify document single category action.\n */\nexport type SingleCategoryClassifyActionResult =\n | SingleCategoryClassifyActionSuccessResult\n | SingleCategoryClassifyActionErrorResult;\n\n/**\n * The error of a custom classify document multi category action.\n */\nexport type MultiCategoryClassifyActionErrorResult = TextAnalyticsActionErrorResult;\n\n/**\n * The results of a succeeded custom classify document multi category action.\n */\nexport interface MultiCategoryClassifyActionSuccessResult extends TextAnalyticsActionSuccessState {\n /**\n * Array of the results for each custom classify document multi category action.\n */\n results: MultiCategoryClassifyResultArray;\n}\n\n/**\n * The result of a custom classify document multi category action.\n */\nexport type MultiCategoryClassifyActionResult =\n | MultiCategoryClassifyActionSuccessResult\n | MultiCategoryClassifyActionErrorResult;\n\n/**\n * The results of an analyze Actions operation represented as a paged iterator that\n * iterates over the results of the requested actions.\n */\nexport type PagedAsyncIterableAnalyzeActionsResult = PagedAsyncIterableIterator<\n AnalyzeActionsResult,\n AnalyzeActionsResult\n>;\n\n/**\n * The results of an analyze actions operation represented as a paged iterator that\n * iterates over the results of the requested actions.\n */\nexport interface PagedAnalyzeActionsResult extends PagedAsyncIterableAnalyzeActionsResult {\n // /**\n // * Statistics about the input document batch and how it was processed\n // * by the service. This property will have a value when includeStatistics is set to true\n // * in the client call.\n // */\n // statistics?: TextDocumentBatchStatistics;\n}\n\n/**\n * The type of different actions supported by the begin analyze actions operation.\n * @internal\n */\ntype TextAnalyticsActionType =\n | \"RecognizeCategorizedEntities\"\n | \"RecognizePiiEntities\"\n | \"ExtractKeyPhrases\"\n | \"RecognizeLinkedEntities\"\n | \"AnalyzeSentiment\"\n | \"ExtractSummary\"\n | \"RecognizeCustomEntities\"\n | \"SingleCategoryClassify\"\n | \"MultiCategoryClassify\";\n\n/**\n * The type of an action error with the type of the action that erred and its\n * index in the list of input actions.\n * @internal\n */\ninterface TextAnalyticsActionError {\n /**\n * A code describing the kind of error produced\n */\n readonly code: ErrorCode;\n /**\n * A message from the service explaining the error\n */\n readonly message: string;\n /**\n * The type of the action that erred\n */\n readonly type: TextAnalyticsActionType;\n /**\n * The index of the action that erred in the list of input actions\n */\n readonly index: number;\n}\n\n/**\n * Converts the service task name (in the JSON pointer in an action error) to an action type name.\n * @param serviceActionType - The task type name the service uses.\n * @returns the action type name that the package uses\n * @internal\n */\nfunction convertTaskTypeToActionType(taskType: string): TextAnalyticsActionType {\n switch (taskType) {\n case \"entityRecognitionTasks\": {\n return \"RecognizeCategorizedEntities\";\n }\n case \"entityRecognitionPiiTasks\": {\n return \"RecognizePiiEntities\";\n }\n case \"keyPhraseExtractionTasks\": {\n return \"ExtractKeyPhrases\";\n }\n case \"entityLinkingTasks\": {\n return \"RecognizeLinkedEntities\";\n }\n case \"sentimentAnalysisTasks\": {\n return \"AnalyzeSentiment\";\n }\n case \"extractiveSummarizationTasks\": {\n return \"ExtractSummary\";\n }\n case \"customEntityRecognitionTasks\": {\n return \"RecognizeCustomEntities\";\n }\n case \"customSingleClassificationTasks\": {\n return \"SingleCategoryClassify\";\n }\n case \"customMultiClassificationTasks\": {\n return \"MultiCategoryClassify\";\n }\n default: {\n throw new Error(`unexpected action type from the service: ${taskType}`);\n }\n }\n}\n\n/**\n * Converts a service action error to one with the JSON pointer converted to an action index.\n * @param erredActions - the action error the service sent\n * @returns an action error with an action type and index\n * @internal\n */\nexport function parseActionError(erredActions: TextAnalyticsError): TextAnalyticsActionError {\n if (erredActions.target) {\n const regex = new RegExp(\n /#\\/tasks\\/(entityRecognitionTasks|entityRecognitionPiiTasks|keyPhraseExtractionTasks|entityLinkingTasks|sentimentAnalysisTasks|extractiveSummarizationTasks|customEntityRecognitionTasks|customSingleClassificationTasks|customMultiClassificationTasks)\\/(\\d+)/\n );\n const result = regex.exec(erredActions.target);\n if (result !== null) {\n return {\n code: erredActions.code,\n message: erredActions.message,\n index: parseInt(result[2]),\n type: convertTaskTypeToActionType(result[1])\n };\n } else {\n throw new Error(`Pointer \"${erredActions.target}\" is not a valid action pointer`);\n }\n } else {\n throw new Error(\n \"expected an error with a target field referencing an action but did not get one\"\n );\n }\n}\n\n/**\n * Categorize each action error into a bucket according to its action type.\n * @param erredActions - list of action errors\n * @param recognizeEntitiesActionErrors - a list of recognize entities action errors to be filled from the errors list\n * @param recognizePiiEntitiesActionErrors - a list of recognize pii entities action errors to be filled from the errors list\n * @param extractKeyPhrasesActionErrors - a list of extract key phrases action errors to be filled from the errors list\n * @internal\n */\nfunction categorizeActionErrors(\n erredActions: TextAnalyticsError[],\n recognizeEntitiesActionErrors: TextAnalyticsActionError[],\n recognizePiiEntitiesActionErrors: TextAnalyticsActionError[],\n extractKeyPhrasesActionErrors: TextAnalyticsActionError[],\n recognizeLinkedEntitiesActionErrors: TextAnalyticsActionError[],\n analyzeSentimentActionErrors: TextAnalyticsActionError[],\n extractSummarySentencesActionErrors: TextAnalyticsActionError[],\n recognizeCustomEntitiesActionErrors: TextAnalyticsActionError[],\n singleCategoryClassifyActionErrors: TextAnalyticsActionError[],\n multiCategoryClassifyActionErrors: TextAnalyticsActionError[]\n): void {\n for (const error of erredActions) {\n const actionError = parseActionError(error);\n switch (actionError.type) {\n case \"RecognizeCategorizedEntities\": {\n recognizeEntitiesActionErrors.push(actionError);\n break;\n }\n case \"RecognizePiiEntities\": {\n recognizePiiEntitiesActionErrors.push(actionError);\n break;\n }\n case \"ExtractKeyPhrases\": {\n extractKeyPhrasesActionErrors.push(actionError);\n break;\n }\n case \"RecognizeLinkedEntities\": {\n recognizeLinkedEntitiesActionErrors.push(actionError);\n break;\n }\n case \"AnalyzeSentiment\": {\n analyzeSentimentActionErrors.push(actionError);\n break;\n }\n case \"ExtractSummary\": {\n extractSummarySentencesActionErrors.push(actionError);\n break;\n }\n case \"RecognizeCustomEntities\": {\n recognizeCustomEntitiesActionErrors.push(actionError);\n break;\n }\n case \"SingleCategoryClassify\": {\n singleCategoryClassifyActionErrors.push(actionError);\n break;\n }\n case \"MultiCategoryClassify\": {\n multiCategoryClassifyActionErrors.push(actionError);\n break;\n }\n }\n }\n}\n\n/**\n * @internal\n * @param error - the error the service sent for a task\n * @param lastUpdateDateTime - the time when this task failed\n */\nfunction createErredAction(\n error: TextAnalyticsActionError,\n lastUpdateDateTime: Date,\n taskName?: string\n): TextAnalyticsActionErrorResult {\n return {\n error: intoTextAnalyticsError(error),\n failedOn: lastUpdateDateTime,\n actionName: taskName\n };\n}\n\ninterface TaskSuccessResult<T> {\n results?: T;\n taskName?: string;\n lastUpdateDateTime: Date;\n}\n\ntype ActionResult<TSuccess> =\n | {\n results: TSuccess;\n completedOn: Date;\n }\n | TextAnalyticsActionErrorResult;\n\n/**\n * Creates a list of results for any action.\n * @param documents - list of input documents\n * @param makeResultsArray - a function to convert the results of a service response to the SDK's one\n * @param succeededTasks - list of succeeded action results\n * @param erredActions - list of erred actions\n * @internal\n */\nfunction makeActionResult<TTaskResult, TActionResult>(\n documents: TextDocumentInput[],\n makeResultsArray: (docs: TextDocumentInput[], x: TTaskResult) => TActionResult,\n succeededTasks: TaskSuccessResult<TTaskResult>[],\n erredActions: TextAnalyticsActionError[]\n): ActionResult<TActionResult>[] {\n let errorIndex = 0;\n function convertTasksToActions(\n actions: ActionResult<TActionResult>[],\n task: TaskSuccessResult<TTaskResult>\n ): ActionResult<TActionResult>[] {\n const { results: actionResults, lastUpdateDateTime, taskName } = task;\n if (actionResults !== undefined) {\n const recognizeEntitiesResults = makeResultsArray(documents, actionResults);\n return [\n ...actions,\n {\n results: recognizeEntitiesResults,\n completedOn: lastUpdateDateTime,\n actionName: taskName\n }\n ];\n } else {\n return [\n ...actions,\n createErredAction(erredActions[errorIndex++], lastUpdateDateTime, taskName)\n ];\n }\n }\n return succeededTasks.reduce(convertTasksToActions, []);\n}\n\n/**\n * Creates the user-friendly action results object for the begin analyze actions operation.\n * @param response - the begin analyze actions operation response\n * @param documents - the list of input documents\n * @returns - the user-friendly action results object\n * @internal\n */\nexport function createAnalyzeActionsResult(\n response: GeneratedResponse,\n documents: TextDocumentInput[]\n): AnalyzeActionsResult {\n const recognizeEntitiesActionErrors: TextAnalyticsActionError[] = [];\n const recognizePiiEntitiesActionErrors: TextAnalyticsActionError[] = [];\n const extractKeyPhrasesActionErrors: TextAnalyticsActionError[] = [];\n const recognizeLinkedEntitiesActionErrors: TextAnalyticsActionError[] = [];\n const analyzeSentimentActionErrors: TextAnalyticsActionError[] = [];\n const extractSummarySentencesActionErrors: TextAnalyticsActionError[] = [];\n const recognizeCustomEntitiesActionErrors: TextAnalyticsActionError[] = [];\n const singleCategoryClassifyActionErrors: TextAnalyticsActionError[] = [];\n const multiCategoryClassifyActionErrors: TextAnalyticsActionError[] = [];\n categorizeActionErrors(\n response?.errors ?? [],\n recognizeEntitiesActionErrors,\n recognizePiiEntitiesActionErrors,\n extractKeyPhrasesActionErrors,\n recognizeLinkedEntitiesActionErrors,\n analyzeSentimentActionErrors,\n extractSummarySentencesActionErrors,\n recognizeCustomEntitiesActionErrors,\n singleCategoryClassifyActionErrors,\n multiCategoryClassifyActionErrors\n );\n return {\n recognizeEntitiesResults: makeActionResult(\n documents,\n makeRecognizeCategorizedEntitiesResultArray,\n response.tasks.entityRecognitionTasks ?? [],\n recognizeEntitiesActionErrors\n ),\n recognizePiiEntitiesResults: makeActionResult(\n documents,\n makeRecognizePiiEntitiesResultArray,\n response.tasks.entityRecognitionPiiTasks ?? [],\n recognizePiiEntitiesActionErrors\n ),\n extractKeyPhrasesResults: makeActionResult(\n documents,\n makeExtractKeyPhrasesResultArray,\n response.tasks.keyPhraseExtractionTasks ?? [],\n extractKeyPhrasesActionErrors\n ),\n recognizeLinkedEntitiesResults: makeActionResult(\n documents,\n makeRecognizeLinkedEntitiesResultArray,\n response.tasks.entityLinkingTasks ?? [],\n recognizeLinkedEntitiesActionErrors\n ),\n analyzeSentimentResults: makeActionResult(\n documents,\n makeAnalyzeSentimentResultArray,\n response.tasks.sentimentAnalysisTasks ?? [],\n analyzeSentimentActionErrors\n ),\n extractSummaryResults: makeActionResult(\n documents,\n makeExtractSummaryResultArray,\n response.tasks.extractiveSummarizationTasks ?? [],\n extractSummarySentencesActionErrors\n ),\n recognizeCustomEntitiesResults: makeActionResult(\n documents,\n makeRecognizeCustomEntitiesResultArray,\n response.tasks.customEntityRecognitionTasks ?? [],\n recognizeCustomEntitiesActionErrors\n ),\n singleCategoryClassifyResults: makeActionResult(\n documents,\n makeSingleCategoryClassifyResultArray,\n response.tasks.customSingleClassificationTasks ?? [],\n singleCategoryClassifyActionErrors\n ),\n multiCategoryClassifyResults: makeActionResult(\n documents,\n makeMultiCategoryClassifyResultArray,\n response.tasks.customMultiClassificationTasks ?? [],\n multiCategoryClassifyActionErrors\n )\n };\n}\n"]}
@@ -1,53 +0,0 @@
1
- // Copyright (c) Microsoft Corporation.
2
- // Licensed under the MIT license.
3
- import { makeTextAnalyticsErrorResult, makeTextAnalyticsSuccessResult } from "./textAnalyticsResult";
4
- import { parseHealthcareEntityIndex } from "./util";
5
- /**
6
- * Creates a user-friendly healthcare entity represented as a node in a graph
7
- * @param entity - the healthcare entity returned by the service
8
- * @internal
9
- */
10
- function makeHealthcareEntitiesWithoutNeighbors(entity) {
11
- var _a;
12
- const { category, confidenceScore, assertion, offset, text, links, subcategory, length, name } = entity;
13
- return {
14
- category,
15
- confidenceScore,
16
- assertion,
17
- offset,
18
- length,
19
- text,
20
- normalizedText: name,
21
- subCategory: subcategory,
22
- dataSources: (_a = links === null || links === void 0 ? void 0 : links.map(({ dataSource, id }) => ({ name: dataSource, entityId: id }))) !== null && _a !== void 0 ? _a : []
23
- };
24
- }
25
- /**
26
- * @internal
27
- */
28
- function makeHealthcareRelations(entities, relations) {
29
- return relations.map((relation) => ({
30
- relationType: relation.relationType,
31
- roles: relation.entities.map((role) => ({
32
- entity: entities[parseHealthcareEntityIndex(role.ref)],
33
- name: role.role
34
- }))
35
- }));
36
- }
37
- /**
38
- * Creates a healthcare entity in the convenience layer from the one sent by the service.
39
- * @param document - incoming results sent by the service for a particular document
40
- * @internal
41
- */
42
- export function makeHealthcareEntitiesResult(document) {
43
- const { id, entities, relations, warnings, statistics } = document;
44
- const newEntities = entities.map(makeHealthcareEntitiesWithoutNeighbors);
45
- return Object.assign(Object.assign({}, makeTextAnalyticsSuccessResult(id, warnings, statistics)), { entities: newEntities, entityRelations: makeHealthcareRelations(newEntities, relations) });
46
- }
47
- /**
48
- * @internal
49
- */
50
- export function makeHealthcareEntitiesErrorResult(id, error) {
51
- return makeTextAnalyticsErrorResult(id, error);
52
- }
53
- //# sourceMappingURL=analyzeHealthcareEntitiesResult.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"analyzeHealthcareEntitiesResult.js","sourceRoot":"","sources":["../../src/analyzeHealthcareEntitiesResult.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAelC,OAAO,EACL,4BAA4B,EAC5B,8BAA8B,EAG/B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,0BAA0B,EAAE,MAAM,QAAQ,CAAC;AAoKpD;;;;GAIG;AACH,SAAS,sCAAsC,CAC7C,MAAiC;;IAEjC,MAAM,EACJ,QAAQ,EACR,eAAe,EACf,SAAS,EACT,MAAM,EACN,IAAI,EACJ,KAAK,EACL,WAAW,EACX,MAAM,EACN,IAAI,EACL,GAAG,MAAM,CAAC;IACX,OAAO;QACL,QAAQ;QACR,eAAe;QACf,SAAS;QACT,MAAM;QACN,MAAM;QACN,IAAI;QACJ,cAAc,EAAE,IAAI;QACpB,WAAW,EAAE,WAAW;QACxB,WAAW,EACT,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,GAAG,CAAC,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,EAAoB,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAC,mCAC1F,EAAE;KACL,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,SAAS,uBAAuB,CAC9B,QAA4B,EAC5B,SAA+B;IAE/B,OAAO,SAAS,CAAC,GAAG,CAClB,CAAC,QAA4B,EAA4B,EAAE,CAAC,CAAC;QAC3D,YAAY,EAAE,QAAQ,CAAC,YAAY;QACnC,KAAK,EAAE,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAC1B,CAAC,IAA8B,EAAgC,EAAE,CAAC,CAAC;YACjE,MAAM,EAAE,QAAQ,CAAC,0BAA0B,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YACtD,IAAI,EAAE,IAAI,CAAC,IAAI;SAChB,CAAC,CACH;KACF,CAAC,CACH,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,4BAA4B,CAC1C,QAAoC;IAEpC,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAE,GAAG,QAAQ,CAAC;IACnE,MAAM,WAAW,GAAG,QAAQ,CAAC,GAAG,CAAC,sCAAsC,CAAC,CAAC;IACzE,uCACK,8BAA8B,CAAC,EAAE,EAAE,QAAQ,EAAE,UAAU,CAAC,KAC3D,QAAQ,EAAE,WAAW,EACrB,eAAe,EAAE,uBAAuB,CAAC,WAAW,EAAE,SAAS,CAAC,IAChE;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iCAAiC,CAC/C,EAAU,EACV,KAAyB;IAEzB,OAAO,4BAA4B,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;AACjD,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { PagedAsyncIterableIterator } from \"@azure/core-paging\";\nimport {\n DocumentHealthcareEntities,\n Entity,\n HealthcareRelation,\n TextDocumentBatchStatistics,\n HealthcareEntity as GeneratedHealthcareEntity,\n TextAnalyticsError,\n HealthcareAssertion,\n RelationType,\n HealthcareRelationEntity,\n HealthcareEntityCategory\n} from \"./generated/models\";\nimport {\n makeTextAnalyticsErrorResult,\n makeTextAnalyticsSuccessResult,\n TextAnalyticsErrorResult,\n TextAnalyticsSuccessResult\n} from \"./textAnalyticsResult\";\nimport { parseHealthcareEntityIndex } from \"./util\";\n\n/**\n * A type representing a reference for the healthcare entity into a specific\n * entity catalog.\n */\nexport interface EntityDataSource {\n /**\n * Entity Catalog. Examples include: UMLS, CHV, MSH, etc.\n */\n name: string;\n /**\n * Entity id in the given source catalog.\n */\n entityId: string;\n}\n\n/**\n * A healthcare entity represented as a node in a directed graph where the edges are\n * a particular type of relationship between the source and target nodes.\n */\nexport interface HealthcareEntity extends Entity {\n /**\n * Normalized name for the entity. For example, the normalized text for \"histologically\" is \"histologic\".\n */\n normalizedText?: string;\n /**\n * Whether the entity is negated.\n */\n assertion?: HealthcareAssertion;\n /**\n * Entity references in known data sources.\n */\n dataSources: EntityDataSource[];\n /**\n * Defines values for HealthcareEntityCategory.\n * {@link KnownHealthcareEntityCategory} can be used interchangeably with HealthcareEntityCategory,\n * this enum contains the known values that the service supports.\n * ### Known values supported by the service\n * **BODY_STRUCTURE**\n * **AGE**\n * **GENDER**\n * **EXAMINATION_NAME**\n * **DATE**\n * **DIRECTION**\n * **FREQUENCY**\n * **MEASUREMENT_VALUE**\n * **MEASUREMENT_UNIT**\n * **RELATIONAL_OPERATOR**\n * **TIME**\n * **GENE_OR_PROTEIN**\n * **VARIANT**\n * **ADMINISTRATIVE_EVENT**\n * **CARE_ENVIRONMENT**\n * **HEALTHCARE_PROFESSION**\n * **DIAGNOSIS**\n * **SYMPTOM_OR_SIGN**\n * **CONDITION_QUALIFIER**\n * **MEDICATION_CLASS**\n * **MEDICATION_NAME**\n * **DOSAGE**\n * **MEDICATION_FORM**\n * **MEDICATION_ROUTE**\n * **FAMILY_RELATION**\n * **TREATMENT_NAME**\n */\n category: HealthcareEntityCategory;\n}\n\n/**\n * The type of different roles a healthcare entity can play in a relation.\n */\nexport type HealthcareEntityRelationRoleType = string;\n\n/**\n * A healthcare entity that plays a specific role in a relation.\n */\nexport interface HealthcareEntityRelationRole {\n /**\n * A healthcare entity\n */\n entity: HealthcareEntity;\n /**\n * The role of the healthcare entity in a particular relation.\n */\n name: HealthcareEntityRelationRoleType;\n}\n\n/**\n * A relationship between two or more healthcare entities.\n */\nexport interface HealthcareEntityRelation {\n /**\n * The type of the healthcare relation.\n */\n relationType: RelationType;\n /**\n * The list of healthcare entities and their roles in the healthcare relation.\n */\n roles: HealthcareEntityRelationRole[];\n}\n\n/**\n * The results of a successful healthcare operation for a single document.\n */\nexport interface AnalyzeHealthcareEntitiesSuccessResult extends TextAnalyticsSuccessResult {\n /**\n * Healthcare entities.\n */\n entities: HealthcareEntity[];\n /**\n * Relations between healthcare entities.\n */\n entityRelations: HealthcareEntityRelation[];\n}\n\n/**\n * An error result from the healthcare operation on a single document.\n */\nexport type AnalyzeHealthcareEntitiesErrorResult = TextAnalyticsErrorResult;\n\n/**\n * The result of the healthcare operation on a single document.\n */\nexport type AnalyzeHealthcareEntitiesResult =\n | AnalyzeHealthcareEntitiesSuccessResult\n | AnalyzeHealthcareEntitiesErrorResult;\n\n/**\n * Array of {@link AnalyzeHealthcareEntitiesResult}\n */\nexport interface AnalyzeHealthcareEntitiesResultArray\n extends Array<AnalyzeHealthcareEntitiesResult> {}\n\n/**\n * The results of a healthcare operation represented as a paged iterator that can\n * either iterate over the results on a document-by-document basis or, by\n * byPage(), can iterate over pages of documents.\n */\nexport type PagedAsyncIterableAnalyzeHealthcareEntitiesResult = PagedAsyncIterableIterator<\n AnalyzeHealthcareEntitiesResult,\n AnalyzeHealthcareEntitiesResultArray\n>;\n\n/**\n * The results of a healthcare operation represented as a paged iterator that can\n * either iterate over the results on a document-by-document basis or, by\n * byPage(), can iterate over pages of documents.\n */\nexport interface PagedAnalyzeHealthcareEntitiesResult\n extends PagedAsyncIterableAnalyzeHealthcareEntitiesResult {\n /**\n * Statistics about the input document batch and how it was processed\n * by the service. This property will have a value when includeStatistics is set to true\n * in the client call.\n */\n statistics?: TextDocumentBatchStatistics;\n /**\n * The version of the text analytics model used by this operation on this\n * batch of input documents.\n */\n modelVersion: string;\n}\n\n/**\n * Creates a user-friendly healthcare entity represented as a node in a graph\n * @param entity - the healthcare entity returned by the service\n * @internal\n */\nfunction makeHealthcareEntitiesWithoutNeighbors(\n entity: GeneratedHealthcareEntity\n): HealthcareEntity {\n const {\n category,\n confidenceScore,\n assertion,\n offset,\n text,\n links,\n subcategory,\n length,\n name\n } = entity;\n return {\n category,\n confidenceScore,\n assertion,\n offset,\n length,\n text,\n normalizedText: name,\n subCategory: subcategory,\n dataSources:\n links?.map(({ dataSource, id }): EntityDataSource => ({ name: dataSource, entityId: id })) ??\n []\n };\n}\n\n/**\n * @internal\n */\nfunction makeHealthcareRelations(\n entities: HealthcareEntity[],\n relations: HealthcareRelation[]\n): HealthcareEntityRelation[] {\n return relations.map(\n (relation: HealthcareRelation): HealthcareEntityRelation => ({\n relationType: relation.relationType,\n roles: relation.entities.map(\n (role: HealthcareRelationEntity): HealthcareEntityRelationRole => ({\n entity: entities[parseHealthcareEntityIndex(role.ref)],\n name: role.role\n })\n )\n })\n );\n}\n\n/**\n * Creates a healthcare entity in the convenience layer from the one sent by the service.\n * @param document - incoming results sent by the service for a particular document\n * @internal\n */\nexport function makeHealthcareEntitiesResult(\n document: DocumentHealthcareEntities\n): AnalyzeHealthcareEntitiesSuccessResult {\n const { id, entities, relations, warnings, statistics } = document;\n const newEntities = entities.map(makeHealthcareEntitiesWithoutNeighbors);\n return {\n ...makeTextAnalyticsSuccessResult(id, warnings, statistics),\n entities: newEntities,\n entityRelations: makeHealthcareRelations(newEntities, relations)\n };\n}\n\n/**\n * @internal\n */\nexport function makeHealthcareEntitiesErrorResult(\n id: string,\n error: TextAnalyticsError\n): AnalyzeHealthcareEntitiesErrorResult {\n return makeTextAnalyticsErrorResult(id, error);\n}\n"]}
@@ -1,132 +0,0 @@
1
- // Copyright (c) Microsoft Corporation.
2
- // Licensed under the MIT license.
3
- import { SpanStatusCode } from "@azure/core-tracing";
4
- import { createSerializer } from "@azure/core-client";
5
- import { createSpan } from "./tracing";
6
- import { compileError, getRawResponse, sendGetRequest } from "./util";
7
- import * as Mappers from "./generated/models/mappers";
8
- import { accept, apiVersion, endpoint, includeStatistics, skip, top } from "./generated/models/parameters";
9
- import { getPagedAsyncIterator } from "@azure/core-paging";
10
- import { createAnalyzeActionsResult } from "./analyzeActionsResult";
11
- const serializer = createSerializer(Mappers, /* isXml */ false);
12
- // Consider whether the spec can be exported by code gen
13
- const analyzeStatusOperationSpec = {
14
- httpMethod: "GET",
15
- responses: {
16
- 200: {
17
- bodyMapper: Mappers.AnalyzeJobState
18
- },
19
- default: {
20
- bodyMapper: Mappers.ErrorResponse
21
- }
22
- },
23
- queryParameters: [includeStatistics, top, skip],
24
- urlParameters: [endpoint, apiVersion],
25
- headerParameters: [accept],
26
- serializer
27
- };
28
- /**
29
- * @internal
30
- */
31
- export class AnalyzeLro {
32
- constructor(
33
- // eslint-disable-next-line @azure/azure-sdk/ts-use-interface-parameters
34
- client, baseOptions, initOptions, pollOptions, documents, tasks) {
35
- this.client = client;
36
- this.baseOptions = baseOptions;
37
- this.initOptions = initOptions;
38
- this.pollOptions = pollOptions;
39
- this.documents = documents;
40
- this.tasks = tasks;
41
- this.requestMethod = "POST";
42
- this.requestPath = "/analyze";
43
- }
44
- async sendInitialRequest() {
45
- const { span, updatedOptions: finalOptions } = createSpan("TextAnalyticsClient-beginAnalyze", Object.assign(Object.assign({}, this.baseOptions), this.initOptions));
46
- try {
47
- const { flatResponse, rawResponse } = await getRawResponse((paramOptions) => this.client.analyze(Object.assign({ body: {
48
- analysisInput: { documents: this.documents },
49
- tasks: this.tasks,
50
- displayName: this.initOptions.displayName
51
- } }, paramOptions)), finalOptions);
52
- return {
53
- flatResponse: flatResponse,
54
- rawResponse
55
- };
56
- }
57
- catch (e) {
58
- const exception = compileError(e);
59
- span.setStatus({
60
- code: SpanStatusCode.ERROR,
61
- message: exception.message
62
- });
63
- throw exception;
64
- }
65
- finally {
66
- span.end();
67
- }
68
- }
69
- async sendPollRequest(path) {
70
- return sendGetRequest(this.client, analyzeStatusOperationSpec, "AnalyzeStatus", Object.assign(Object.assign({}, this.baseOptions), this.pollOptions), path);
71
- }
72
- }
73
- /**
74
- * @internal
75
- */
76
- export function isAnalyzeDone(response) {
77
- const castResponse = response;
78
- switch (castResponse.status) {
79
- case "notStarted":
80
- case "running":
81
- return false;
82
- default: {
83
- return true;
84
- }
85
- }
86
- }
87
- /**
88
- * @internal
89
- */
90
- export function processAnalyzeResult(
91
- // eslint-disable-next-line @azure/azure-sdk/ts-use-interface-parameters
92
- client, documents, options) {
93
- return (_result, state) => {
94
- const pollingURL = state.pollingURL;
95
- const pagedResult = {
96
- firstPageLink: pollingURL,
97
- getPage: async (pageLink, maxPageSize) => {
98
- const response = await sendGetRequest(client, analyzeStatusOperationSpec, "AnalyzeStatus",
99
- // if `top` is set to `undefined`, the default value will not be sent
100
- // as part of the request.
101
- maxPageSize ? Object.assign(Object.assign({}, options), { top: maxPageSize }) : options, pageLink);
102
- const flatResponse = response.flatResponse;
103
- return {
104
- page: createAnalyzeActionsResult(flatResponse, documents),
105
- nextPageLink: flatResponse.nextLink
106
- };
107
- }
108
- };
109
- const pagedIterator = getPagedAsyncIterator(pagedResult);
110
- // Attach stats if the service starts to return them
111
- // https://github.com/Azure/azure-sdk-for-js/issues/14139
112
- // state.result = Object.assign(pagedIterator, {
113
- // statistics: operationStatus.statistics
114
- // });
115
- return pagedIterator;
116
- };
117
- }
118
- /**
119
- * @internal
120
- */
121
- export function updateAnalyzeState(state, lastResponse) {
122
- const response = lastResponse.body;
123
- state.createdOn = response.createdDateTime;
124
- state.lastModifiedOn = response.lastUpdateDateTime;
125
- state.expiresOn = response.expirationDateTime;
126
- state.status = response.status;
127
- state.actionsSucceededCount = response.tasks.completed;
128
- state.actionsFailedCount = response.tasks.failed;
129
- state.actionsInProgressCount = response.tasks.inProgress;
130
- state.displayName = response.displayName;
131
- }
132
- //# sourceMappingURL=analyzeLro.js.map