@azure/ai-text-analytics 5.1.1-alpha.20210715.1 → 5.1.1-alpha.20220725.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +14 -13
- package/dist/index.js +758 -367
- package/dist/index.js.map +1 -1
- package/dist-esm/src/analyzeActionsResult.js +9 -9
- package/dist-esm/src/analyzeActionsResult.js.map +1 -1
- package/dist-esm/src/analyzeHealthcareEntitiesResult.js +4 -4
- package/dist-esm/src/analyzeHealthcareEntitiesResult.js.map +1 -1
- package/dist-esm/src/analyzeSentimentResult.js +5 -5
- package/dist-esm/src/analyzeSentimentResult.js.map +1 -1
- package/dist-esm/src/analyzeSentimentResultArray.js +1 -1
- package/dist-esm/src/analyzeSentimentResultArray.js.map +1 -1
- package/dist-esm/src/azureKeyCredentialPolicy.js +2 -2
- package/dist-esm/src/azureKeyCredentialPolicy.js.map +1 -1
- package/dist-esm/src/detectLanguageResult.js +1 -1
- package/dist-esm/src/detectLanguageResult.js.map +1 -1
- package/dist-esm/src/detectLanguageResultArray.js +1 -1
- package/dist-esm/src/detectLanguageResultArray.js.map +1 -1
- package/dist-esm/src/extractKeyPhrasesResult.js +1 -1
- package/dist-esm/src/extractKeyPhrasesResult.js.map +1 -1
- package/dist-esm/src/extractKeyPhrasesResultArray.js +1 -1
- package/dist-esm/src/extractKeyPhrasesResultArray.js.map +1 -1
- package/dist-esm/src/generated/generatedClient.js +41 -3
- package/dist-esm/src/generated/generatedClient.js.map +1 -1
- package/dist-esm/src/generated/index.js +0 -1
- package/dist-esm/src/generated/index.js.map +1 -1
- package/dist-esm/src/generated/models/index.js +514 -1
- package/dist-esm/src/generated/models/index.js.map +1 -1
- package/dist-esm/src/generated/models/mappers.js +5 -0
- package/dist-esm/src/generated/models/mappers.js.map +1 -1
- package/dist-esm/src/generated/models/parameters.js +1 -0
- package/dist-esm/src/generated/models/parameters.js.map +1 -1
- package/dist-esm/src/index.js +3 -3
- package/dist-esm/src/index.js.map +1 -1
- package/dist-esm/src/lro/analyze/operation.js +29 -71
- package/dist-esm/src/lro/analyze/operation.js.map +1 -1
- package/dist-esm/src/lro/analyze/poller.js +3 -3
- package/dist-esm/src/lro/analyze/poller.js.map +1 -1
- package/dist-esm/src/lro/health/operation.js +41 -82
- package/dist-esm/src/lro/health/operation.js.map +1 -1
- package/dist-esm/src/lro/health/poller.js +3 -3
- package/dist-esm/src/lro/health/poller.js.map +1 -1
- package/dist-esm/src/lro/poller.js +1 -1
- package/dist-esm/src/lro/poller.js.map +1 -1
- package/dist-esm/src/recognizeCategorizedEntitiesResult.js +1 -1
- package/dist-esm/src/recognizeCategorizedEntitiesResult.js.map +1 -1
- package/dist-esm/src/recognizeCategorizedEntitiesResultArray.js +1 -1
- package/dist-esm/src/recognizeCategorizedEntitiesResultArray.js.map +1 -1
- package/dist-esm/src/recognizeLinkedEntitiesResult.js +1 -1
- package/dist-esm/src/recognizeLinkedEntitiesResult.js.map +1 -1
- package/dist-esm/src/recognizeLinkedEntitiesResultArray.js +1 -1
- package/dist-esm/src/recognizeLinkedEntitiesResultArray.js.map +1 -1
- package/dist-esm/src/recognizePiiEntitiesResult.js +1 -1
- package/dist-esm/src/recognizePiiEntitiesResult.js.map +1 -1
- package/dist-esm/src/recognizePiiEntitiesResultArray.js +1 -1
- package/dist-esm/src/recognizePiiEntitiesResultArray.js.map +1 -1
- package/dist-esm/src/textAnalyticsClient.js +58 -149
- package/dist-esm/src/textAnalyticsClient.js.map +1 -1
- package/dist-esm/src/textAnalyticsResult.js +4 -14
- package/dist-esm/src/textAnalyticsResult.js.map +1 -1
- package/dist-esm/src/util.js +44 -29
- package/dist-esm/src/util.js.map +1 -1
- package/package.json +34 -36
- package/types/ai-text-analytics.d.ts +70 -31
- package/CHANGELOG.md +0 -144
- package/dist-esm/src/generated/generatedClientContext.js +0 -42
- package/dist-esm/src/generated/generatedClientContext.js.map +0 -1
- package/dist-esm/src/tracing.js +0 -12
- package/dist-esm/src/tracing.js.map +0 -1
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
// Copyright (c) Microsoft Corporation.
|
|
2
2
|
// Licensed under the MIT license.
|
|
3
3
|
import { __asyncGenerator, __await } from "tslib";
|
|
4
|
-
import { createAnalyzeActionsResult } from "../../analyzeActionsResult";
|
|
5
|
-
import { getOperationId,
|
|
4
|
+
import { createAnalyzeActionsResult, } from "../../analyzeActionsResult";
|
|
5
|
+
import { getOperationId, nextLinkToTopAndSkip, throwError } from "../../util";
|
|
6
6
|
import { AnalysisPollOperation } from "../poller";
|
|
7
|
-
import { SpanStatusCode } from "@azure/core-tracing";
|
|
8
|
-
import { createSpan } from "../../tracing";
|
|
9
7
|
import { logger } from "../../logger";
|
|
10
8
|
/**
|
|
11
9
|
* @internal
|
|
@@ -19,7 +17,7 @@ function getMetaInfoFromResponse(response) {
|
|
|
19
17
|
actionsSucceededCount: response.tasks.completed,
|
|
20
18
|
actionsFailedCount: response.tasks.failed,
|
|
21
19
|
actionsInProgressCount: response.tasks.inProgress,
|
|
22
|
-
displayName: response.displayName
|
|
20
|
+
displayName: response.displayName,
|
|
23
21
|
};
|
|
24
22
|
}
|
|
25
23
|
/**
|
|
@@ -30,10 +28,11 @@ function getMetaInfoFromResponse(response) {
|
|
|
30
28
|
export class BeginAnalyzeActionsPollerOperation extends AnalysisPollOperation {
|
|
31
29
|
constructor(state,
|
|
32
30
|
// eslint-disable-next-line @azure/azure-sdk/ts-use-interface-parameters
|
|
33
|
-
client, documents, actions, options = {}) {
|
|
31
|
+
client, tracing, documents, actions, options = {}) {
|
|
34
32
|
super(state);
|
|
35
33
|
this.state = state;
|
|
36
34
|
this.client = client;
|
|
35
|
+
this.tracing = tracing;
|
|
37
36
|
this.documents = documents;
|
|
38
37
|
this.actions = actions;
|
|
39
38
|
this.options = options;
|
|
@@ -55,7 +54,7 @@ export class BeginAnalyzeActionsPollerOperation extends AnalysisPollOperation {
|
|
|
55
54
|
byPage: (settings) => {
|
|
56
55
|
const pageOptions = Object.assign(Object.assign({}, options), { top: settings === null || settings === void 0 ? void 0 : settings.maxPageSize });
|
|
57
56
|
return this._listAnalyzeActionsResultsPaged(operationId, pageOptions);
|
|
58
|
-
}
|
|
57
|
+
},
|
|
59
58
|
};
|
|
60
59
|
}
|
|
61
60
|
/**
|
|
@@ -76,77 +75,36 @@ export class BeginAnalyzeActionsPollerOperation extends AnalysisPollOperation {
|
|
|
76
75
|
* returns an iterator to arrays of the sorted results of an analyze actions operation.
|
|
77
76
|
*/
|
|
78
77
|
async _listAnalyzeActionsResultsSinglePage(operationId, options) {
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
const result = createAnalyzeActionsResult(response, this.documents);
|
|
83
|
-
return response.nextLink
|
|
84
|
-
? Object.assign({ result }, nextLinkToTopAndSkip(response.nextLink)) : { result };
|
|
85
|
-
}
|
|
86
|
-
catch (e) {
|
|
87
|
-
span.setStatus({
|
|
88
|
-
code: SpanStatusCode.ERROR,
|
|
89
|
-
message: e.message
|
|
90
|
-
});
|
|
91
|
-
throw e;
|
|
92
|
-
}
|
|
93
|
-
finally {
|
|
94
|
-
span.end();
|
|
95
|
-
}
|
|
78
|
+
const response = await this.tracing.withSpan("TextAnalyticsClient-_listAnalyzeActionsResultsSinglePage", options || {}, (finalOptions) => this.client.analyzeStatus(operationId, finalOptions));
|
|
79
|
+
const result = createAnalyzeActionsResult(response, this.documents);
|
|
80
|
+
return response.nextLink ? Object.assign({ result }, nextLinkToTopAndSkip(response.nextLink)) : { result };
|
|
96
81
|
}
|
|
97
82
|
/**
|
|
98
83
|
* returns whether the analyze actions operation is done and if so returns also
|
|
99
84
|
* statistics.
|
|
100
85
|
*/
|
|
101
86
|
async getAnalyzeActionsOperationStatus(operationId, options) {
|
|
102
|
-
const
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
operationMetdata: getMetaInfoFromResponse(response)
|
|
114
|
-
};
|
|
115
|
-
}
|
|
87
|
+
const response = await this.tracing.withSpan("TextAnalyticsClient-getAnalyzeActionsOperationStatus", options || {}, (finalOptions) => this.client.analyzeStatus(operationId, finalOptions));
|
|
88
|
+
switch (response.status) {
|
|
89
|
+
case "notStarted":
|
|
90
|
+
case "running":
|
|
91
|
+
break;
|
|
92
|
+
default: {
|
|
93
|
+
return {
|
|
94
|
+
done: true,
|
|
95
|
+
statistics: response.statistics,
|
|
96
|
+
operationMetdata: getMetaInfoFromResponse(response),
|
|
97
|
+
};
|
|
116
98
|
}
|
|
117
|
-
return { done: false, operationMetdata: getMetaInfoFromResponse(response) };
|
|
118
|
-
}
|
|
119
|
-
catch (e) {
|
|
120
|
-
span.setStatus({
|
|
121
|
-
code: SpanStatusCode.ERROR,
|
|
122
|
-
message: e.message
|
|
123
|
-
});
|
|
124
|
-
throw e;
|
|
125
|
-
}
|
|
126
|
-
finally {
|
|
127
|
-
span.end();
|
|
128
99
|
}
|
|
100
|
+
return { done: false, operationMetdata: getMetaInfoFromResponse(response) };
|
|
129
101
|
}
|
|
130
102
|
async beginAnalyzeActions(documents, actions, options) {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
displayName: options === null || options === void 0 ? void 0 : options.displayName
|
|
137
|
-
} }, finalOptions));
|
|
138
|
-
}
|
|
139
|
-
catch (e) {
|
|
140
|
-
const exception = handleInvalidDocumentBatch(e);
|
|
141
|
-
span.setStatus({
|
|
142
|
-
code: SpanStatusCode.ERROR,
|
|
143
|
-
message: exception.message
|
|
144
|
-
});
|
|
145
|
-
throw exception;
|
|
146
|
-
}
|
|
147
|
-
finally {
|
|
148
|
-
span.end();
|
|
149
|
-
}
|
|
103
|
+
return this.tracing.withSpan("TextAnalyticsClient-beginAnalyze", options || {}, (finalOptions) => throwError(this.client.analyze(Object.assign({ body: {
|
|
104
|
+
analysisInput: { documents: documents },
|
|
105
|
+
tasks: actions,
|
|
106
|
+
displayName: options === null || options === void 0 ? void 0 : options.displayName,
|
|
107
|
+
} }, finalOptions))));
|
|
150
108
|
}
|
|
151
109
|
async update(options = {}) {
|
|
152
110
|
var _a;
|
|
@@ -158,7 +116,7 @@ export class BeginAnalyzeActionsPollerOperation extends AnalysisPollOperation {
|
|
|
158
116
|
displayName: this.options.displayName,
|
|
159
117
|
tracingOptions: this.options.tracingOptions,
|
|
160
118
|
requestOptions: this.options.requestOptions,
|
|
161
|
-
abortSignal: updatedAbortSignal ? updatedAbortSignal : this.options.abortSignal
|
|
119
|
+
abortSignal: updatedAbortSignal ? updatedAbortSignal : this.options.abortSignal,
|
|
162
120
|
});
|
|
163
121
|
if (!response.operationLocation) {
|
|
164
122
|
throw new Error("Expects a valid 'operationLocation' to retrieve analyze results but did not find any");
|
|
@@ -168,7 +126,7 @@ export class BeginAnalyzeActionsPollerOperation extends AnalysisPollOperation {
|
|
|
168
126
|
const operationStatus = await this.getAnalyzeActionsOperationStatus(state.operationId, {
|
|
169
127
|
abortSignal: updatedAbortSignal ? updatedAbortSignal : options.abortSignal,
|
|
170
128
|
includeStatistics: this.options.includeStatistics,
|
|
171
|
-
tracingOptions: this.options.tracingOptions
|
|
129
|
+
tracingOptions: this.options.tracingOptions,
|
|
172
130
|
});
|
|
173
131
|
state.createdOn = operationStatus.operationMetdata.createdOn;
|
|
174
132
|
state.expiresOn = operationStatus.operationMetdata.expiresOn;
|
|
@@ -184,7 +142,7 @@ export class BeginAnalyzeActionsPollerOperation extends AnalysisPollOperation {
|
|
|
184
142
|
tracingOptions: this.options.tracingOptions,
|
|
185
143
|
includeStatistics: this.options.includeStatistics,
|
|
186
144
|
onResponse: this.options.onResponse,
|
|
187
|
-
serializerOptions: this.options.serializerOptions
|
|
145
|
+
serializerOptions: this.options.serializerOptions,
|
|
188
146
|
});
|
|
189
147
|
// Attach stats if the service starts to return them
|
|
190
148
|
// https://github.com/Azure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B,GAAG,eAAe,CAAC,gBAAgB,CAAC,kBAAkB,CAAC;QAC/E,KAAK,CAAC,sBAAsB,GAAG,eAAe,CAAC,gBAAgB,CAAC,sBAAsB,CAAC;QACvF,KAAK,CAAC,WAAW,GAAG,MAAA,eAAe,CAAC,gBAAgB,0CAAE,WAAW,CAAC;QAElE,IAAI,CAAC,KAAK,CAAC,WAAW,IAAI,eAAe,CAAC,IAAI,EAAE;YAC9C,MAAM,aAAa,GAAG,IAAI,CAAC,yBAAyB,CAAC,KAAK,CAAC,WAAY,EAAE;gBACvE,WAAW,EAAE,IAAI,CAAC,OAAO,CAAC,WAAW;gBACrC,cAAc,EAAE,IAAI,CAAC,OAAO,CAAC,cAAc;gBAC3C,iBAAiB,EAAE,IAAI,CAAC,OAAO,CAAC,iBAAiB;gBACjD,UAAU,EAAE,IAAI,CAAC,OAAO,CAAC,UAAU;gBACnC,iBAAiB,EAAE,IAAI,CAAC,OAAO,CAAC,iBAAiB;aAClD,CAAC,CAAC;YACH,oDAAoD;YACpD,yDAAyD;YACzD,gDAAgD;YAChD,2CAA2C;YAC3C,MAAM;YACN,KAAK,CAAC,MAAM,GAAG,aAAa,CAAC;YAC7B,KAAK,CAAC,WAAW,GAAG,IAAI,CAAC;SAC1B;QAED,IAAI,OAAO,OAAO,CAAC,YAAY,KAAK,UAAU,EAAE;YAC9C,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;SAC7B;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,MAAM;QACV,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QACzB,MAAM,CAAC,OAAO,CAAC,iEAAiE,CAAC,CAAC;QAClF,KAAK,CAAC,WAAW,GAAG,IAAI,CAAC;QACzB,OAAO,IAAI,CAAC;IACd,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { OperationOptions } from \"@azure/core-client\";\n\nimport { AbortSignalLike } from \"@azure/abort-controller\";\n\nimport {\n AnalyzeJobState,\n GeneratedClientAnalyzeResponse as BeginAnalyzeResponse,\n GeneratedClientAnalyzeStatusOptionalParams as AnalyzeActionsOperationStatusOptions,\n JobManifestTasks as GeneratedActions,\n State,\n TextDocumentBatchStatistics,\n TextDocumentInput\n} from \"../../generated/models\";\nimport {\n AnalyzeActionsResult,\n PagedAsyncIterableAnalyzeActionsResult,\n PagedAnalyzeActionsResult,\n createAnalyzeActionsResult\n} from \"../../analyzeActionsResult\";\nimport { PageSettings } from \"@azure/core-paging\";\nimport { getOperationId, handleInvalidDocumentBatch, nextLinkToTopAndSkip } from \"../../util\";\nimport { AnalysisPollOperation, AnalysisPollOperationState, OperationMetadata } from \"../poller\";\nimport { GeneratedClient as Client } from \"../../generated\";\nimport { SpanStatusCode } from \"@azure/core-tracing\";\nimport { createSpan } from \"../../tracing\";\nimport { logger } from \"../../logger\";\nexport { State };\n\n/**\n * @internal\n */\ninterface AnalyzeResultsWithPagination {\n result: AnalyzeActionsResult;\n top?: number;\n skip?: number;\n}\n\n/**\n * The metadata for beginAnalyzeActions operations.\n */\nexport interface AnalyzeActionsOperationMetadata extends OperationMetadata {\n /**\n * Number of successfully completed actions.\n */\n actionsSucceededCount: number;\n /**\n * Number of failed actions.\n */\n actionsFailedCount: number;\n /**\n * Number of actions still in progress.\n */\n actionsInProgressCount: number;\n /**\n * The operation's display name.\n */\n displayName?: string;\n}\n\n/**\n * @internal\n */\ninterface AnalyzeActionsOperationStatus {\n done: boolean;\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 operationMetdata: Omit<AnalyzeActionsOperationMetadata, \"operationId\">;\n}\n\n/**\n * @internal\n */\ninterface BeginAnalyzeInternalOptions extends OperationOptions {\n displayName?: string;\n}\n\n/**\n * Options for the begin analyze actions operation.\n */\nexport interface BeginAnalyzeActionsOptions extends OperationOptions {\n /**\n * Delay to wait until next poll, in milliseconds.\n */\n updateIntervalInMs?: number;\n /**\n * A serialized poller which can be used to resume an existing paused Long-Running-Operation.\n */\n resumeFrom?: string;\n /**\n * If set to true, response will contain input and document level statistics.\n */\n includeStatistics?: boolean;\n /**\n * The operation's display name.\n */\n displayName?: string;\n}\n\n/**\n * The state of the begin analyze polling operation.\n */\nexport interface AnalyzeActionsOperationState\n extends AnalysisPollOperationState<PagedAnalyzeActionsResult>,\n AnalyzeActionsOperationMetadata {}\n\n/**\n * @internal\n */\nfunction getMetaInfoFromResponse(\n response: AnalyzeJobState\n): Omit<AnalyzeActionsOperationMetadata, \"operationId\"> {\n return {\n createdOn: response.createdDateTime,\n lastModifiedOn: response.lastUpdateDateTime,\n expiresOn: response.expirationDateTime,\n status: response.status,\n actionsSucceededCount: response.tasks.completed,\n actionsFailedCount: response.tasks.failed,\n actionsInProgressCount: response.tasks.inProgress,\n displayName: response.displayName\n };\n}\n\n/**\n * Class that represents a poller that waits for results of the analyze\n * operation.\n * @internal\n */\nexport class BeginAnalyzeActionsPollerOperation extends AnalysisPollOperation<\n AnalyzeActionsOperationState,\n PagedAnalyzeActionsResult\n> {\n constructor(\n public state: AnalyzeActionsOperationState,\n // eslint-disable-next-line @azure/azure-sdk/ts-use-interface-parameters\n private client: Client,\n private documents: TextDocumentInput[],\n private actions: GeneratedActions,\n private options: BeginAnalyzeActionsOptions = {}\n ) {\n super(state);\n }\n\n /**\n * should be called only after all the status of the analyze actions operations became\n * \"succeeded\" and it returns an iterator for the results and provides a\n * byPage method to return the results paged.\n */\n private listAnalyzeActionsResults(\n operationId: string,\n options: AnalyzeActionsOperationStatusOptions = {}\n ): PagedAsyncIterableAnalyzeActionsResult {\n const iter = this._listAnalyzeActionsResultsPaged(operationId, options);\n return {\n next() {\n return iter.next();\n },\n [Symbol.asyncIterator]() {\n return this;\n },\n byPage: (settings?: PageSettings) => {\n const pageOptions = { ...options, top: settings?.maxPageSize };\n return this._listAnalyzeActionsResultsPaged(operationId, pageOptions);\n }\n };\n }\n\n /**\n * returns an iterator to arrays of the results of an analyze actions operation.\n */\n private async *_listAnalyzeActionsResultsPaged(\n operationId: string,\n options?: AnalyzeActionsOperationStatusOptions\n ): AsyncIterableIterator<AnalyzeActionsResult> {\n let response = await this._listAnalyzeActionsResultsSinglePage(operationId, options);\n yield response.result;\n while (response.skip) {\n const optionsWithContinuation: AnalyzeActionsOperationStatusOptions = {\n ...options,\n top: response.top,\n skip: response.skip\n };\n response = await this._listAnalyzeActionsResultsSinglePage(\n operationId,\n optionsWithContinuation\n );\n yield response.result;\n }\n }\n\n /**\n * returns an iterator to arrays of the sorted results of an analyze actions operation.\n */\n private async _listAnalyzeActionsResultsSinglePage(\n operationId: string,\n options?: AnalyzeActionsOperationStatusOptions\n ): Promise<AnalyzeResultsWithPagination> {\n const { span, updatedOptions: finalOptions } = createSpan(\n \"TextAnalyticsClient-_listAnalyzeActionsResultsSinglePage\",\n options || {}\n );\n try {\n const response = await this.client.analyzeStatus(operationId, finalOptions);\n const result = createAnalyzeActionsResult(response, this.documents);\n return response.nextLink\n ? { result, ...nextLinkToTopAndSkip(response.nextLink) }\n : { result };\n } catch (e) {\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: e.message\n });\n throw e;\n } finally {\n span.end();\n }\n }\n\n /**\n * returns whether the analyze actions operation is done and if so returns also\n * statistics.\n */\n private async getAnalyzeActionsOperationStatus(\n operationId: string,\n options?: AnalyzeActionsOperationStatusOptions\n ): Promise<AnalyzeActionsOperationStatus> {\n const { span, updatedOptions: finalOptions } = createSpan(\n \"TextAnalyticsClient-getAnalyzeActionsOperationStatus\",\n options || {}\n );\n try {\n const response = await this.client.analyzeStatus(operationId, finalOptions);\n switch (response.status) {\n case \"notStarted\":\n case \"running\":\n break;\n default: {\n return {\n done: true,\n statistics: response.statistics,\n operationMetdata: getMetaInfoFromResponse(response)\n };\n }\n }\n return { done: false, operationMetdata: getMetaInfoFromResponse(response) };\n } catch (e) {\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: e.message\n });\n throw e;\n } finally {\n span.end();\n }\n }\n\n private async beginAnalyzeActions(\n documents: TextDocumentInput[],\n actions: GeneratedActions,\n options?: BeginAnalyzeInternalOptions\n ): Promise<BeginAnalyzeResponse> {\n const { span, updatedOptions: finalOptions } = createSpan(\n \"TextAnalyticsClient-beginAnalyze\",\n options || {}\n );\n\n try {\n return await this.client.analyze({\n body: {\n analysisInput: { documents: documents },\n tasks: actions,\n displayName: options?.displayName\n },\n ...finalOptions\n });\n } catch (e) {\n const exception = handleInvalidDocumentBatch(e);\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: exception.message\n });\n throw exception;\n } finally {\n span.end();\n }\n }\n\n async update(\n options: {\n abortSignal?: AbortSignalLike;\n fireProgress?: (state: AnalyzeActionsOperationState) => void;\n } = {}\n ): Promise<BeginAnalyzeActionsPollerOperation> {\n const state = this.state;\n const updatedAbortSignal = options.abortSignal;\n if (!state.isStarted) {\n state.isStarted = true;\n const response = await this.beginAnalyzeActions(this.documents, this.actions, {\n displayName: this.options.displayName,\n tracingOptions: this.options.tracingOptions,\n requestOptions: this.options.requestOptions,\n abortSignal: updatedAbortSignal ? updatedAbortSignal : this.options.abortSignal\n });\n if (!response.operationLocation) {\n throw new Error(\n \"Expects a valid 'operationLocation' to retrieve analyze results but did not find any\"\n );\n }\n state.operationId = getOperationId(response.operationLocation);\n }\n\n const operationStatus = await this.getAnalyzeActionsOperationStatus(state.operationId!, {\n abortSignal: updatedAbortSignal ? updatedAbortSignal : options.abortSignal,\n includeStatistics: this.options.includeStatistics,\n tracingOptions: this.options.tracingOptions\n });\n\n state.createdOn = operationStatus.operationMetdata.createdOn;\n state.expiresOn = operationStatus.operationMetdata.expiresOn;\n state.lastModifiedOn = operationStatus.operationMetdata.lastModifiedOn;\n state.status = operationStatus.operationMetdata.status;\n state.actionsSucceededCount = operationStatus.operationMetdata.actionsSucceededCount;\n state.actionsFailedCount = operationStatus.operationMetdata.actionsFailedCount;\n state.actionsInProgressCount = operationStatus.operationMetdata.actionsInProgressCount;\n state.displayName = operationStatus.operationMetdata?.displayName;\n\n if (!state.isCompleted && operationStatus.done) {\n const pagedIterator = this.listAnalyzeActionsResults(state.operationId!, {\n abortSignal: this.options.abortSignal,\n tracingOptions: this.options.tracingOptions,\n includeStatistics: this.options.includeStatistics,\n onResponse: this.options.onResponse,\n serializerOptions: this.options.serializerOptions\n });\n // Attach stats if the service starts to return them\n // https://github.com/Azure/azure-sdk-for-js/issues/14139\n // state.result = Object.assign(pagedIterator, {\n // statistics: operationStatus.statistics\n // });\n state.result = pagedIterator;\n state.isCompleted = true;\n }\n\n if (typeof options.fireProgress === \"function\") {\n options.fireProgress(state);\n }\n return this;\n }\n\n async cancel(): Promise<BeginAnalyzeActionsPollerOperation> {\n const state = this.state;\n logger.warning(`The service does not yet support cancellation for beginAnalyze.`);\n state.isCancelled = true;\n return this;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"operation.js","sourceRoot":"","sources":["../../../../src/lro/analyze/operation.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;AAclC,OAAO,EAIL,0BAA0B,GAC3B,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC9E,OAAO,EAAE,qBAAqB,EAAiD,MAAM,WAAW,CAAC;AAEjG,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAoFtC;;GAEG;AACH,SAAS,uBAAuB,CAC9B,QAAyB;IAEzB,OAAO;QACL,SAAS,EAAE,QAAQ,CAAC,eAAe;QACnC,cAAc,EAAE,QAAQ,CAAC,kBAAkB;QAC3C,SAAS,EAAE,QAAQ,CAAC,kBAAkB;QACtC,MAAM,EAAE,QAAQ,CAAC,MAAM;QACvB,qBAAqB,EAAE,QAAQ,CAAC,KAAK,CAAC,SAAS;QAC/C,kBAAkB,EAAE,QAAQ,CAAC,KAAK,CAAC,MAAM;QACzC,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C,WAAY,EAAE;gBACvE,WAAW,EAAE,IAAI,CAAC,OAAO,CAAC,WAAW;gBACrC,cAAc,EAAE,IAAI,CAAC,OAAO,CAAC,cAAc;gBAC3C,iBAAiB,EAAE,IAAI,CAAC,OAAO,CAAC,iBAAiB;gBACjD,UAAU,EAAE,IAAI,CAAC,OAAO,CAAC,UAAU;gBACnC,iBAAiB,EAAE,IAAI,CAAC,OAAO,CAAC,iBAAiB;aAClD,CAAC,CAAC;YACH,oDAAoD;YACpD,yDAAyD;YACzD,gDAAgD;YAChD,2CAA2C;YAC3C,MAAM;YACN,KAAK,CAAC,MAAM,GAAG,aAAa,CAAC;YAC7B,KAAK,CAAC,WAAW,GAAG,IAAI,CAAC;SAC1B;QAED,IAAI,OAAO,OAAO,CAAC,YAAY,KAAK,UAAU,EAAE;YAC9C,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;SAC7B;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,MAAM;QACV,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QACzB,MAAM,CAAC,OAAO,CAAC,iEAAiE,CAAC,CAAC;QAClF,KAAK,CAAC,WAAW,GAAG,IAAI,CAAC;QACzB,OAAO,IAAI,CAAC;IACd,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { OperationOptions } from \"@azure/core-client\";\n\nimport { AbortSignalLike } from \"@azure/abort-controller\";\n\nimport {\n AnalyzeStatusOptionalParams as AnalyzeActionsOperationStatusOptions,\n AnalyzeJobState,\n AnalyzeResponse as BeginAnalyzeResponse,\n JobManifestTasks as GeneratedActions,\n TextDocumentBatchStatistics,\n TextDocumentInput,\n} from \"../../generated/models\";\nimport {\n AnalyzeActionsResult,\n PagedAnalyzeActionsResult,\n PagedAsyncIterableAnalyzeActionsResult,\n createAnalyzeActionsResult,\n} from \"../../analyzeActionsResult\";\nimport { PageSettings } from \"@azure/core-paging\";\nimport { getOperationId, nextLinkToTopAndSkip, throwError } from \"../../util\";\nimport { AnalysisPollOperation, AnalysisPollOperationState, OperationMetadata } from \"../poller\";\nimport { GeneratedClient as Client } from \"../../generated\";\nimport { logger } from \"../../logger\";\nimport { TracingClient } from \"@azure/core-tracing\";\n\n/**\n * @internal\n */\ninterface AnalyzeResultsWithPagination {\n result: AnalyzeActionsResult;\n top?: number;\n skip?: number;\n}\n\n/**\n * The metadata for beginAnalyzeActions operations.\n */\nexport interface AnalyzeActionsOperationMetadata extends OperationMetadata {\n /**\n * Number of successfully completed actions.\n */\n actionsSucceededCount: number;\n /**\n * Number of failed actions.\n */\n actionsFailedCount: number;\n /**\n * Number of actions still in progress.\n */\n actionsInProgressCount: number;\n /**\n * The operation's display name.\n */\n displayName?: string;\n}\n\n/**\n * @internal\n */\ninterface AnalyzeActionsOperationStatus {\n done: boolean;\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 operationMetdata: Omit<AnalyzeActionsOperationMetadata, \"operationId\">;\n}\n\n/**\n * @internal\n */\ninterface BeginAnalyzeInternalOptions extends OperationOptions {\n displayName?: string;\n}\n\n/**\n * Options for the begin analyze actions operation.\n */\nexport interface BeginAnalyzeActionsOptions extends OperationOptions {\n /**\n * Delay to wait until next poll, in milliseconds.\n */\n updateIntervalInMs?: number;\n /**\n * A serialized poller which can be used to resume an existing paused Long-Running-Operation.\n */\n resumeFrom?: string;\n /**\n * If set to true, response will contain input and document level statistics.\n */\n includeStatistics?: boolean;\n /**\n * The operation's display name.\n */\n displayName?: string;\n}\n\n/**\n * The state of the begin analyze polling operation.\n */\nexport interface AnalyzeActionsOperationState\n extends AnalysisPollOperationState<PagedAnalyzeActionsResult>,\n AnalyzeActionsOperationMetadata {}\n\n/**\n * @internal\n */\nfunction getMetaInfoFromResponse(\n response: AnalyzeJobState\n): Omit<AnalyzeActionsOperationMetadata, \"operationId\"> {\n return {\n createdOn: response.createdDateTime,\n lastModifiedOn: response.lastUpdateDateTime,\n expiresOn: response.expirationDateTime,\n status: response.status,\n actionsSucceededCount: response.tasks.completed,\n actionsFailedCount: response.tasks.failed,\n actionsInProgressCount: response.tasks.inProgress,\n displayName: response.displayName,\n };\n}\n\n/**\n * Class that represents a poller that waits for results of the analyze\n * operation.\n * @internal\n */\nexport class BeginAnalyzeActionsPollerOperation extends AnalysisPollOperation<\n AnalyzeActionsOperationState,\n PagedAnalyzeActionsResult\n> {\n constructor(\n public state: AnalyzeActionsOperationState,\n // eslint-disable-next-line @azure/azure-sdk/ts-use-interface-parameters\n private client: Client,\n private tracing: TracingClient,\n private documents: TextDocumentInput[],\n private actions: GeneratedActions,\n private options: BeginAnalyzeActionsOptions = {}\n ) {\n super(state);\n }\n\n /**\n * should be called only after all the status of the analyze actions operations became\n * \"succeeded\" and it returns an iterator for the results and provides a\n * byPage method to return the results paged.\n */\n private listAnalyzeActionsResults(\n operationId: string,\n options: AnalyzeActionsOperationStatusOptions = {}\n ): PagedAsyncIterableAnalyzeActionsResult {\n const iter = this._listAnalyzeActionsResultsPaged(operationId, options);\n return {\n next() {\n return iter.next();\n },\n [Symbol.asyncIterator]() {\n return this;\n },\n byPage: (settings?: PageSettings) => {\n const pageOptions = { ...options, top: settings?.maxPageSize };\n return this._listAnalyzeActionsResultsPaged(operationId, pageOptions);\n },\n };\n }\n\n /**\n * returns an iterator to arrays of the results of an analyze actions operation.\n */\n private async *_listAnalyzeActionsResultsPaged(\n operationId: string,\n options?: AnalyzeActionsOperationStatusOptions\n ): AsyncIterableIterator<AnalyzeActionsResult> {\n let response = await this._listAnalyzeActionsResultsSinglePage(operationId, options);\n yield response.result;\n while (response.skip) {\n const optionsWithContinuation: AnalyzeActionsOperationStatusOptions = {\n ...options,\n top: response.top,\n skip: response.skip,\n };\n response = await this._listAnalyzeActionsResultsSinglePage(\n operationId,\n optionsWithContinuation\n );\n yield response.result;\n }\n }\n\n /**\n * returns an iterator to arrays of the sorted results of an analyze actions operation.\n */\n private async _listAnalyzeActionsResultsSinglePage(\n operationId: string,\n options?: AnalyzeActionsOperationStatusOptions\n ): Promise<AnalyzeResultsWithPagination> {\n const response = await this.tracing.withSpan(\n \"TextAnalyticsClient-_listAnalyzeActionsResultsSinglePage\",\n options || {},\n (finalOptions) => this.client.analyzeStatus(operationId, finalOptions)\n );\n const result = createAnalyzeActionsResult(response, this.documents);\n return response.nextLink ? { result, ...nextLinkToTopAndSkip(response.nextLink) } : { result };\n }\n\n /**\n * returns whether the analyze actions operation is done and if so returns also\n * statistics.\n */\n private async getAnalyzeActionsOperationStatus(\n operationId: string,\n options?: AnalyzeActionsOperationStatusOptions\n ): Promise<AnalyzeActionsOperationStatus> {\n const response = await this.tracing.withSpan(\n \"TextAnalyticsClient-getAnalyzeActionsOperationStatus\",\n options || {},\n (finalOptions) => this.client.analyzeStatus(operationId, finalOptions)\n );\n switch (response.status) {\n case \"notStarted\":\n case \"running\":\n break;\n default: {\n return {\n done: true,\n statistics: response.statistics,\n operationMetdata: getMetaInfoFromResponse(response),\n };\n }\n }\n return { done: false, operationMetdata: getMetaInfoFromResponse(response) };\n }\n\n private async beginAnalyzeActions(\n documents: TextDocumentInput[],\n actions: GeneratedActions,\n options?: BeginAnalyzeInternalOptions\n ): Promise<BeginAnalyzeResponse> {\n return this.tracing.withSpan(\n \"TextAnalyticsClient-beginAnalyze\",\n options || {},\n (finalOptions) =>\n throwError(\n this.client.analyze({\n body: {\n analysisInput: { documents: documents },\n tasks: actions,\n displayName: options?.displayName,\n },\n ...finalOptions,\n })\n )\n );\n }\n\n async update(\n options: {\n abortSignal?: AbortSignalLike;\n fireProgress?: (state: AnalyzeActionsOperationState) => void;\n } = {}\n ): Promise<BeginAnalyzeActionsPollerOperation> {\n const state = this.state;\n const updatedAbortSignal = options.abortSignal;\n if (!state.isStarted) {\n state.isStarted = true;\n const response = await this.beginAnalyzeActions(this.documents, this.actions, {\n displayName: this.options.displayName,\n tracingOptions: this.options.tracingOptions,\n requestOptions: this.options.requestOptions,\n abortSignal: updatedAbortSignal ? updatedAbortSignal : this.options.abortSignal,\n });\n if (!response.operationLocation) {\n throw new Error(\n \"Expects a valid 'operationLocation' to retrieve analyze results but did not find any\"\n );\n }\n state.operationId = getOperationId(response.operationLocation);\n }\n\n const operationStatus = await this.getAnalyzeActionsOperationStatus(state.operationId!, {\n abortSignal: updatedAbortSignal ? updatedAbortSignal : options.abortSignal,\n includeStatistics: this.options.includeStatistics,\n tracingOptions: this.options.tracingOptions,\n });\n\n state.createdOn = operationStatus.operationMetdata.createdOn;\n state.expiresOn = operationStatus.operationMetdata.expiresOn;\n state.lastModifiedOn = operationStatus.operationMetdata.lastModifiedOn;\n state.status = operationStatus.operationMetdata.status;\n state.actionsSucceededCount = operationStatus.operationMetdata.actionsSucceededCount;\n state.actionsFailedCount = operationStatus.operationMetdata.actionsFailedCount;\n state.actionsInProgressCount = operationStatus.operationMetdata.actionsInProgressCount;\n state.displayName = operationStatus.operationMetdata?.displayName;\n\n if (!state.isCompleted && operationStatus.done) {\n const pagedIterator = this.listAnalyzeActionsResults(state.operationId!, {\n abortSignal: this.options.abortSignal,\n tracingOptions: this.options.tracingOptions,\n includeStatistics: this.options.includeStatistics,\n onResponse: this.options.onResponse,\n serializerOptions: this.options.serializerOptions,\n });\n // Attach stats if the service starts to return them\n // https://github.com/Azure/azure-sdk-for-js/issues/14139\n // state.result = Object.assign(pagedIterator, {\n // statistics: operationStatus.statistics\n // });\n state.result = pagedIterator;\n state.isCompleted = true;\n }\n\n if (typeof options.fireProgress === \"function\") {\n options.fireProgress(state);\n }\n return this;\n }\n\n async cancel(): Promise<BeginAnalyzeActionsPollerOperation> {\n const state = this.state;\n logger.warning(`The service does not yet support cancellation for beginAnalyze.`);\n state.isCancelled = true;\n return this;\n }\n}\n"]}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Licensed under the MIT license.
|
|
3
3
|
import { delay } from "../../util";
|
|
4
4
|
import { AnalysisPoller } from "../poller";
|
|
5
|
-
import { BeginAnalyzeActionsPollerOperation } from "./operation";
|
|
5
|
+
import { BeginAnalyzeActionsPollerOperation, } from "./operation";
|
|
6
6
|
/**
|
|
7
7
|
* Class that represents a poller that waits for the analyze actions results.
|
|
8
8
|
* @internal
|
|
@@ -10,12 +10,12 @@ import { BeginAnalyzeActionsPollerOperation } from "./operation";
|
|
|
10
10
|
export class BeginAnalyzeActionsPoller extends AnalysisPoller {
|
|
11
11
|
// eslint-disable-next-line @azure/azure-sdk/ts-use-interface-parameters
|
|
12
12
|
constructor(pollerOptions) {
|
|
13
|
-
const { client, documents, actions, options, updateIntervalInMs = 5000, resumeFrom } = pollerOptions;
|
|
13
|
+
const { client, tracing, documents, actions, options, updateIntervalInMs = 5000, resumeFrom, } = pollerOptions;
|
|
14
14
|
let state;
|
|
15
15
|
if (resumeFrom) {
|
|
16
16
|
state = JSON.parse(resumeFrom).state;
|
|
17
17
|
}
|
|
18
|
-
const operation = new BeginAnalyzeActionsPollerOperation((state || {}), client, documents, actions, options);
|
|
18
|
+
const operation = new BeginAnalyzeActionsPollerOperation((state || {}), client, tracing, documents, actions, options);
|
|
19
19
|
super(operation);
|
|
20
20
|
this.updateIntervalInMs = updateIntervalInMs;
|
|
21
21
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"poller.js","sourceRoot":"","sources":["../../../../src/lro/analyze/poller.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAKlC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC,OAAO,EAAE,cAAc,EAAyB,MAAM,WAAW,CAAC;AAClE,OAAO,
|
|
1
|
+
{"version":3,"file":"poller.js","sourceRoot":"","sources":["../../../../src/lro/analyze/poller.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAKlC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC,OAAO,EAAE,cAAc,EAAyB,MAAM,WAAW,CAAC;AAClE,OAAO,EAGL,kCAAkC,GACnC,MAAM,aAAa,CAAC;AAkBrB;;;GAGG;AACH,MAAM,OAAO,yBAA0B,SAAQ,cAG9C;IACC,wEAAwE;IACxE,YAAY,aAA0C;QACpD,MAAM,EACJ,MAAM,EACN,OAAO,EACP,SAAS,EACT,OAAO,EACP,OAAO,EACP,kBAAkB,GAAG,IAAI,EACzB,UAAU,GACX,GAAG,aAAa,CAAC;QAElB,IAAI,KAA+C,CAAC;QAEpD,IAAI,UAAU,EAAE;YACd,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC;SACtC;QACD,MAAM,SAAS,GAAG,IAAI,kCAAkC,CACtD,CAAC,KAAK,IAAI,EAAE,CAAQ,EACpB,MAAM,EACN,OAAO,EACP,SAAS,EACT,OAAO,EACP,OAAO,CACR,CAAC;QAEF,KAAK,CAAC,SAAS,CAAC,CAAC;QAEjB,IAAI,CAAC,kBAAkB,GAAG,kBAAkB,CAAC;IAC/C,CAAC;IAEM,KAAK;QACV,OAAO,KAAK,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;IACxC,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { PollerLike } from \"@azure/core-lro\";\nimport { PagedAnalyzeActionsResult } from \"../../analyzeActionsResult\";\nimport { JobManifestTasks as GeneratedActions } from \"../../generated/models\";\nimport { delay } from \"../../util\";\n\nimport { AnalysisPoller, AnalysisPollerOptions } from \"../poller\";\nimport {\n AnalyzeActionsOperationState,\n BeginAnalyzeActionsOptions,\n BeginAnalyzeActionsPollerOperation,\n} from \"./operation\";\n\n/**\n * @internal\n */\ninterface AnalyzeActionsPollerOptions extends AnalysisPollerOptions {\n actions: GeneratedActions;\n readonly options: BeginAnalyzeActionsOptions;\n}\n\n/**\n * Result type of the Begin Analyze Actions Long-Running-Operation (LRO).\n */\nexport type AnalyzeActionsPollerLike = PollerLike<\n AnalyzeActionsOperationState,\n PagedAnalyzeActionsResult\n>;\n\n/**\n * Class that represents a poller that waits for the analyze actions results.\n * @internal\n */\nexport class BeginAnalyzeActionsPoller extends AnalysisPoller<\n AnalyzeActionsOperationState,\n PagedAnalyzeActionsResult\n> {\n // eslint-disable-next-line @azure/azure-sdk/ts-use-interface-parameters\n constructor(pollerOptions: AnalyzeActionsPollerOptions) {\n const {\n client,\n tracing,\n documents,\n actions,\n options,\n updateIntervalInMs = 5000,\n resumeFrom,\n } = pollerOptions;\n\n let state: AnalyzeActionsOperationState | undefined;\n\n if (resumeFrom) {\n state = JSON.parse(resumeFrom).state;\n }\n const operation = new BeginAnalyzeActionsPollerOperation(\n (state || {}) as any,\n client,\n tracing,\n documents,\n actions,\n options\n );\n\n super(operation);\n\n this.updateIntervalInMs = updateIntervalInMs;\n }\n\n public delay(): Promise<void> {\n return delay(this.updateIntervalInMs);\n }\n}\n"]}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
// Copyright (c) Microsoft Corporation.
|
|
2
2
|
// Licensed under the MIT license.
|
|
3
3
|
import { __asyncDelegator, __asyncGenerator, __asyncValues, __await } from "tslib";
|
|
4
|
-
import { makeHealthcareEntitiesResult,
|
|
5
|
-
import { addStrEncodingParam, getOperationId,
|
|
6
|
-
import { AnalysisPollOperation } from "../poller";
|
|
4
|
+
import { makeHealthcareEntitiesErrorResult, makeHealthcareEntitiesResult, } from "../../analyzeHealthcareEntitiesResult";
|
|
5
|
+
import { addStrEncodingParam, getOperationId, nextLinkToTopAndSkip, throwError, } from "../../util";
|
|
6
|
+
import { AnalysisPollOperation, } from "../poller";
|
|
7
7
|
import { processAndCombineSuccessfulAndErroneousDocuments } from "../../textAnalyticsResult";
|
|
8
|
-
import { SpanStatusCode } from "@azure/core-tracing";
|
|
9
|
-
import { createSpan } from "../../tracing";
|
|
10
8
|
/**
|
|
11
9
|
* @internal
|
|
12
10
|
*/
|
|
@@ -15,7 +13,7 @@ function getMetaInfoFromResponse(response) {
|
|
|
15
13
|
createdOn: response.createdDateTime,
|
|
16
14
|
lastModifiedOn: response.lastUpdateDateTime,
|
|
17
15
|
expiresOn: response.expirationDateTime,
|
|
18
|
-
status: response.status
|
|
16
|
+
status: response.status,
|
|
19
17
|
};
|
|
20
18
|
}
|
|
21
19
|
/**
|
|
@@ -25,10 +23,11 @@ function getMetaInfoFromResponse(response) {
|
|
|
25
23
|
export class BeginAnalyzeHealthcarePollerOperation extends AnalysisPollOperation {
|
|
26
24
|
constructor(state,
|
|
27
25
|
// eslint-disable-next-line @azure/azure-sdk/ts-use-interface-parameters
|
|
28
|
-
client, documents, options = {}) {
|
|
26
|
+
client, tracing, documents, options = {}) {
|
|
29
27
|
super(state);
|
|
30
28
|
this.state = state;
|
|
31
29
|
this.client = client;
|
|
30
|
+
this.tracing = tracing;
|
|
32
31
|
this.documents = documents;
|
|
33
32
|
this.options = options;
|
|
34
33
|
}
|
|
@@ -49,7 +48,7 @@ export class BeginAnalyzeHealthcarePollerOperation extends AnalysisPollOperation
|
|
|
49
48
|
byPage: (settings) => {
|
|
50
49
|
const pageOptions = Object.assign(Object.assign({}, options), { top: settings === null || settings === void 0 ? void 0 : settings.maxPageSize });
|
|
51
50
|
return this._listHealthcareEntitiesPaged(operationId, pageOptions);
|
|
52
|
-
}
|
|
51
|
+
},
|
|
53
52
|
};
|
|
54
53
|
}
|
|
55
54
|
/**
|
|
@@ -91,27 +90,14 @@ export class BeginAnalyzeHealthcarePollerOperation extends AnalysisPollOperation
|
|
|
91
90
|
* returns an iterator to arrays of the sorted results of a healthcare operation.
|
|
92
91
|
*/
|
|
93
92
|
async _listHealthcareEntitiesSinglePage(operationId, options) {
|
|
94
|
-
const
|
|
95
|
-
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
return response.nextLink
|
|
100
|
-
? Object.assign({ result }, nextLinkToTopAndSkip(response.nextLink)) : { result };
|
|
101
|
-
}
|
|
102
|
-
else {
|
|
103
|
-
throw new Error("Healthcare action has succeeded but the there are no results!");
|
|
104
|
-
}
|
|
93
|
+
const response = await this.tracing.withSpan("TextAnalyticsClient-_listHealthcareEntitiesSinglePage", options || {}, (finalOptions) => this.client.healthStatus(operationId, finalOptions));
|
|
94
|
+
if (response.results) {
|
|
95
|
+
const result = processAndCombineSuccessfulAndErroneousDocuments(this.documents, response.results, makeHealthcareEntitiesResult, makeHealthcareEntitiesErrorResult);
|
|
96
|
+
return response.nextLink
|
|
97
|
+
? Object.assign({ result }, nextLinkToTopAndSkip(response.nextLink)) : { result };
|
|
105
98
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
code: SpanStatusCode.ERROR,
|
|
109
|
-
message: e.message
|
|
110
|
-
});
|
|
111
|
-
throw e;
|
|
112
|
-
}
|
|
113
|
-
finally {
|
|
114
|
-
span.end();
|
|
99
|
+
else {
|
|
100
|
+
throw new Error("Healthcare action has succeeded but the there are no results!");
|
|
115
101
|
}
|
|
116
102
|
}
|
|
117
103
|
/**
|
|
@@ -120,61 +106,34 @@ export class BeginAnalyzeHealthcarePollerOperation extends AnalysisPollOperation
|
|
|
120
106
|
*/
|
|
121
107
|
async getHealthStatus(operationId, options) {
|
|
122
108
|
var _a;
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
109
|
+
const response = await this.tracing.withSpan("TextAnalyticsClient-getHealthStatus", options || {}, (finalOptions) => this.client.healthStatus(operationId, finalOptions));
|
|
110
|
+
switch (response.status) {
|
|
111
|
+
case "notStarted":
|
|
112
|
+
case "running":
|
|
113
|
+
break;
|
|
114
|
+
case "failed": {
|
|
115
|
+
const errors = (_a = response.errors) === null || _a === void 0 ? void 0 : _a.map((e) => ` code ${e.code}, message: '${e.message}'`).join("\n");
|
|
116
|
+
const message = `Healthcare analysis failed. Error(s): ${errors || ""}`;
|
|
117
|
+
throw new Error(message);
|
|
118
|
+
}
|
|
119
|
+
default: {
|
|
120
|
+
if (response.results) {
|
|
121
|
+
return {
|
|
122
|
+
done: true,
|
|
123
|
+
statistics: response.results.statistics,
|
|
124
|
+
modelVersion: response.results.modelVersion,
|
|
125
|
+
operationMetdata: getMetaInfoFromResponse(response),
|
|
126
|
+
};
|
|
134
127
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
return {
|
|
138
|
-
done: true,
|
|
139
|
-
statistics: response.results.statistics,
|
|
140
|
-
modelVersion: response.results.modelVersion,
|
|
141
|
-
operationMetdata: getMetaInfoFromResponse(response)
|
|
142
|
-
};
|
|
143
|
-
}
|
|
144
|
-
else {
|
|
145
|
-
throw new Error("Healthcare action has finished but the there are no results!");
|
|
146
|
-
}
|
|
128
|
+
else {
|
|
129
|
+
throw new Error("Healthcare action has finished but the there are no results!");
|
|
147
130
|
}
|
|
148
131
|
}
|
|
149
|
-
return { done: false, operationMetdata: getMetaInfoFromResponse(response) };
|
|
150
|
-
}
|
|
151
|
-
catch (e) {
|
|
152
|
-
span.setStatus({
|
|
153
|
-
code: SpanStatusCode.ERROR,
|
|
154
|
-
message: e.message
|
|
155
|
-
});
|
|
156
|
-
throw e;
|
|
157
|
-
}
|
|
158
|
-
finally {
|
|
159
|
-
span.end();
|
|
160
132
|
}
|
|
133
|
+
return { done: false, operationMetdata: getMetaInfoFromResponse(response) };
|
|
161
134
|
}
|
|
162
135
|
async beginAnalyzeHealthcare(documents, options) {
|
|
163
|
-
|
|
164
|
-
try {
|
|
165
|
-
return await this.client.health({ documents: documents }, finalOptions);
|
|
166
|
-
}
|
|
167
|
-
catch (e) {
|
|
168
|
-
const exception = handleInvalidDocumentBatch(e);
|
|
169
|
-
span.setStatus({
|
|
170
|
-
code: SpanStatusCode.ERROR,
|
|
171
|
-
message: exception.message
|
|
172
|
-
});
|
|
173
|
-
throw exception;
|
|
174
|
-
}
|
|
175
|
-
finally {
|
|
176
|
-
span.end();
|
|
177
|
-
}
|
|
136
|
+
return this.tracing.withSpan("TextAnalyticsClient-beginAnalyzeHealthcare", addStrEncodingParam(options || {}), (finalOptions) => throwError(this.client.health({ documents: documents }, finalOptions)));
|
|
178
137
|
}
|
|
179
138
|
async update(options = {}) {
|
|
180
139
|
const state = this.state;
|
|
@@ -187,7 +146,7 @@ export class BeginAnalyzeHealthcarePollerOperation extends AnalysisPollOperation
|
|
|
187
146
|
abortSignal: updatedAbortSignal ? updatedAbortSignal : options.abortSignal,
|
|
188
147
|
modelVersion: this.options.modelVersion,
|
|
189
148
|
stringIndexType: this.options.stringIndexType,
|
|
190
|
-
loggingOptOut: this.options.disableServiceLogs
|
|
149
|
+
loggingOptOut: this.options.disableServiceLogs,
|
|
191
150
|
});
|
|
192
151
|
if (!response.operationLocation) {
|
|
193
152
|
throw new Error("Expects a valid 'operationLocation' to retrieve health results but did not find any");
|
|
@@ -199,7 +158,7 @@ export class BeginAnalyzeHealthcarePollerOperation extends AnalysisPollOperation
|
|
|
199
158
|
includeStatistics: this.options.includeStatistics,
|
|
200
159
|
tracingOptions: this.options.tracingOptions,
|
|
201
160
|
onResponse: this.options.onResponse,
|
|
202
|
-
serializerOptions: this.options.serializerOptions
|
|
161
|
+
serializerOptions: this.options.serializerOptions,
|
|
203
162
|
});
|
|
204
163
|
state.createdOn = operationStatus.operationMetdata.createdOn;
|
|
205
164
|
state.expiresOn = operationStatus.operationMetdata.expiresOn;
|
|
@@ -208,11 +167,11 @@ export class BeginAnalyzeHealthcarePollerOperation extends AnalysisPollOperation
|
|
|
208
167
|
if (!state.isCompleted && operationStatus.done) {
|
|
209
168
|
const pagedIterator = this.listHealthcareEntitiesByPage(state.operationId, {
|
|
210
169
|
abortSignal: this.options.abortSignal,
|
|
211
|
-
tracingOptions: this.options.tracingOptions
|
|
170
|
+
tracingOptions: this.options.tracingOptions,
|
|
212
171
|
});
|
|
213
172
|
state.result = Object.assign(pagedIterator, {
|
|
214
173
|
statistics: operationStatus.statistics,
|
|
215
|
-
modelVersion: operationStatus.modelVersion
|
|
174
|
+
modelVersion: operationStatus.modelVersion,
|
|
216
175
|
});
|
|
217
176
|
state.isCompleted = true;
|
|
218
177
|
}
|
|
@@ -226,7 +185,7 @@ export class BeginAnalyzeHealthcarePollerOperation extends AnalysisPollOperation
|
|
|
226
185
|
if (state.operationId) {
|
|
227
186
|
await this.client.cancelHealthJob(state.operationId, {
|
|
228
187
|
abortSignal: this.options.abortSignal,
|
|
229
|
-
tracingOptions: this.options.tracingOptions
|
|
188
|
+
tracingOptions: this.options.tracingOptions,
|
|
230
189
|
});
|
|
231
190
|
}
|
|
232
191
|
state.isCancelled = true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operation.js","sourceRoot":"","sources":["../../../../src/lro/health/operation.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;AAalC,OAAO,EAKL,4BAA4B,EAC5B,iCAAiC,EAClC,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EACL,mBAAmB,EACnB,cAAc,EACd,0BAA0B,EAC1B,oBAAoB,EAErB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,qBAAqB,EAGtB,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,gDAAgD,EAAE,MAAM,2BAA2B,CAAC;AAC7F,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAiF3C;;GAEG;AACH,SAAS,uBAAuB,CAC9B,QAA4B;IAE5B,OAAO;QACL,SAAS,EAAE,QAAQ,CAAC,eAAe;QACnC,cAAc,EAAE,QAAQ,CAAC,kBAAkB;QAC3C,SAAS,EAAE,QAAQ,CAAC,kBAAkB;QACtC,MAAM,EAAE,QAAQ,CAAC,MAAM;KACxB,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,OAAO,qCAAsC,SAAQ,qBAG1D;IACC,YACS,KAAsC;IAC7C,wEAAwE;IAChE,MAAc,EACd,SAA8B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AAO,CAAC,WAAW;gBACrC,cAAc,EAAE,IAAI,CAAC,OAAO,CAAC,cAAc;aAC5C,CAAC,CAAC;YACH,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,aAAa,EAAE;gBAC1C,UAAU,EAAE,eAAe,CAAC,UAAU;gBACtC,YAAY,EAAE,eAAe,CAAC,YAAa;aAC5C,CAAC,CAAC;YACH,KAAK,CAAC,WAAW,GAAG,IAAI,CAAC;SAC1B;QACD,IAAI,OAAO,OAAO,CAAC,YAAY,KAAK,UAAU,EAAE;YAC9C,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;SAC7B;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,MAAM;QACV,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QACzB,IAAI,KAAK,CAAC,WAAW,EAAE;YACrB,MAAM,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,KAAK,CAAC,WAAW,EAAE;gBACnD,WAAW,EAAE,IAAI,CAAC,OAAO,CAAC,WAAW;gBACrC,cAAc,EAAE,IAAI,CAAC,OAAO,CAAC,cAAc;aAC5C,CAAC,CAAC;SACJ;QACD,KAAK,CAAC,WAAW,GAAG,IAAI,CAAC;QACzB,OAAO,IAAI,CAAC;IACd,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { AbortSignalLike } from \"@azure/abort-controller\";\nimport { OperationOptions } from \"@azure/core-client\";\n\nimport {\n GeneratedClientHealthResponse as BeginAnalyzeHealthcareResponse,\n GeneratedClientHealthStatusOptionalParams as HealthcareJobStatusOptions,\n HealthcareJobState,\n State,\n TextDocumentBatchStatistics,\n TextDocumentInput\n} from \"../../generated/models\";\nimport {\n AnalyzeHealthcareEntitiesResult,\n AnalyzeHealthcareEntitiesResultArray,\n PagedAsyncIterableAnalyzeHealthcareEntitiesResult,\n PagedAnalyzeHealthcareEntitiesResult,\n makeHealthcareEntitiesResult,\n makeHealthcareEntitiesErrorResult\n} from \"../../analyzeHealthcareEntitiesResult\";\nimport { PageSettings } from \"@azure/core-paging\";\nimport {\n addStrEncodingParam,\n getOperationId,\n handleInvalidDocumentBatch,\n nextLinkToTopAndSkip,\n StringIndexType\n} from \"../../util\";\nimport {\n AnalysisPollOperation,\n AnalysisPollOperationState,\n OperationMetadata as AnalyzeHealthcareEntitiesOperationMetadata\n} from \"../poller\";\nimport { GeneratedClient as Client } from \"../../generated\";\nimport { processAndCombineSuccessfulAndErroneousDocuments } from \"../../textAnalyticsResult\";\nimport { SpanStatusCode } from \"@azure/core-tracing\";\nimport { createSpan } from \"../../tracing\";\nimport { TextAnalyticsOperationOptions } from \"../../textAnalyticsOperationOptions\";\nexport { State };\n\n/**\n * @internal\n */\ninterface AnalyzeHealthcareEntitiesResultWithPagination {\n result: AnalyzeHealthcareEntitiesResultArray;\n top?: number;\n skip?: number;\n}\n\n/**\n * @internal\n */\ninterface HealthcareJobStatus {\n done: boolean;\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 operationMetdata: Omit<AnalyzeHealthcareEntitiesOperationMetadata, \"operationId\">;\n}\n\n/**\n * @internal\n */\ninterface BeginAnalyzeHealthcareInternalOptions extends OperationOptions {\n /**\n * This value indicates which model will be used for scoring. If a model-version is\n * not specified, the API should default to the latest, non-preview version.\n * For supported model versions, see operation-specific documentation, for example:\n * https://docs.microsoft.com/azure/cognitive-services/text-analytics/how-tos/text-analytics-how-to-sentiment-analysis#model-versioning\n */\n modelVersion?: string;\n /**\n * Specifies the measurement unit used to calculate the offset and length properties.\n * Possible units are \"TextElements_v8\", \"UnicodeCodePoint\", and \"Utf16CodeUnit\".\n * The default is the JavaScript's default which is \"Utf16CodeUnit\".\n */\n stringIndexType?: StringIndexType;\n /**\n * If set to false, you opt-in to have your text input logged for troubleshooting. By default, Text Analytics\n * will not log your input text for healthcare entities analysis. Setting this parameter to false,\n * enables input logging.\n */\n loggingOptOut?: boolean;\n}\n\n/**\n * Options for the begin analyze healthcare entities operation.\n */\nexport interface BeginAnalyzeHealthcareEntitiesOptions extends TextAnalyticsOperationOptions {\n /**\n * Delay to wait until next poll, in milliseconds.\n */\n stringIndexType?: StringIndexType;\n /**\n * Delay to wait until next poll, in milliseconds.\n */\n updateIntervalInMs?: number;\n /**\n * A serialized poller which can be used to resume an existing paused Long-Running-Operation.\n */\n resumeFrom?: string;\n}\n\n/**\n * The state of the begin analyze healthcare polling operation.\n */\nexport interface AnalyzeHealthcareOperationState\n extends AnalysisPollOperationState<PagedAnalyzeHealthcareEntitiesResult> {}\n\n/**\n * @internal\n */\nfunction getMetaInfoFromResponse(\n response: HealthcareJobState\n): Omit<AnalyzeHealthcareEntitiesOperationMetadata, \"operationId\"> {\n return {\n createdOn: response.createdDateTime,\n lastModifiedOn: response.lastUpdateDateTime,\n expiresOn: response.expirationDateTime,\n status: response.status\n };\n}\n\n/**\n * Class that represents a poller that waits for the healthcare results.\n * @internal\n */\nexport class BeginAnalyzeHealthcarePollerOperation extends AnalysisPollOperation<\n AnalyzeHealthcareOperationState,\n PagedAnalyzeHealthcareEntitiesResult\n> {\n constructor(\n public state: AnalyzeHealthcareOperationState,\n // eslint-disable-next-line @azure/azure-sdk/ts-use-interface-parameters\n private client: Client,\n private documents: TextDocumentInput[],\n private options: BeginAnalyzeHealthcareEntitiesOptions = {}\n ) {\n super(state);\n }\n\n /**\n * should be called only after all the status of the healthcare operations became\n * \"succeeded\" and it returns an iterator for the results and provides a\n * byPage method to return the results paged.\n */\n private listHealthcareEntitiesByPage(\n operationId: string,\n options: HealthcareJobStatusOptions = {}\n ): PagedAsyncIterableAnalyzeHealthcareEntitiesResult {\n const iter = this._listHealthcareEntities(operationId, options);\n return {\n next() {\n return iter.next();\n },\n [Symbol.asyncIterator]() {\n return this;\n },\n byPage: (settings?: PageSettings) => {\n const pageOptions = { ...options, top: settings?.maxPageSize };\n return this._listHealthcareEntitiesPaged(operationId, pageOptions);\n }\n };\n }\n\n /**\n * returns an iterator to the results of a healthcare operation.\n */\n private async *_listHealthcareEntities(\n operationId: string,\n options?: HealthcareJobStatusOptions\n ): AsyncIterableIterator<AnalyzeHealthcareEntitiesResult> {\n for await (const page of this._listHealthcareEntitiesPaged(operationId, options)) {\n yield* page;\n }\n }\n\n /**\n * returns an iterator to arrays of the results of a healthcare operation.\n */\n private async *_listHealthcareEntitiesPaged(\n operationId: string,\n options?: HealthcareJobStatusOptions\n ): AsyncIterableIterator<AnalyzeHealthcareEntitiesResultArray> {\n let response = await this._listHealthcareEntitiesSinglePage(operationId, options);\n yield response.result;\n while (response.skip) {\n const optionsWithContinuation: HealthcareJobStatusOptions = {\n ...options,\n top: response.top,\n skip: response.skip\n };\n response = await this._listHealthcareEntitiesSinglePage(operationId, optionsWithContinuation);\n yield response.result;\n }\n }\n\n /**\n * returns an iterator to arrays of the sorted results of a healthcare operation.\n */\n private async _listHealthcareEntitiesSinglePage(\n operationId: string,\n options?: HealthcareJobStatusOptions\n ): Promise<AnalyzeHealthcareEntitiesResultWithPagination> {\n const { span, updatedOptions: finalOptions } = createSpan(\n \"TextAnalyticsClient-_listHealthcareEntitiesSinglePage\",\n options || {}\n );\n try {\n const response = await this.client.healthStatus(operationId, finalOptions);\n if (response.results) {\n const result = processAndCombineSuccessfulAndErroneousDocuments(\n this.documents,\n response.results,\n makeHealthcareEntitiesResult,\n makeHealthcareEntitiesErrorResult\n );\n return response.nextLink\n ? { result, ...nextLinkToTopAndSkip(response.nextLink) }\n : { result };\n } else {\n throw new Error(\"Healthcare action has succeeded but the there are no results!\");\n }\n } catch (e) {\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: e.message\n });\n throw e;\n } finally {\n span.end();\n }\n }\n\n /**\n * returns whether the healthcare operation is done and if so returns also\n * statistics and the model version used.\n */\n private async getHealthStatus(\n operationId: string,\n options?: HealthcareJobStatusOptions\n ): Promise<HealthcareJobStatus> {\n const { span, updatedOptions: finalOptions } = createSpan(\n \"TextAnalyticsClient-getHealthStatus\",\n options || {}\n );\n try {\n const response = await this.client.healthStatus(operationId, finalOptions);\n switch (response.status) {\n case \"notStarted\":\n case \"running\":\n break;\n case \"failed\": {\n const errors = response.errors\n ?.map((e) => ` code ${e.code}, message: '${e.message}'`)\n .join(\"\\n\");\n const message = `Healthcare analysis failed. Error(s): ${errors || \"\"}`;\n throw new Error(message);\n }\n default: {\n if (response.results) {\n return {\n done: true,\n statistics: response.results.statistics,\n modelVersion: response.results.modelVersion,\n operationMetdata: getMetaInfoFromResponse(response)\n };\n } else {\n throw new Error(\"Healthcare action has finished but the there are no results!\");\n }\n }\n }\n return { done: false, operationMetdata: getMetaInfoFromResponse(response) };\n } catch (e) {\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: e.message\n });\n throw e;\n } finally {\n span.end();\n }\n }\n\n private async beginAnalyzeHealthcare(\n documents: TextDocumentInput[],\n options?: BeginAnalyzeHealthcareInternalOptions\n ): Promise<BeginAnalyzeHealthcareResponse> {\n const { span, updatedOptions: finalOptions } = createSpan(\n \"TextAnalyticsClient-beginAnalyzeHealthcare\",\n addStrEncodingParam(options || {})\n );\n\n try {\n return await this.client.health({ documents: documents }, finalOptions);\n } catch (e) {\n const exception = handleInvalidDocumentBatch(e);\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: exception.message\n });\n throw exception;\n } finally {\n span.end();\n }\n }\n\n async update(\n options: {\n abortSignal?: AbortSignalLike;\n fireProgress?: (state: AnalyzeHealthcareOperationState) => void;\n } = {}\n ): Promise<BeginAnalyzeHealthcarePollerOperation> {\n const state = this.state;\n const updatedAbortSignal = options.abortSignal;\n if (!state.isStarted) {\n state.isStarted = true;\n const response = await this.beginAnalyzeHealthcare(this.documents, {\n requestOptions: this.options.requestOptions,\n tracingOptions: this.options.tracingOptions,\n abortSignal: updatedAbortSignal ? updatedAbortSignal : options.abortSignal,\n modelVersion: this.options.modelVersion,\n stringIndexType: this.options.stringIndexType,\n loggingOptOut: this.options.disableServiceLogs\n });\n if (!response.operationLocation) {\n throw new Error(\n \"Expects a valid 'operationLocation' to retrieve health results but did not find any\"\n );\n }\n state.operationId = getOperationId(response.operationLocation);\n }\n const operationStatus = await this.getHealthStatus(state.operationId!, {\n abortSignal: updatedAbortSignal ? updatedAbortSignal : options.abortSignal,\n includeStatistics: this.options.includeStatistics,\n tracingOptions: this.options.tracingOptions,\n onResponse: this.options.onResponse,\n serializerOptions: this.options.serializerOptions\n });\n\n state.createdOn = operationStatus.operationMetdata.createdOn;\n state.expiresOn = operationStatus.operationMetdata.expiresOn;\n state.lastModifiedOn = operationStatus.operationMetdata.lastModifiedOn;\n state.status = operationStatus.operationMetdata.status;\n\n if (!state.isCompleted && operationStatus.done) {\n const pagedIterator = this.listHealthcareEntitiesByPage(state.operationId!, {\n abortSignal: this.options.abortSignal,\n tracingOptions: this.options.tracingOptions\n });\n state.result = Object.assign(pagedIterator, {\n statistics: operationStatus.statistics,\n modelVersion: operationStatus.modelVersion!\n });\n state.isCompleted = true;\n }\n if (typeof options.fireProgress === \"function\") {\n options.fireProgress(state);\n }\n return this;\n }\n\n async cancel(): Promise<BeginAnalyzeHealthcarePollerOperation> {\n const state = this.state;\n if (state.operationId) {\n await this.client.cancelHealthJob(state.operationId, {\n abortSignal: this.options.abortSignal,\n tracingOptions: this.options.tracingOptions\n });\n }\n state.isCancelled = true;\n return this;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"operation.js","sourceRoot":"","sources":["../../../../src/lro/health/operation.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;AAYlC,OAAO,EAKL,iCAAiC,EACjC,4BAA4B,GAC7B,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EAEL,mBAAmB,EACnB,cAAc,EACd,oBAAoB,EACpB,UAAU,GACX,MAAM,YAAY,CAAC;AACpB,OAAO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ACD,IAAI,OAAO,OAAO,CAAC,YAAY,KAAK,UAAU,EAAE;YAC9C,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;SAC7B;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,MAAM;QACV,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QACzB,IAAI,KAAK,CAAC,WAAW,EAAE;YACrB,MAAM,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,KAAK,CAAC,WAAW,EAAE;gBACnD,WAAW,EAAE,IAAI,CAAC,OAAO,CAAC,WAAW;gBACrC,cAAc,EAAE,IAAI,CAAC,OAAO,CAAC,cAAc;aAC5C,CAAC,CAAC;SACJ;QACD,KAAK,CAAC,WAAW,GAAG,IAAI,CAAC;QACzB,OAAO,IAAI,CAAC;IACd,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { AbortSignalLike } from \"@azure/abort-controller\";\nimport { OperationOptions } from \"@azure/core-client\";\n\nimport {\n HealthResponse as BeginAnalyzeHealthcareResponse,\n HealthcareJobState,\n HealthStatusOptionalParams as HealthcareJobStatusOptions,\n TextDocumentBatchStatistics,\n TextDocumentInput,\n} from \"../../generated/models\";\nimport {\n AnalyzeHealthcareEntitiesResult,\n AnalyzeHealthcareEntitiesResultArray,\n PagedAnalyzeHealthcareEntitiesResult,\n PagedAsyncIterableAnalyzeHealthcareEntitiesResult,\n makeHealthcareEntitiesErrorResult,\n makeHealthcareEntitiesResult,\n} from \"../../analyzeHealthcareEntitiesResult\";\nimport { PageSettings } from \"@azure/core-paging\";\nimport {\n StringIndexType,\n addStrEncodingParam,\n getOperationId,\n nextLinkToTopAndSkip,\n throwError,\n} from \"../../util\";\nimport {\n AnalysisPollOperation,\n AnalysisPollOperationState,\n OperationMetadata as AnalyzeHealthcareEntitiesOperationMetadata,\n} from \"../poller\";\nimport { GeneratedClient as Client } from \"../../generated\";\nimport { processAndCombineSuccessfulAndErroneousDocuments } from \"../../textAnalyticsResult\";\nimport { TextAnalyticsOperationOptions } from \"../../textAnalyticsOperationOptions\";\nimport { TracingClient } from \"@azure/core-tracing\";\n\n/**\n * @internal\n */\ninterface AnalyzeHealthcareEntitiesResultWithPagination {\n result: AnalyzeHealthcareEntitiesResultArray;\n top?: number;\n skip?: number;\n}\n\n/**\n * @internal\n */\ninterface HealthcareJobStatus {\n done: boolean;\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 operationMetdata: Omit<AnalyzeHealthcareEntitiesOperationMetadata, \"operationId\">;\n}\n\n/**\n * @internal\n */\ninterface BeginAnalyzeHealthcareInternalOptions extends OperationOptions {\n /**\n * This value indicates which model will be used for scoring. If a model-version is\n * not specified, the API should default to the latest, non-preview version.\n * For supported model versions, see operation-specific documentation, for example:\n * https://docs.microsoft.com/azure/cognitive-services/text-analytics/how-tos/text-analytics-how-to-sentiment-analysis#model-versioning\n */\n modelVersion?: string;\n /**\n * Specifies the measurement unit used to calculate the offset and length properties.\n * Possible units are \"TextElements_v8\", \"UnicodeCodePoint\", and \"Utf16CodeUnit\".\n * The default is the JavaScript's default which is \"Utf16CodeUnit\".\n */\n stringIndexType?: StringIndexType;\n /**\n * If set to false, you opt-in to have your text input logged for troubleshooting. By default, Text Analytics\n * will not log your input text for healthcare entities analysis. Setting this parameter to false,\n * enables input logging.\n */\n loggingOptOut?: boolean;\n}\n\n/**\n * Options for the begin analyze healthcare entities operation.\n */\nexport interface BeginAnalyzeHealthcareEntitiesOptions extends TextAnalyticsOperationOptions {\n /**\n * Delay to wait until next poll, in milliseconds.\n */\n stringIndexType?: StringIndexType;\n /**\n * Delay to wait until next poll, in milliseconds.\n */\n updateIntervalInMs?: number;\n /**\n * A serialized poller which can be used to resume an existing paused Long-Running-Operation.\n */\n resumeFrom?: string;\n}\n\n/**\n * The state of the begin analyze healthcare polling operation.\n */\nexport interface AnalyzeHealthcareOperationState\n extends AnalysisPollOperationState<PagedAnalyzeHealthcareEntitiesResult> {}\n\n/**\n * @internal\n */\nfunction getMetaInfoFromResponse(\n response: HealthcareJobState\n): Omit<AnalyzeHealthcareEntitiesOperationMetadata, \"operationId\"> {\n return {\n createdOn: response.createdDateTime,\n lastModifiedOn: response.lastUpdateDateTime,\n expiresOn: response.expirationDateTime,\n status: response.status,\n };\n}\n\n/**\n * Class that represents a poller that waits for the healthcare results.\n * @internal\n */\nexport class BeginAnalyzeHealthcarePollerOperation extends AnalysisPollOperation<\n AnalyzeHealthcareOperationState,\n PagedAnalyzeHealthcareEntitiesResult\n> {\n constructor(\n public state: AnalyzeHealthcareOperationState,\n // eslint-disable-next-line @azure/azure-sdk/ts-use-interface-parameters\n private client: Client,\n private tracing: TracingClient,\n private documents: TextDocumentInput[],\n private options: BeginAnalyzeHealthcareEntitiesOptions = {}\n ) {\n super(state);\n }\n\n /**\n * should be called only after all the status of the healthcare operations became\n * \"succeeded\" and it returns an iterator for the results and provides a\n * byPage method to return the results paged.\n */\n private listHealthcareEntitiesByPage(\n operationId: string,\n options: HealthcareJobStatusOptions = {}\n ): PagedAsyncIterableAnalyzeHealthcareEntitiesResult {\n const iter = this._listHealthcareEntities(operationId, options);\n return {\n next() {\n return iter.next();\n },\n [Symbol.asyncIterator]() {\n return this;\n },\n byPage: (settings?: PageSettings) => {\n const pageOptions = { ...options, top: settings?.maxPageSize };\n return this._listHealthcareEntitiesPaged(operationId, pageOptions);\n },\n };\n }\n\n /**\n * returns an iterator to the results of a healthcare operation.\n */\n private async *_listHealthcareEntities(\n operationId: string,\n options?: HealthcareJobStatusOptions\n ): AsyncIterableIterator<AnalyzeHealthcareEntitiesResult> {\n for await (const page of this._listHealthcareEntitiesPaged(operationId, options)) {\n yield* page;\n }\n }\n\n /**\n * returns an iterator to arrays of the results of a healthcare operation.\n */\n private async *_listHealthcareEntitiesPaged(\n operationId: string,\n options?: HealthcareJobStatusOptions\n ): AsyncIterableIterator<AnalyzeHealthcareEntitiesResultArray> {\n let response = await this._listHealthcareEntitiesSinglePage(operationId, options);\n yield response.result;\n while (response.skip) {\n const optionsWithContinuation: HealthcareJobStatusOptions = {\n ...options,\n top: response.top,\n skip: response.skip,\n };\n response = await this._listHealthcareEntitiesSinglePage(operationId, optionsWithContinuation);\n yield response.result;\n }\n }\n\n /**\n * returns an iterator to arrays of the sorted results of a healthcare operation.\n */\n private async _listHealthcareEntitiesSinglePage(\n operationId: string,\n options?: HealthcareJobStatusOptions\n ): Promise<AnalyzeHealthcareEntitiesResultWithPagination> {\n const response = await this.tracing.withSpan(\n \"TextAnalyticsClient-_listHealthcareEntitiesSinglePage\",\n options || {},\n (finalOptions) => this.client.healthStatus(operationId, finalOptions)\n );\n if (response.results) {\n const result = processAndCombineSuccessfulAndErroneousDocuments(\n this.documents,\n response.results,\n makeHealthcareEntitiesResult,\n makeHealthcareEntitiesErrorResult\n );\n return response.nextLink\n ? { result, ...nextLinkToTopAndSkip(response.nextLink) }\n : { result };\n } else {\n throw new Error(\"Healthcare action has succeeded but the there are no results!\");\n }\n }\n\n /**\n * returns whether the healthcare operation is done and if so returns also\n * statistics and the model version used.\n */\n private async getHealthStatus(\n operationId: string,\n options?: HealthcareJobStatusOptions\n ): Promise<HealthcareJobStatus> {\n const response = await this.tracing.withSpan(\n \"TextAnalyticsClient-getHealthStatus\",\n options || {},\n (finalOptions) => this.client.healthStatus(operationId, finalOptions)\n );\n switch (response.status) {\n case \"notStarted\":\n case \"running\":\n break;\n case \"failed\": {\n const errors = response.errors\n ?.map((e) => ` code ${e.code}, message: '${e.message}'`)\n .join(\"\\n\");\n const message = `Healthcare analysis failed. Error(s): ${errors || \"\"}`;\n throw new Error(message);\n }\n default: {\n if (response.results) {\n return {\n done: true,\n statistics: response.results.statistics,\n modelVersion: response.results.modelVersion,\n operationMetdata: getMetaInfoFromResponse(response),\n };\n } else {\n throw new Error(\"Healthcare action has finished but the there are no results!\");\n }\n }\n }\n return { done: false, operationMetdata: getMetaInfoFromResponse(response) };\n }\n\n private async beginAnalyzeHealthcare(\n documents: TextDocumentInput[],\n options?: BeginAnalyzeHealthcareInternalOptions\n ): Promise<BeginAnalyzeHealthcareResponse> {\n return this.tracing.withSpan(\n \"TextAnalyticsClient-beginAnalyzeHealthcare\",\n addStrEncodingParam(options || {}),\n (finalOptions) => throwError(this.client.health({ documents: documents }, finalOptions))\n );\n }\n\n async update(\n options: {\n abortSignal?: AbortSignalLike;\n fireProgress?: (state: AnalyzeHealthcareOperationState) => void;\n } = {}\n ): Promise<BeginAnalyzeHealthcarePollerOperation> {\n const state = this.state;\n const updatedAbortSignal = options.abortSignal;\n if (!state.isStarted) {\n state.isStarted = true;\n const response = await this.beginAnalyzeHealthcare(this.documents, {\n requestOptions: this.options.requestOptions,\n tracingOptions: this.options.tracingOptions,\n abortSignal: updatedAbortSignal ? updatedAbortSignal : options.abortSignal,\n modelVersion: this.options.modelVersion,\n stringIndexType: this.options.stringIndexType,\n loggingOptOut: this.options.disableServiceLogs,\n });\n if (!response.operationLocation) {\n throw new Error(\n \"Expects a valid 'operationLocation' to retrieve health results but did not find any\"\n );\n }\n state.operationId = getOperationId(response.operationLocation);\n }\n const operationStatus = await this.getHealthStatus(state.operationId!, {\n abortSignal: updatedAbortSignal ? updatedAbortSignal : options.abortSignal,\n includeStatistics: this.options.includeStatistics,\n tracingOptions: this.options.tracingOptions,\n onResponse: this.options.onResponse,\n serializerOptions: this.options.serializerOptions,\n });\n\n state.createdOn = operationStatus.operationMetdata.createdOn;\n state.expiresOn = operationStatus.operationMetdata.expiresOn;\n state.lastModifiedOn = operationStatus.operationMetdata.lastModifiedOn;\n state.status = operationStatus.operationMetdata.status;\n\n if (!state.isCompleted && operationStatus.done) {\n const pagedIterator = this.listHealthcareEntitiesByPage(state.operationId!, {\n abortSignal: this.options.abortSignal,\n tracingOptions: this.options.tracingOptions,\n });\n state.result = Object.assign(pagedIterator, {\n statistics: operationStatus.statistics,\n modelVersion: operationStatus.modelVersion!,\n });\n state.isCompleted = true;\n }\n if (typeof options.fireProgress === \"function\") {\n options.fireProgress(state);\n }\n return this;\n }\n\n async cancel(): Promise<BeginAnalyzeHealthcarePollerOperation> {\n const state = this.state;\n if (state.operationId) {\n await this.client.cancelHealthJob(state.operationId, {\n abortSignal: this.options.abortSignal,\n tracingOptions: this.options.tracingOptions,\n });\n }\n state.isCancelled = true;\n return this;\n }\n}\n"]}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Licensed under the MIT license.
|
|
3
3
|
import { delay } from "../../util";
|
|
4
4
|
import { AnalysisPoller } from "../poller";
|
|
5
|
-
import { BeginAnalyzeHealthcarePollerOperation } from "./operation";
|
|
5
|
+
import { BeginAnalyzeHealthcarePollerOperation, } from "./operation";
|
|
6
6
|
/**
|
|
7
7
|
* Class that represents a poller that waits for the healthcare results.
|
|
8
8
|
* @internal
|
|
@@ -10,12 +10,12 @@ import { BeginAnalyzeHealthcarePollerOperation } from "./operation";
|
|
|
10
10
|
export class BeginAnalyzeHealthcarePoller extends AnalysisPoller {
|
|
11
11
|
// eslint-disable-next-line @azure/azure-sdk/ts-use-interface-parameters
|
|
12
12
|
constructor(inputs) {
|
|
13
|
-
const { client, documents, options, updateIntervalInMs = 5000, resumeFrom } = inputs;
|
|
13
|
+
const { client, tracing, documents, options, updateIntervalInMs = 5000, resumeFrom } = inputs;
|
|
14
14
|
let state;
|
|
15
15
|
if (resumeFrom) {
|
|
16
16
|
state = JSON.parse(resumeFrom).state;
|
|
17
17
|
}
|
|
18
|
-
const operation = new BeginAnalyzeHealthcarePollerOperation((state || {}), client, documents, options);
|
|
18
|
+
const operation = new BeginAnalyzeHealthcarePollerOperation((state || {}), client, tracing, documents, options);
|
|
19
19
|
super(operation);
|
|
20
20
|
this.updateIntervalInMs = updateIntervalInMs;
|
|
21
21
|
}
|