@azure/ai-language-text 1.0.0-beta.1 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -53
- package/dist/index.js +198 -455
- package/dist/index.js.map +1 -1
- package/dist-esm/src/constants.js +1 -1
- package/dist-esm/src/constants.js.map +1 -1
- package/dist-esm/src/generated/generatedClient.js +2 -2
- package/dist-esm/src/generated/generatedClient.js.map +1 -1
- package/dist-esm/src/generated/models/index.js +71 -47
- package/dist-esm/src/generated/models/index.js.map +1 -1
- package/dist-esm/src/generated/models/mappers.js +16 -281
- package/dist-esm/src/generated/models/mappers.js.map +1 -1
- package/dist-esm/src/generated/models/parameters.js +1 -1
- package/dist-esm/src/generated/models/parameters.js.map +1 -1
- package/dist-esm/src/index.js +1 -1
- package/dist-esm/src/index.js.map +1 -1
- package/dist-esm/src/lro.js +19 -24
- package/dist-esm/src/lro.js.map +1 -1
- package/dist-esm/src/models.js +0 -9
- package/dist-esm/src/models.js.map +1 -1
- package/dist-esm/src/textAnalysisClient.js +41 -26
- package/dist-esm/src/textAnalysisClient.js.map +1 -1
- package/dist-esm/src/transforms.js +38 -43
- package/dist-esm/src/transforms.js.map +1 -1
- package/dist-esm/src/util.js +7 -8
- package/dist-esm/src/util.js.map +1 -1
- package/package.json +3 -3
- package/types/ai-language-text.d.ts +63 -148
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"parameters.js","sourceRoot":"","sources":["../../../../src/generated/models/parameters.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAOH,OAAO,EACL,aAAa,IAAI,mBAAmB,EACpC,oBAAoB,IAAI,0BAA0B,EACnD,MAAM,mBAAmB,CAAC;AAE3B,MAAM,CAAC,MAAM,WAAW,GAAuB;IAC7C,aAAa,EAAE,CAAC,SAAS,EAAE,aAAa,CAAC;IACzC,MAAM,EAAE;QACN,YAAY,EAAE,kBAAkB;QAChC,UAAU,EAAE,IAAI;QAChB,cAAc,EAAE,cAAc;QAC9B,IAAI,EAAE;YACJ,IAAI,EAAE,QAAQ;SACf;KACF;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,IAAI,GAAuB;IACtC,aAAa,EAAE,MAAM;IACrB,MAAM,EAAE,mBAAmB;CAC5B,CAAC;AAEF,MAAM,CAAC,MAAM,MAAM,GAAuB;IACxC,aAAa,EAAE,QAAQ;IACvB,MAAM,EAAE;QACN,YAAY,EAAE,kBAAkB;QAChC,UAAU,EAAE,IAAI;QAChB,cAAc,EAAE,QAAQ;QACxB,IAAI,EAAE;YACJ,IAAI,EAAE,QAAQ;SACf;KACF;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,QAAQ,GAA0B;IAC7C,aAAa,EAAE,UAAU;IACzB,MAAM,EAAE;QACN,cAAc,EAAE,UAAU;QAC1B,QAAQ,EAAE,IAAI;QACd,IAAI,EAAE;YACJ,IAAI,EAAE,QAAQ;SACf;KACF;IACD,YAAY,EAAE,IAAI;CACnB,CAAC;AAEF,MAAM,CAAC,MAAM,UAAU,GAA4B;IACjD,aAAa,EAAE,YAAY;IAC3B,MAAM,EAAE;QACN,YAAY,EAAE,
|
1
|
+
{"version":3,"file":"parameters.js","sourceRoot":"","sources":["../../../../src/generated/models/parameters.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAOH,OAAO,EACL,aAAa,IAAI,mBAAmB,EACpC,oBAAoB,IAAI,0BAA0B,EACnD,MAAM,mBAAmB,CAAC;AAE3B,MAAM,CAAC,MAAM,WAAW,GAAuB;IAC7C,aAAa,EAAE,CAAC,SAAS,EAAE,aAAa,CAAC;IACzC,MAAM,EAAE;QACN,YAAY,EAAE,kBAAkB;QAChC,UAAU,EAAE,IAAI;QAChB,cAAc,EAAE,cAAc;QAC9B,IAAI,EAAE;YACJ,IAAI,EAAE,QAAQ;SACf;KACF;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,IAAI,GAAuB;IACtC,aAAa,EAAE,MAAM;IACrB,MAAM,EAAE,mB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AE,KAAK,CAAC;IACjC,MAAM,EAAE;QACN,cAAc,EAAE,KAAK;QACrB,IAAI,EAAE;YACJ,IAAI,EAAE,QAAQ;SACf;KACF;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,IAAI,GAA4B;IAC3C,aAAa,EAAE,CAAC,SAAS,EAAE,MAAM,CAAC;IAClC,MAAM,EAAE;QACN,cAAc,EAAE,MAAM;QACtB,IAAI,EAAE;YACJ,IAAI,EAAE,QAAQ;SACf;KACF;CACF,CAAC","sourcesContent":["/*\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n *\n * Code generated by Microsoft (R) AutoRest Code Generator.\n * Changes may cause incorrect behavior and will be lost if the code is regenerated.\n */\n\nimport {\n OperationParameter,\n OperationURLParameter,\n OperationQueryParameter\n} from \"@azure/core-client\";\nimport {\n AnalyzeAction as AnalyzeActionMapper,\n AnalyzeTextJobsInput as AnalyzeTextJobsInputMapper\n} from \"../models/mappers\";\n\nexport const contentType: OperationParameter = {\n parameterPath: [\"options\", \"contentType\"],\n mapper: {\n defaultValue: \"application/json\",\n isConstant: true,\n serializedName: \"Content-Type\",\n type: {\n name: \"String\"\n }\n }\n};\n\nexport const body: OperationParameter = {\n parameterPath: \"body\",\n mapper: AnalyzeActionMapper\n};\n\nexport const accept: OperationParameter = {\n parameterPath: \"accept\",\n mapper: {\n defaultValue: \"application/json\",\n isConstant: true,\n serializedName: \"Accept\",\n type: {\n name: \"String\"\n }\n }\n};\n\nexport const endpoint: OperationURLParameter = {\n parameterPath: \"endpoint\",\n mapper: {\n serializedName: \"Endpoint\",\n required: true,\n type: {\n name: \"String\"\n }\n },\n skipEncoding: true\n};\n\nexport const apiVersion: OperationQueryParameter = {\n parameterPath: \"apiVersion\",\n mapper: {\n defaultValue: \"2022-05-01\",\n isConstant: true,\n serializedName: \"api-version\",\n type: {\n name: \"String\"\n }\n }\n};\n\nexport const includeStatistics: OperationQueryParameter = {\n parameterPath: [\"options\", \"includeStatistics\"],\n mapper: {\n serializedName: \"showStats\",\n type: {\n name: \"Boolean\"\n }\n }\n};\n\nexport const body1: OperationParameter = {\n parameterPath: \"body\",\n mapper: AnalyzeTextJobsInputMapper\n};\n\nexport const jobId: OperationURLParameter = {\n parameterPath: \"jobId\",\n mapper: {\n serializedName: \"jobId\",\n required: true,\n type: {\n name: \"Uuid\"\n }\n }\n};\n\nexport const top: OperationQueryParameter = {\n parameterPath: [\"options\", \"top\"],\n mapper: {\n serializedName: \"top\",\n type: {\n name: \"Number\"\n }\n }\n};\n\nexport const skip: OperationQueryParameter = {\n parameterPath: [\"options\", \"skip\"],\n mapper: {\n serializedName: \"skip\",\n type: {\n name: \"Number\"\n }\n }\n};\n"]}
|
package/dist-esm/src/index.js
CHANGED
@@ -14,5 +14,5 @@ export { TextAnalysisClient } from "./textAnalysisClient";
|
|
14
14
|
export * from "./models";
|
15
15
|
export {
|
16
16
|
/** orphan exports */
|
17
|
-
KnownPiiEntityDomain, KnownPiiEntityCategory, KnownStringIndexType, KnownErrorCode, KnownInnerErrorCode,
|
17
|
+
KnownPiiEntityDomain, KnownPiiEntityCategory, KnownStringIndexType, KnownErrorCode, KnownInnerErrorCode, } from "./generated/models";
|
18
18
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC;;;;;;;;GAQG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,cAAc,UAAU,CAAC;AACzB,OAAO;
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC;;;;;;;;GAQG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,cAAc,UAAU,CAAC;AACzB,OAAO;AAwCL,qBAAqB;AACrB,oBAAoB,EACpB,sBAAsB,EACtB,oBAAoB,EACpB,cAAc,EACd,mBAAmB,GAEpB,MAAM,oBAAoB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * [Azure Cognitive Language Services](https://docs.microsoft.com/azure/cognitive-services/language-service/overview)\n * is a suite of natural language processing (NLP) skills built with\n * best-in-class Microsoft machine learning algorithms used to analyze\n * unstructured text for actions such as sentiment analysis, key phrase\n * extraction, and language detection.\n *\n * @packageDocumentation\n */\n\nexport { AzureKeyCredential } from \"@azure/core-auth\";\n\nexport { TextAnalysisClient } from \"./textAnalysisClient\";\nexport * from \"./models\";\nexport {\n AssessmentSentiment,\n SentimentAnalysisAction,\n EntityLinkingAction,\n EntityRecognitionAction,\n KeyPhraseExtractionAction,\n LanguageDetectionAction,\n PiiEntityRecognitionAction,\n StringIndexType,\n LinkedEntity,\n Entity,\n DetectedLanguage,\n PiiEntityCategory,\n PiiEntityDomain,\n SentimentConfidenceScores,\n SentenceSentimentLabel,\n DocumentSentimentLabel,\n TargetConfidenceScores,\n TokenSentimentLabel,\n LanguageDetectionInput,\n TextDocumentInput,\n TextDocumentStatistics,\n DocumentWarning,\n WarningCode,\n Match,\n ActionCommon,\n ActionPrebuilt,\n HealthcareAction,\n CustomEntityRecognitionAction,\n CustomSingleLabelClassificationAction,\n CustomMultiLabelClassificationAction,\n ActionCustom,\n ClassificationCategory,\n HealthcareAssertion,\n HealthcareEntityCategory,\n EntityDataSource,\n RelationType,\n EntityAssociation,\n EntityCertainty,\n EntityConditionality,\n /** orphan exports */\n KnownPiiEntityDomain,\n KnownPiiEntityCategory,\n KnownStringIndexType,\n KnownErrorCode,\n KnownInnerErrorCode,\n TextDocumentBatchStatistics,\n} from \"./generated/models\";\n"]}
|
package/dist-esm/src/lro.js
CHANGED
@@ -24,7 +24,7 @@ const jobStatusOperationSpec = {
|
|
24
24
|
};
|
25
25
|
async function getRawResponse(getResponse, options) {
|
26
26
|
const { onResponse } = options || {};
|
27
|
-
let rawResponse
|
27
|
+
let rawResponse;
|
28
28
|
const flatResponse = await getResponse(Object.assign(Object.assign({}, options), { onResponse: (response, flatResponseParam) => {
|
29
29
|
rawResponse = response;
|
30
30
|
onResponse === null || onResponse === void 0 ? void 0 : onResponse(response, flatResponseParam);
|
@@ -46,7 +46,7 @@ async function sendRequest(settings) {
|
|
46
46
|
/**
|
47
47
|
* @internal
|
48
48
|
*/
|
49
|
-
|
49
|
+
function createSendPollRequest(settings) {
|
50
50
|
const { client, options, tracing, spanStr } = settings;
|
51
51
|
return async (path) => {
|
52
52
|
return throwError(sendRequest({
|
@@ -65,8 +65,6 @@ export function createSendPollRequest(settings) {
|
|
65
65
|
export function createAnalyzeBatchLro(settings) {
|
66
66
|
const { client, commonOptions, documents, initialRequestOptions, pollRequestOptions, tasks, tracing, } = settings;
|
67
67
|
return {
|
68
|
-
requestMethod: "POST",
|
69
|
-
requestPath: "/analyze-text/jobs",
|
70
68
|
async sendInitialRequest() {
|
71
69
|
return tracing.withSpan(`${clientName}.beginAnalyzeBatch`, Object.assign(Object.assign({}, commonOptions), initialRequestOptions), async (finalOptions) => throwError(getRawResponse((paramOptions) => client.analyzeText.submitJob({
|
72
70
|
tasks,
|
@@ -87,13 +85,13 @@ export function createAnalyzeBatchLro(settings) {
|
|
87
85
|
/**
|
88
86
|
* @internal
|
89
87
|
*/
|
90
|
-
export function
|
88
|
+
export function getDocIDsFromState(serializedState) {
|
91
89
|
try {
|
92
|
-
const {
|
93
|
-
return
|
90
|
+
const { docIds } = JSON.parse(serializedState).state;
|
91
|
+
return docIds;
|
94
92
|
}
|
95
93
|
catch (e) {
|
96
|
-
logger.error(`
|
94
|
+
logger.error(`Document IDs are not found in the LRO's state. The results may not be ordered correctly.`);
|
97
95
|
return [];
|
98
96
|
}
|
99
97
|
}
|
@@ -103,8 +101,6 @@ export function getDocsFromState(serializedState) {
|
|
103
101
|
export function createCreateAnalyzeBatchPollerLro(settings) {
|
104
102
|
const { client, options, tracing } = settings;
|
105
103
|
return {
|
106
|
-
requestMethod: "POST",
|
107
|
-
requestPath: "/analyze-text/jobs",
|
108
104
|
async sendInitialRequest() {
|
109
105
|
throw new Error(`The operation has already started`);
|
110
106
|
},
|
@@ -120,9 +116,9 @@ export function createCreateAnalyzeBatchPollerLro(settings) {
|
|
120
116
|
* @internal
|
121
117
|
*/
|
122
118
|
export function processAnalyzeResult(options) {
|
123
|
-
return (
|
124
|
-
const { client,
|
125
|
-
const pageURL =
|
119
|
+
return () => {
|
120
|
+
const { client, docIds, opOptions, tracing, state } = options;
|
121
|
+
const pageURL = state.continuationToken;
|
126
122
|
const pagedResult = {
|
127
123
|
firstPageLink: pageURL,
|
128
124
|
getPage: async (pageLink, maxPageSize) => {
|
@@ -138,7 +134,7 @@ export function processAnalyzeResult(options) {
|
|
138
134
|
});
|
139
135
|
const flatResponse = response.flatResponse;
|
140
136
|
return {
|
141
|
-
page: transformAnalyzeBatchResults(
|
137
|
+
page: transformAnalyzeBatchResults(docIds, flatResponse.tasks.items),
|
142
138
|
nextPageLink: flatResponse.nextLink,
|
143
139
|
};
|
144
140
|
},
|
@@ -149,31 +145,30 @@ export function processAnalyzeResult(options) {
|
|
149
145
|
/**
|
150
146
|
* @internal
|
151
147
|
*/
|
152
|
-
export function createUpdateAnalyzeState(
|
148
|
+
export function createUpdateAnalyzeState(docIds) {
|
153
149
|
return (state, lastResponse) => {
|
154
|
-
const { createdOn, modifiedOn, id,
|
150
|
+
const { createdOn, modifiedOn, id, displayName, expiresOn, tasks } = lastResponse.flatResponse;
|
155
151
|
const mutableState = state;
|
156
152
|
mutableState.createdOn = createdOn;
|
157
153
|
mutableState.modifiedOn = modifiedOn;
|
158
154
|
mutableState.expiresOn = expiresOn;
|
159
155
|
mutableState.displayName = displayName;
|
160
156
|
mutableState.id = id;
|
161
|
-
mutableState.status = status;
|
162
157
|
mutableState.actionSucceededCount = tasks.completed;
|
163
158
|
mutableState.actionFailedCount = tasks.failed;
|
164
159
|
mutableState.actionInProgressCount = tasks.inProgress;
|
165
|
-
if (mutableState.
|
166
|
-
mutableState.
|
160
|
+
if (mutableState.docIds === undefined && docIds !== undefined) {
|
161
|
+
mutableState.docIds = docIds;
|
167
162
|
}
|
168
163
|
};
|
169
164
|
}
|
170
165
|
/**
|
171
166
|
* @internal
|
172
167
|
*/
|
173
|
-
export function
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
168
|
+
export function createPollerWithCancellation(settings) {
|
169
|
+
const { client, options, poller, id, tracing } = settings;
|
170
|
+
return Object.assign(Object.assign({}, poller), { sendCancellationRequest: async () => {
|
171
|
+
await tracing.withSpan(`${clientName}.beginAnalyzeBatch`, options, async (finalOptions) => throwError(getRawResponse((paramOptions) => client.analyzeText.cancelJob(id, paramOptions), finalOptions)));
|
172
|
+
} });
|
178
173
|
}
|
179
174
|
//# sourceMappingURL=lro.js.map
|
package/dist-esm/src/lro.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"lro.js","sourceRoot":"","sources":["../../src/lro.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,KAAK,OAAO,MAAM,4BAA4B,CAAC;AACtD,OAAO,KAAK,UAAU,MAAM,+BAA+B,CAAC;AAS5D,OAAO,EAIL,gBAAgB,GACjB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAe,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AACxE,OAAO,EAAE,UAAU,EAAE,4BAA4B,EAAE,MAAM,cAAc,CAAC;AAGxE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,MAAM,UAAU,GAAG,gBAAgB,CAAC,OAAO,EAAE,WAAW,CAAC,KAAK,CAAC,CAAC;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CAAC;QAC9C,YAAY,CAAC,qBAAqB,GAAG,KAAK,CAAC,UAAU,CAAC;QACtD,IAAI,YAAY,CAAC,SAAS,KAAK,SAAS,IAAI,SAAS,KAAK,SAAS,EAAE;YACnE,YAAY,CAAC,SAAS,GAAG,SAAS,CAAC;SACpC;IACH,CAAC,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,qBAAqB,CAAC,QAIrC;IACC,OAAO,KAAK,EAAE,EAAE,EAAE,EAAE,EAAiB,EAAE;QACrC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,QAAQ,CAAC;QAC9C,MAAM,OAAO,CAAC,QAAQ,CAAC,GAAG,UAAU,oBAAoB,EAAE,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,EAAE,CACxF,UAAU,CACR,cAAc,CACZ,CAAC,YAAY,EAAE,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,EAAE,EAAE,YAAY,CAAC,EAChE,YAAY,CACb,CACF,CACF,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport * as Mappers from \"./generated/models/mappers\";\nimport * as Parameters from \"./generated/models/parameters\";\nimport {\n AnalyzeBatchActionUnion,\n AnalyzeTextJobStatusOptionalParams,\n AnalyzeTextJobStatusResponse,\n GeneratedClient,\n TextDocumentInput,\n} from \"./generated\";\nimport { AnalyzeBatchOperationState, AnalyzeBatchResult, PagedAnalyzeBatchResult } from \"./models\";\nimport {\n FullOperationResponse,\n OperationOptions,\n OperationSpec,\n createSerializer,\n} from \"@azure/core-client\";\nimport { LongRunningOperation, LroResponse, RawResponse } from \"@azure/core-lro\";\nimport { PagedResult, getPagedAsyncIterator } from \"@azure/core-paging\";\nimport { throwError, transformAnalyzeBatchResults } from \"./transforms\";\nimport { HttpMethods } from \"@azure/core-rest-pipeline\";\nimport { TracingClient } from \"@azure/core-tracing\";\nimport { clientName } from \"./constants\";\nimport { logger } from \"./logger\";\n\nconst serializer = createSerializer(Mappers, /* isXml */ false);\n\nconst jobStatusOperationSpec: OperationSpec = {\n httpMethod: \"GET\",\n responses: {\n 200: {\n bodyMapper: Mappers.AnalyzeTextJobState,\n },\n default: {\n bodyMapper: Mappers.ErrorResponse,\n },\n },\n headerParameters: [Parameters.accept],\n queryParameters: [Parameters.top, Parameters.skip, Parameters.includeStatistics],\n serializer,\n};\n\nasync function getRawResponse<TOptions extends OperationOptions, TResponse>(\n getResponse: (options: TOptions) => Promise<TResponse>,\n options: TOptions\n): Promise<LroResponse<TResponse>> {\n const { onResponse } = options || {};\n let rawResponse: FullOperationResponse | undefined = undefined;\n const flatResponse = await getResponse({\n ...options,\n onResponse: (response: FullOperationResponse, flatResponseParam: unknown) => {\n rawResponse = response;\n onResponse?.(response, flatResponseParam);\n },\n });\n return {\n flatResponse,\n rawResponse: {\n statusCode: rawResponse!.status,\n headers: rawResponse!.headers.toJSON(),\n body: rawResponse!.parsedBody,\n },\n };\n}\n\nasync function sendRequest<TOptions extends OperationOptions>(settings: {\n client: GeneratedClient;\n tracing: TracingClient;\n spec: OperationSpec;\n spanStr: string;\n opOptions: TOptions;\n path: string;\n httpMethod?: HttpMethods;\n}): Promise<LroResponse<unknown>> {\n const { client, opOptions, path, spanStr, spec, tracing, httpMethod = \"GET\" } = settings;\n return tracing.withSpan(spanStr, opOptions, async (finalOptions: TOptions) =>\n throwError(\n getRawResponse(\n (options) =>\n client.sendOperationRequest(\n { options },\n {\n ...spec,\n path,\n httpMethod,\n }\n ),\n finalOptions\n )\n )\n );\n}\n\n/**\n * @internal\n */\nexport function createSendPollRequest<TOptions extends OperationOptions>(settings: {\n client: GeneratedClient;\n tracing: TracingClient;\n options: TOptions;\n spanStr: string;\n}): (path: string) => Promise<LroResponse<unknown>> {\n const { client, options, tracing, spanStr } = settings;\n return async (path: string): Promise<LroResponse<unknown>> => {\n return throwError(\n sendRequest({\n client,\n opOptions: options,\n path,\n spanStr,\n spec: jobStatusOperationSpec,\n tracing,\n })\n );\n };\n}\n\n/**\n * @internal\n */\nexport function createAnalyzeBatchLro(settings: {\n client: GeneratedClient;\n tracing: TracingClient;\n commonOptions: OperationOptions;\n initialRequestOptions: {\n displayName?: string;\n };\n pollRequestOptions: {\n includeStatistics?: boolean;\n };\n documents: TextDocumentInput[];\n tasks: AnalyzeBatchActionUnion[];\n}): LongRunningOperation<unknown> {\n const {\n client,\n commonOptions,\n documents,\n initialRequestOptions,\n pollRequestOptions,\n tasks,\n tracing,\n } = settings;\n return {\n requestMethod: \"POST\",\n requestPath: \"/analyze-text/jobs\",\n async sendInitialRequest(): Promise<LroResponse<unknown>> {\n return tracing.withSpan(\n `${clientName}.beginAnalyzeBatch`,\n {\n ...commonOptions,\n ...initialRequestOptions,\n },\n async (finalOptions) =>\n throwError(\n getRawResponse(\n (paramOptions) =>\n client.analyzeText.submitJob(\n {\n tasks,\n analysisInput: {\n documents,\n },\n displayName: initialRequestOptions.displayName,\n },\n paramOptions\n ),\n finalOptions\n )\n )\n );\n },\n sendPollRequest: createSendPollRequest({\n client,\n options: { ...commonOptions, ...pollRequestOptions },\n spanStr: `${clientName}.beginAnalyzeBatch`,\n tracing,\n }),\n };\n}\n\n/**\n * @internal\n */\nexport function getDocsFromState(serializedState: string): TextDocumentInput[] {\n try {\n const { documents } = JSON.parse(serializedState).state;\n return documents;\n } catch (e) {\n logger.error(\n `Documents are not found in the LRO's state. The results may not be ordered correctly.`\n );\n return [];\n }\n}\n\n/**\n * @internal\n */\nexport function createCreateAnalyzeBatchPollerLro<OptionsT extends OperationOptions>(settings: {\n client: GeneratedClient;\n tracing: TracingClient;\n options: OptionsT;\n}): LongRunningOperation<unknown> {\n const { client, options, tracing } = settings;\n return {\n requestMethod: \"POST\",\n requestPath: \"/analyze-text/jobs\",\n async sendInitialRequest(): Promise<LroResponse<unknown>> {\n throw new Error(`The operation has already started`);\n },\n sendPollRequest: createSendPollRequest({\n client,\n options,\n spanStr: `${clientName}.beginAnalyzeBatch`,\n tracing,\n }),\n };\n}\n\n/**\n * @internal\n */\nexport function processAnalyzeResult(options: {\n client: GeneratedClient;\n tracing: TracingClient;\n documents: TextDocumentInput[];\n opOptions: AnalyzeTextJobStatusOptionalParams;\n continuationToken?: string;\n}): (result: unknown, state: AnalyzeBatchOperationState) => PagedAnalyzeBatchResult {\n return (_result: unknown, state: AnalyzeBatchOperationState): PagedAnalyzeBatchResult => {\n const { client, documents, opOptions, tracing, continuationToken } = options;\n const pageURL = continuationToken ?? (state as any).pollingURL;\n const pagedResult: PagedResult<AnalyzeBatchResult[]> = {\n firstPageLink: pageURL,\n getPage: async (pageLink: string, maxPageSize?: number) => {\n const response = await sendRequest({\n client,\n spec: jobStatusOperationSpec,\n spanStr: `${clientName}.beginAnalyzeBatch`,\n // if `top` is set to `undefined`, the default value will not be sent\n // as part of the request.\n opOptions: maxPageSize ? { ...opOptions, top: maxPageSize } : opOptions,\n path: pageLink,\n tracing,\n });\n const flatResponse = response.flatResponse as AnalyzeTextJobStatusResponse;\n return {\n page: transformAnalyzeBatchResults(documents, flatResponse.tasks.items),\n nextPageLink: flatResponse.nextLink,\n };\n },\n };\n return getPagedAsyncIterator(pagedResult);\n };\n}\n\ntype Writable<T> = {\n -readonly [P in keyof T]: T[P];\n};\n\n/**\n * @internal\n */\nexport function createUpdateAnalyzeState(documents?: TextDocumentInput[]) {\n return (state: AnalyzeBatchOperationState, lastResponse: RawResponse): void => {\n const { createdOn, modifiedOn, id, status, displayName, expiresOn, tasks } =\n lastResponse.body as AnalyzeTextJobStatusResponse;\n const mutableState = state as Writable<AnalyzeBatchOperationState> & {\n documents?: TextDocumentInput[];\n };\n mutableState.createdOn = createdOn;\n mutableState.modifiedOn = modifiedOn;\n mutableState.expiresOn = expiresOn;\n mutableState.displayName = displayName;\n mutableState.id = id;\n mutableState.status = status;\n mutableState.actionSucceededCount = tasks.completed;\n mutableState.actionFailedCount = tasks.failed;\n mutableState.actionInProgressCount = tasks.inProgress;\n if (mutableState.documents === undefined && documents !== undefined) {\n mutableState.documents = documents;\n }\n };\n}\n\n/**\n * @internal\n */\nexport function createCancelOperation(settings: {\n client: GeneratedClient;\n tracing: TracingClient;\n options: AnalyzeTextJobStatusOptionalParams;\n}): (state: AnalyzeBatchOperationState) => Promise<void> {\n return async ({ id }): Promise<void> => {\n const { client, options, tracing } = settings;\n await tracing.withSpan(`${clientName}.beginAnalyzeBatch`, options, async (finalOptions) =>\n throwError(\n getRawResponse(\n (paramOptions) => client.analyzeText.cancelJob(id, paramOptions),\n finalOptions\n )\n )\n );\n };\n}\n"]}
|
1
|
+
{"version":3,"file":"lro.js","sourceRoot":"","sources":["../../src/lro.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,KAAK,OAAO,MAAM,4BAA4B,CAAC;AACtD,OAAO,KAAK,UAAU,MAAM,+BAA+B,CAAC;AAc5D,OAAO,EAIL,gBAAgB,GACjB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAe,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AACxE,OAAO,EAAE,UAAU,EAAE,4BAA4B,EAAE,MAAM,cAAc,CAAC;AAGxE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,MAAM,UAAU,GAAG,gBAAgB,CAAC,OAAO,EAAE,WAAW,CAAC,KAAK,CAAC,CAAC;AAEhE,MAAM,sBAAsB,GAAkB;IAC5C,UAAU,EAAE,KAAK;IACjB,SAAS,EAAE;QACT,GAAG,EAAE;YACH,UAAU,EAAE,OAAO,CAAC,mBAAmB;SACxC;QACD,OAAO,EAAE;YACP,UAAU,EAAE,OAAO,CAAC,aAAa;SAClC;KACF;IACD,gBAAgB,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC;IACrC,eAAe,EAAE,CAAC,UAAU,CAAC,GAAG,EAAE,UAAU,CAAC,IAAI,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,YAAY,EAAE,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,EAAE,EAAE,YAAY,CAAC,EAChE,YAAY,CACb,CACF,CACF,CAAC;QACJ,CAAC,IACD;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport * as Mappers from \"./generated/models/mappers\";\nimport * as Parameters from \"./generated/models/parameters\";\nimport {\n AnalyzeBatchActionUnion,\n AnalyzeTextJobStatusOptionalParams,\n AnalyzeTextJobStatusResponse,\n GeneratedClient,\n TextDocumentInput,\n} from \"./generated\";\nimport {\n AnalyzeBatchOperationState,\n AnalyzeBatchResult,\n PagedAnalyzeBatchResult,\n PollerLike,\n} from \"./models\";\nimport {\n FullOperationResponse,\n OperationOptions,\n OperationSpec,\n createSerializer,\n} from \"@azure/core-client\";\nimport { LongRunningOperation, LroResponse, SimplePollerLike } from \"@azure/core-lro\";\nimport { PagedResult, getPagedAsyncIterator } from \"@azure/core-paging\";\nimport { throwError, transformAnalyzeBatchResults } from \"./transforms\";\nimport { HttpMethods } from \"@azure/core-rest-pipeline\";\nimport { TracingClient } from \"@azure/core-tracing\";\nimport { clientName } from \"./constants\";\nimport { logger } from \"./logger\";\n\nconst serializer = createSerializer(Mappers, /* isXml */ false);\n\nconst jobStatusOperationSpec: OperationSpec = {\n httpMethod: \"GET\",\n responses: {\n 200: {\n bodyMapper: Mappers.AnalyzeTextJobState,\n },\n default: {\n bodyMapper: Mappers.ErrorResponse,\n },\n },\n headerParameters: [Parameters.accept],\n queryParameters: [Parameters.top, Parameters.skip, Parameters.includeStatistics],\n serializer,\n};\n\nasync function getRawResponse<TOptions extends OperationOptions, TResponse>(\n getResponse: (options: TOptions) => Promise<TResponse>,\n options: TOptions\n): Promise<LroResponse<TResponse>> {\n const { onResponse } = options || {};\n let rawResponse: FullOperationResponse;\n const flatResponse = await getResponse({\n ...options,\n onResponse: (response, flatResponseParam) => {\n rawResponse = response;\n onResponse?.(response, flatResponseParam);\n },\n });\n return {\n flatResponse,\n rawResponse: {\n statusCode: rawResponse!.status,\n headers: rawResponse!.headers.toJSON(),\n body: rawResponse!.parsedBody,\n },\n };\n}\n\nasync function sendRequest<TOptions extends OperationOptions>(settings: {\n client: GeneratedClient;\n tracing: TracingClient;\n spec: OperationSpec;\n spanStr: string;\n opOptions: TOptions;\n path: string;\n httpMethod?: HttpMethods;\n}): Promise<LroResponse<unknown>> {\n const { client, opOptions, path, spanStr, spec, tracing, httpMethod = \"GET\" } = settings;\n return tracing.withSpan(spanStr, opOptions, async (finalOptions: TOptions) =>\n throwError(\n getRawResponse(\n (options) =>\n client.sendOperationRequest(\n { options },\n {\n ...spec,\n path,\n httpMethod,\n }\n ),\n finalOptions\n )\n )\n );\n}\n\n/**\n * @internal\n */\nfunction createSendPollRequest<TOptions extends OperationOptions>(settings: {\n client: GeneratedClient;\n tracing: TracingClient;\n options: TOptions;\n spanStr: string;\n}): (path: string) => Promise<LroResponse<unknown>> {\n const { client, options, tracing, spanStr } = settings;\n return async (path: string): Promise<LroResponse<unknown>> => {\n return throwError(\n sendRequest({\n client,\n opOptions: options,\n path,\n spanStr,\n spec: jobStatusOperationSpec,\n tracing,\n })\n );\n };\n}\n\n/**\n * @internal\n */\nexport function createAnalyzeBatchLro(settings: {\n client: GeneratedClient;\n tracing: TracingClient;\n commonOptions: OperationOptions;\n initialRequestOptions: {\n displayName?: string;\n };\n pollRequestOptions: {\n includeStatistics?: boolean;\n };\n documents: TextDocumentInput[];\n tasks: AnalyzeBatchActionUnion[];\n}): LongRunningOperation {\n const {\n client,\n commonOptions,\n documents,\n initialRequestOptions,\n pollRequestOptions,\n tasks,\n tracing,\n } = settings;\n return {\n async sendInitialRequest(): Promise<LroResponse<unknown>> {\n return tracing.withSpan(\n `${clientName}.beginAnalyzeBatch`,\n {\n ...commonOptions,\n ...initialRequestOptions,\n },\n async (finalOptions) =>\n throwError(\n getRawResponse(\n (paramOptions) =>\n client.analyzeText.submitJob(\n {\n tasks,\n analysisInput: {\n documents,\n },\n displayName: initialRequestOptions.displayName,\n },\n paramOptions\n ),\n finalOptions\n )\n )\n );\n },\n sendPollRequest: createSendPollRequest({\n client,\n options: { ...commonOptions, ...pollRequestOptions },\n spanStr: `${clientName}.beginAnalyzeBatch`,\n tracing,\n }),\n };\n}\n\n/**\n * @internal\n */\nexport function getDocIDsFromState(serializedState: string): string[] {\n try {\n const { docIds } = JSON.parse(serializedState).state;\n return docIds;\n } catch (e) {\n logger.error(\n `Document IDs are not found in the LRO's state. The results may not be ordered correctly.`\n );\n return [];\n }\n}\n\n/**\n * @internal\n */\nexport function createCreateAnalyzeBatchPollerLro<OptionsT extends OperationOptions>(settings: {\n client: GeneratedClient;\n tracing: TracingClient;\n options: OptionsT;\n}): LongRunningOperation {\n const { client, options, tracing } = settings;\n return {\n async sendInitialRequest(): Promise<LroResponse<unknown>> {\n throw new Error(`The operation has already started`);\n },\n sendPollRequest: createSendPollRequest({\n client,\n options,\n spanStr: `${clientName}.beginAnalyzeBatch`,\n tracing,\n }),\n };\n}\n\n/**\n * @internal\n */\nexport function processAnalyzeResult(options: {\n client: GeneratedClient;\n tracing: TracingClient;\n docIds: string[];\n opOptions: AnalyzeTextJobStatusOptionalParams;\n state: { continuationToken: string };\n}): (result: unknown, state: AnalyzeBatchOperationState) => PagedAnalyzeBatchResult {\n return (): PagedAnalyzeBatchResult => {\n const { client, docIds, opOptions, tracing, state } = options;\n const pageURL = state.continuationToken;\n const pagedResult: PagedResult<AnalyzeBatchResult[]> = {\n firstPageLink: pageURL,\n getPage: async (pageLink: string, maxPageSize?: number) => {\n const response = await sendRequest({\n client,\n spec: jobStatusOperationSpec,\n spanStr: `${clientName}.beginAnalyzeBatch`,\n // if `top` is set to `undefined`, the default value will not be sent\n // as part of the request.\n opOptions: maxPageSize ? { ...opOptions, top: maxPageSize } : opOptions,\n path: pageLink,\n tracing,\n });\n const flatResponse = response.flatResponse as AnalyzeTextJobStatusResponse;\n return {\n page: transformAnalyzeBatchResults(docIds, flatResponse.tasks.items),\n nextPageLink: flatResponse.nextLink,\n };\n },\n };\n return getPagedAsyncIterator(pagedResult);\n };\n}\n\ntype Writable<T> = {\n -readonly [P in keyof T]: T[P];\n};\n\n/**\n * @internal\n */\nexport function createUpdateAnalyzeState(docIds?: string[]) {\n return (state: AnalyzeBatchOperationState, lastResponse: LroResponse): void => {\n const { createdOn, modifiedOn, id, displayName, expiresOn, tasks } =\n lastResponse.flatResponse as AnalyzeTextJobStatusResponse;\n const mutableState = state as Writable<AnalyzeBatchOperationState> & {\n docIds?: string[];\n };\n mutableState.createdOn = createdOn;\n mutableState.modifiedOn = modifiedOn;\n mutableState.expiresOn = expiresOn;\n mutableState.displayName = displayName;\n mutableState.id = id;\n mutableState.actionSucceededCount = tasks.completed;\n mutableState.actionFailedCount = tasks.failed;\n mutableState.actionInProgressCount = tasks.inProgress;\n if (mutableState.docIds === undefined && docIds !== undefined) {\n mutableState.docIds = docIds;\n }\n };\n}\n\n/**\n * @internal\n */\nexport function createPollerWithCancellation(settings: {\n poller: SimplePollerLike<AnalyzeBatchOperationState, PagedAnalyzeBatchResult>;\n client: GeneratedClient;\n tracing: TracingClient;\n options: AnalyzeTextJobStatusOptionalParams;\n id: string;\n}): PollerLike<AnalyzeBatchOperationState, PagedAnalyzeBatchResult> {\n const { client, options, poller, id, tracing } = settings;\n return {\n ...poller,\n sendCancellationRequest: async () => {\n await tracing.withSpan(`${clientName}.beginAnalyzeBatch`, options, async (finalOptions) =>\n throwError(\n getRawResponse(\n (paramOptions) => client.analyzeText.cancelJob(id, paramOptions),\n finalOptions\n )\n )\n );\n },\n };\n}\n"]}
|
package/dist-esm/src/models.js
CHANGED
@@ -22,19 +22,10 @@ export const AnalyzeBatchActionNames = {
|
|
22
22
|
KeyPhraseExtraction: "KeyPhraseExtraction",
|
23
23
|
EntityLinking: "EntityLinking",
|
24
24
|
Healthcare: "Healthcare",
|
25
|
-
ExtractiveSummarization: "ExtractiveSummarization",
|
26
25
|
CustomEntityRecognition: "CustomEntityRecognition",
|
27
26
|
CustomSingleLabelClassification: "CustomSingleLabelClassification",
|
28
27
|
CustomMultiLabelClassification: "CustomMultiLabelClassification",
|
29
28
|
};
|
30
|
-
/**
|
31
|
-
* Known values of the {@link HealthcareAction.fhirVersion} parameter.
|
32
|
-
*/
|
33
|
-
export var KnownFhirVersion;
|
34
|
-
(function (KnownFhirVersion) {
|
35
|
-
/** 4.0.1 */
|
36
|
-
KnownFhirVersion["4.0.1"] = "4.0.1";
|
37
|
-
})(KnownFhirVersion || (KnownFhirVersion = {}));
|
38
29
|
/**
|
39
30
|
* Enum of possible error codes of a {@link TextAnalysisError}.
|
40
31
|
*/
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"models.js","sourceRoot":"","sources":["../../src/models.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAkBL,cAAc,EACd,mBAAmB,GAcpB,MAAM,aAAa,CAAC;AA8DrB;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,aAAa,EAAE,eAAe;IAC9B,iBAAiB,EAAE,mBAAmB;IACtC,mBAAmB,EAAE,qBAAqB;IAC1C,oBAAoB,EAAE,sBAAsB;IAC5C,iBAAiB,EAAE,mBAAmB;IACtC,iBAAiB,EAAE,mBAAmB;CAC9B,CAAC;AAEX;;GAEG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC,iBAAiB,EAAE,mBAAmB;IACtC,iBAAiB,EAAE,mBAAmB;IACtC,oBAAoB,EAAE,sBAAsB;IAC5C,mBAAmB,EAAE,qBAAqB;IAC1C,aAAa,EAAE,eAAe;IAC9B,UAAU,EAAE,YAAY;IACxB,uBAAuB,EAAE,yBAAyB;IAClD,uBAAuB,EAAE,yBAAyB;IAClD,+BAA+B,EAAE,iCAAiC;IAClE,8BAA8B,EAAE,gCAAgC;CACxD,CAAC;AAmBX;;GAEG;AACH,MAAM,CAAN,IAAY,gBAGX;AAHD,WAAY,gBAAgB;IAC1B,YAAY;IACZ,mCAAiB,CAAA;AACnB,CAAC,EAHW,gBAAgB,KAAhB,gBAAgB,QAG3B;AAcD;;GAEG;AACH,MAAM,CAAC,MAAM,0BAA0B,mCAAQ,cAAc,GAAK,mBAAmB,CAAE,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n AssessmentSentiment,\n ClassificationCategory,\n CustomEntityRecognitionAction,\n CustomMultiLabelClassificationAction,\n CustomSingleLabelClassificationAction,\n DetectedLanguage,\n DocumentSentimentLabel,\n DocumentWarning,\n Entity,\n EntityDataSource,\n EntityLinkingAction,\n EntityRecognitionAction,\n ExtractiveSummarizationAction,\n HealthcareAction,\n HealthcareAssertion,\n HealthcareEntityCategory,\n KeyPhraseExtractionAction,\n KnownErrorCode,\n KnownInnerErrorCode,\n LanguageDetectionAction,\n LinkedEntity,\n OperationStatus,\n PiiEntityRecognitionAction,\n RelationType,\n SentenceSentimentLabel,\n SentimentAnalysisAction,\n SentimentConfidenceScores,\n SummarySentence,\n TargetConfidenceScores,\n TextDocumentBatchStatistics,\n TextDocumentStatistics,\n TokenSentimentLabel,\n} from \"./generated\";\nimport { CommonClientOptions, OperationOptions } from \"@azure/core-client\";\nimport { PollOperationState, PollerLike } from \"@azure/core-lro\";\nimport { PagedAsyncIterableIterator } from \"@azure/core-paging\";\n\n/**\n * Configuration options for {@link TextAnalysisClient}.\n */\nexport interface TextAnalysisClientOptions extends CommonClientOptions {\n /**\n * The default country hint to use. Defaults to \"us\".\n */\n defaultCountryHint?: string;\n\n /**\n * The default language to use. Defaults to \"en\".\n */\n defaultLanguage?: string;\n /**\n * The version of the Cognitive Language Service API to use.\n */\n apiVersion?: string;\n}\n\n/**\n * Options common to all operations.\n */\nexport interface TextAnalysisOperationOptions extends OperationOptions {\n /**\n * If set to true, response will contain input and document level statistics.\n */\n includeStatistics?: boolean;\n /**\n * The version of the Cognitive Language Service API to use.\n */\n apiVersion?: string;\n}\n\n/**\n * Options for the begin analyze actions operation.\n */\nexport interface BeginAnalyzeBatchOptions extends TextAnalysisOperationOptions {\n /**\n * Time delay between poll requests, in milliseconds.\n */\n updateIntervalInMs?: number;\n /**\n * The operation's display name.\n */\n displayName?: string;\n}\n\n/**\n * Options for the begin analyze actions operation.\n */\nexport interface RestoreAnalyzeBatchPollerOptions extends TextAnalysisOperationOptions {\n /**\n * Time delay between poll requests, in milliseconds.\n */\n updateIntervalInMs?: number;\n}\n\n/**\n * Type of actions supported by the {@link TextAnalysisClient.analyze} method.\n */\nexport const AnalyzeActionNames = {\n EntityLinking: \"EntityLinking\",\n EntityRecognition: \"EntityRecognition\",\n KeyPhraseExtraction: \"KeyPhraseExtraction\",\n PiiEntityRecognition: \"PiiEntityRecognition\",\n LanguageDetection: \"LanguageDetection\",\n SentimentAnalysis: \"SentimentAnalysis\",\n} as const;\n\n/**\n * Type of actions supported by the {@link TextAnalysisClient.beginAnalyzeBatch} method.\n */\nexport const AnalyzeBatchActionNames = {\n SentimentAnalysis: \"SentimentAnalysis\",\n EntityRecognition: \"EntityRecognition\",\n PiiEntityRecognition: \"PiiEntityRecognition\",\n KeyPhraseExtraction: \"KeyPhraseExtraction\",\n EntityLinking: \"EntityLinking\",\n Healthcare: \"Healthcare\",\n ExtractiveSummarization: \"ExtractiveSummarization\",\n CustomEntityRecognition: \"CustomEntityRecognition\",\n CustomSingleLabelClassification: \"CustomSingleLabelClassification\",\n CustomMultiLabelClassification: \"CustomMultiLabelClassification\",\n} as const;\n\n/**\n * Type of actions supported by the {@link TextAnalysisClient.analyze} method.\n */\nexport type AnalyzeActionName = keyof typeof AnalyzeActionNames;\n\n/**\n * The type of parameters for every action in ${@link AnalyzeActionNames}.\n */\nexport type AnalyzeActionParameters<ActionName extends AnalyzeActionName> = {\n EntityLinking: EntityLinkingAction;\n EntityRecognition: EntityRecognitionAction;\n PiiEntityRecognition: PiiEntityRecognitionAction;\n KeyPhraseExtraction: KeyPhraseExtractionAction;\n SentimentAnalysis: SentimentAnalysisAction;\n LanguageDetection: LanguageDetectionAction;\n}[ActionName];\n\n/**\n * Known values of the {@link HealthcareAction.fhirVersion} parameter.\n */\nexport enum KnownFhirVersion {\n /** 4.0.1 */\n \"4.0.1\" = \"4.0.1\",\n}\n\n/**\n * The type of results of every action in ${@link AnalyzeActionNames}.\n */\nexport type AnalyzeResult<ActionName extends AnalyzeActionName> = {\n EntityLinking: EntityLinkingResult[];\n EntityRecognition: EntityRecognitionResult[];\n PiiEntityRecognition: PiiEntityRecognitionResult[];\n KeyPhraseExtraction: KeyPhraseExtractionResult[];\n SentimentAnalysis: SentimentAnalysisResult[];\n LanguageDetection: LanguageDetectionResult[];\n}[ActionName];\n\n/**\n * Enum of possible error codes of a {@link TextAnalysisError}.\n */\nexport const KnownTextAnalysisErrorCode = { ...KnownErrorCode, ...KnownInnerErrorCode };\n\n/**\n * Type describing an API error.\n */\nexport interface TextAnalysisError {\n /**\n * A code describing the kind of error produced. See {@link KnownTextAnalysisErrorCode}.\n */\n readonly code: string;\n /**\n * A message from the service explaining the error\n */\n readonly message: string;\n /**\n * The target of the particular error (for example, the name of an invalid parameter)\n */\n readonly target?: string;\n}\n\n/**\n * Base type for results of an action corresponding to a single input document.\n */\nexport interface TextAnalysisSuccessResult {\n /**\n * Unique, non-empty document identifier.\n */\n readonly id: string;\n\n /**\n * Statistics about the input document and how it was processed by the service.\n * This property will have a value when includeStatistics is set to true in\n * the client call.\n */\n readonly statistics?: TextDocumentStatistics;\n\n /**\n * An array of warning data corresponding to this document.\n *\n * If no warnings were returned, this array will be empty.\n */\n readonly warnings: DocumentWarning[];\n\n /**\n * Discriminant to determine if this is an error result.\n */\n readonly error?: undefined;\n}\n\n/**\n * Base type for error results of an action corresponding to a single document.\n */\nexport interface TextAnalysisErrorResult {\n /**\n * Unique, non-empty document identifier.\n */\n readonly id: string;\n\n /**\n * The Error for this document result.\n */\n readonly error: TextAnalysisError;\n}\n\n/**\n * The result of an entity recognition action on a single document.\n */\nexport type EntityRecognitionResult = EntityRecognitionSuccessResult | EntityRecognitionErrorResult;\n\n/**\n * The result of an entity recognition action on a single document, containing\n * a collection of {@link Entity} objects identified in that document.\n */\nexport interface EntityRecognitionSuccessResult extends TextAnalysisSuccessResult {\n /**\n * The collection of entities identified in the input document.\n */\n readonly entities: Entity[];\n}\n\n/**\n * An error result from an entity recognition action on a single document.\n */\nexport type EntityRecognitionErrorResult = TextAnalysisErrorResult;\n\n/**\n * The result of an entity recognition action on a single document.\n */\nexport type PiiEntityRecognitionResult =\n | PiiEntityRecognitionSuccessResult\n | PiiEntityRecognitionErrorResult;\n\n/**\n * The result of a pii entity recognition action on a single document,\n * containing the collection of {@link Entity} objects identified in that\n * document.\n */\nexport interface PiiEntityRecognitionSuccessResult extends TextAnalysisSuccessResult {\n /**\n * The collection of entities identified in the input document.\n */\n readonly entities: Entity[];\n /**\n * The text redacted.\n */\n readonly redactedText: string;\n}\n\n/**\n * An error result from a pii entity recognition action on a single document.\n */\nexport type PiiEntityRecognitionErrorResult = TextAnalysisErrorResult;\n\n/**\n * The result of an entity linking action on a single document.\n */\nexport type EntityLinkingResult = EntityLinkingSuccessResult | EntityLinkingErrorResult;\n\n/**\n * The result of a entity linking action on a single document, containing a\n * collection of the {@link LinkedEntity} objects identified in that document.\n */\nexport interface EntityLinkingSuccessResult extends TextAnalysisSuccessResult {\n /**\n * The collection of entities identified in the input document.\n */\n readonly entities: LinkedEntity[];\n}\n\n/**\n * An error result from an entity linking action on a single document.\n */\nexport type EntityLinkingErrorResult = TextAnalysisErrorResult;\n\n/**\n * The result of a language detection action on a single document.\n */\nexport type LanguageDetectionResult = LanguageDetectionSuccessResult | LanguageDetectionErrorResult;\n\n/**\n * The result of a language detection action on a single document,\n * containing a prediction of what language the document is written in.\n */\nexport interface LanguageDetectionSuccessResult extends TextAnalysisSuccessResult {\n /**\n * The top detected language by confidence score.\n */\n readonly primaryLanguage: DetectedLanguage;\n}\n\n/**\n * An error result from a language detection action on a single document.\n */\nexport type LanguageDetectionErrorResult = TextAnalysisErrorResult;\n\n/**\n * The result of a sentiment analysis action on a single document.\n */\nexport type KeyPhraseExtractionResult =\n | KeyPhraseExtractionSuccessResult\n | KeyPhraseExtractionErrorResult;\n\n/**\n * The result of a key phrase extraction action on a single document,\n * containing a collection of the key phrases identified in that document.\n */\nexport interface KeyPhraseExtractionSuccessResult extends TextAnalysisSuccessResult {\n /**\n * A list of representative words or phrases. The number of key phrases\n * returned is proportional to the number of words in the input document.\n */\n readonly keyPhrases: string[];\n}\n\n/**\n * An error result from a key phrase extraction action on a single document.\n */\nexport type KeyPhraseExtractionErrorResult = TextAnalysisErrorResult;\n\n/**\n * The result of a sentiment analysis action on a single document.\n */\nexport type SentimentAnalysisResult = SentimentAnalysisSuccessResult | SentimentAnalysisErrorResult;\n\n/**\n * The result of a sentiment analysis action on a single document,\n * containing the predicted sentiment for each sentence as well as for the full\n * document.\n */\nexport interface SentimentAnalysisSuccessResult extends TextAnalysisSuccessResult {\n /**\n * Predicted sentiment for document. For a list of possible values, see {@link DocumentSentimentLabel}\n */\n readonly sentiment: DocumentSentimentLabel;\n /**\n * Document level sentiment confidence scores between 0 and 1 for each\n * sentiment class.\n */\n readonly confidenceScores: SentimentConfidenceScores;\n /**\n * The predicted sentiment for each sentence in the corresponding document.\n */\n readonly sentences: SentenceSentiment[];\n}\n\n/**\n * The predicted sentiment for a given span of text. For more information\n * regarding text sentiment, see {@link https://docs.microsoft.com//azure/cognitive-services/language-service/sentiment-opinion-mining/overview}.\n */\nexport interface SentenceSentiment {\n /**\n * The sentence text.\n */\n readonly text: string;\n /**\n * The predicted Sentiment for the sentence. For a list of possible values,\n * see {@link SentenceSentimentLabel}\n */\n readonly sentiment: SentenceSentimentLabel;\n /**\n * The sentiment confidence score between 0 and 1 for the sentence for all\n * classes.\n */\n readonly confidenceScores: SentimentConfidenceScores;\n /**\n * The sentence text offset from the start of the document.\n */\n readonly offset: number;\n /**\n * The length of the sentence text.\n */\n readonly length: number;\n /**\n * The list of opinions mined from this sentence. For example in \"The food is\n * good, but the service is bad\", the following two opinions will be returned:\n * \"food is good\" and \"service is bad\".\n *\n * It is non-empty only returned if {@link includeOpinionMining} was set to\n * `true`.\n */\n readonly opinions: Opinion[];\n}\n\n/**\n * TargetSentiment contains the predicted sentiment, confidence scores and other\n * information about a target of a product. A target of a product/service is a\n * key component of that product/service. For example in \"The food at Hotel Foo\n * is good\", \"food\" is a target of \"Hotel Foo\".\n */\nexport interface TargetSentiment {\n /**\n * The sentiment confidence score between 0 and 1 for the target for\n * 'positive' and 'negative' labels.\n */\n readonly confidenceScores: TargetConfidenceScores;\n /**\n * The predicted Sentiment for the Target. For a list of possible values,\n * see {@link TokenSentimentLabel}\n */\n readonly sentiment: TokenSentimentLabel;\n /**\n * The target text.\n */\n readonly text: string;\n /**\n * The Target text offset from the start of the sentence.\n */\n readonly offset: number;\n /**\n * The length of the Target text.\n */\n readonly length: number;\n}\n\n/**\n * A mined opinion object represents an opinion we've extracted from a sentence.\n * It consists of both a target that these assessments are about, and the actual\n * assessments themselves.\n */\nexport interface Opinion {\n /**\n * The target of a product/service that this assessment is about.\n */\n readonly target: TargetSentiment;\n /**\n * The actual assessments of the target.\n */\n readonly assessments: AssessmentSentiment[];\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 readonly normalizedText?: string;\n /**\n * Whether the entity is negated.\n */\n readonly assertion?: HealthcareAssertion;\n /**\n * Entity references in known data sources.\n */\n readonly 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 readonly 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 readonly entity: HealthcareEntity;\n /**\n * The role of the healthcare entity in a particular relation.\n */\n readonly 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 readonly relationType: RelationType;\n /**\n * The list of healthcare entities and their roles in the healthcare relation.\n */\n readonly roles: HealthcareEntityRelationRole[];\n}\n\n/**\n * The results of a successful healthcare analysis action for a single document.\n */\nexport interface HealthcareSuccessResult extends TextAnalysisSuccessResult {\n /**\n * Healthcare entities.\n */\n readonly entities: HealthcareEntity[];\n /**\n * Relations between healthcare entities.\n */\n readonly entityRelations: HealthcareEntityRelation[];\n /**\n * JSON bundle containing a FHIR compatible object for consumption in other\n * Healthcare tools. For additional information see {@link https://www.hl7.org/fhir/overview.html}.\n */\n readonly fhirBundle?: Record<string, any>;\n}\n\n/**\n * An error result from the healthcare analysis action on a single document.\n */\nexport type HealthcareErrorResult = TextAnalysisErrorResult;\n\n/**\n * The result of the healthcare analysis action on a single document.\n */\nexport type HealthcareResult = HealthcareSuccessResult | HealthcareErrorResult;\n\n/**\n * The result of the extractive summarization action on a single document.\n */\nexport type SummarizationExtractionResult =\n | SummarizationExtractionSuccessResult\n | SummarizationExtractionErrorResult;\n\n/**\n * The result of the extractive summarization action on a single document,\n * containing a collection of the summary identified in that document.\n */\nexport interface SummarizationExtractionSuccessResult extends TextAnalysisSuccessResult {\n /**\n * A list of sentences composing a summary of the input document.\n */\n readonly sentences: SummarySentence[];\n}\n\n/**\n * An error result from the extractive summarization action on a single document.\n */\nexport type SummarizationExtractionErrorResult = TextAnalysisErrorResult;\n\n/**\n * The result of the custom entity recognition action on a single document.\n */\nexport type CustomEntityRecognitionResult =\n | CustomEntityRecognitionSuccessResult\n | CustomEntityRecognitionErrorResult;\n\n/**\n * The result of the custom entity recognition action on a single document,\n * containing a collection of the entities identified in that document.\n */\nexport interface CustomEntityRecognitionSuccessResult extends TextAnalysisSuccessResult {\n /**\n * The collection of entities identified in the input document.\n */\n readonly entities: Entity[];\n}\n\n/**\n * An error result from the custom entity recognition action on a single document.\n */\nexport type CustomEntityRecognitionErrorResult = TextAnalysisErrorResult;\n\n/**\n * The result of the single-label classification action on a single document.\n */\nexport type CustomSingleLabelClassificationResult =\n | CustomSingleLabelClassificationSuccessResult\n | CustomSingleLabelClassificationErrorResult;\n\n/**\n * The result of a successful single-label classification action on a single document,\n * containing the result of the classification.\n */\nexport interface CustomSingleLabelClassificationSuccessResult extends TextAnalysisSuccessResult {\n /**\n * The collection of classifications in the input document.\n */\n readonly classifications: ClassificationCategory[];\n}\n\n/**\n * An error result from the single-label classification action on a single document.\n */\nexport type CustomSingleLabelClassificationErrorResult = TextAnalysisErrorResult;\n\n/**\n * The result of the multi-label classification action on a multi document.\n */\nexport type CustomMultiLabelClassificationResult =\n | CustomMultiLabelClassificationSuccessResult\n | CustomMultiLabelClassificationErrorResult;\n\n/**\n * The result of a successful multi-label classification action on a multi document,\n * containing the result of the classification.\n */\nexport interface CustomMultiLabelClassificationSuccessResult extends TextAnalysisSuccessResult {\n /**\n * The collection of classifications in the input document.\n */\n readonly classifications: ClassificationCategory[];\n}\n\n/**\n * An error result from the multi-label classification action on a multi document.\n */\nexport type CustomMultiLabelClassificationErrorResult = TextAnalysisErrorResult;\n\n/**\n * Options common to all batch actions.\n */\nexport interface AnalyzeBatchActionCommon {\n /**\n * The name of the action.\n */\n actionName?: string;\n}\n\n/** Options for an entity linking batch action. */\nexport interface EntityLinkingBatchAction extends AnalyzeBatchActionCommon, EntityLinkingAction {\n /**\n * The kind of the action.\n */\n kind: \"EntityLinking\";\n}\n\n/** Options for an entity recognition batch action. */\nexport interface EntityRecognitionBatchAction\n extends AnalyzeBatchActionCommon,\n EntityRecognitionAction {\n /**\n * The kind of the action.\n */\n kind: \"EntityRecognition\";\n}\n\n/** Options for an key phrase extraction batch action. */\nexport interface KeyPhraseExtractionBatchAction\n extends AnalyzeBatchActionCommon,\n KeyPhraseExtractionAction {\n /**\n * The kind of the action.\n */\n kind: \"KeyPhraseExtraction\";\n}\n\n/** Options for a pii entity recognition batch action. */\nexport interface PiiEntityRecognitionBatchAction\n extends AnalyzeBatchActionCommon,\n PiiEntityRecognitionAction {\n /**\n * The kind of the action.\n */\n kind: \"PiiEntityRecognition\";\n}\n\n/** Options for a healthcare batch action. */\nexport interface HealthcareBatchAction extends AnalyzeBatchActionCommon, HealthcareAction {\n /**\n * The kind of the action.\n */\n kind: \"Healthcare\";\n}\n\n/** Options for an extractive summarization batch action. */\nexport interface ExtractiveSummarizationBatchAction\n extends AnalyzeBatchActionCommon,\n ExtractiveSummarizationAction {\n /**\n * The kind of the action.\n */\n kind: \"ExtractiveSummarization\";\n}\n\n/** Options for a sentiment analysis batch action. */\nexport interface SentimentAnalysisBatchAction\n extends AnalyzeBatchActionCommon,\n SentimentAnalysisAction {\n /**\n * The kind of the action.\n */\n kind: \"SentimentAnalysis\";\n}\n\n/** Options for a custom entity recognition batch action. */\nexport interface CustomEntityRecognitionBatchAction\n extends AnalyzeBatchActionCommon,\n CustomEntityRecognitionAction {\n /**\n * The kind of the action.\n */\n kind: \"CustomEntityRecognition\";\n}\n\n/** Options for a custom single-label classification batch action. */\nexport interface CustomSingleLabelClassificationBatchAction\n extends AnalyzeBatchActionCommon,\n CustomSingleLabelClassificationAction {\n /**\n * The kind of the action.\n */\n kind: \"CustomSingleLabelClassification\";\n}\n\n/** Options for a custom multi-label classification batch action. */\nexport interface CustomMultiLabelClassificationBatchAction\n extends AnalyzeBatchActionCommon,\n CustomMultiLabelClassificationAction {\n /**\n * The kind of the action.\n */\n kind: \"CustomMultiLabelClassification\";\n}\n\n/**\n * Batch of actions.\n */\nexport type AnalyzeBatchAction =\n | EntityLinkingBatchAction\n | EntityRecognitionBatchAction\n | KeyPhraseExtractionBatchAction\n | PiiEntityRecognitionBatchAction\n | HealthcareBatchAction\n | ExtractiveSummarizationBatchAction\n | SentimentAnalysisBatchAction\n | CustomEntityRecognitionBatchAction\n | CustomSingleLabelClassificationBatchAction\n | CustomMultiLabelClassificationBatchAction;\n\n/**\n * Type of actions supported by the {@link TextAnalysisClient.beginAnalyzeBatch} method.\n */\nexport type AnalyzeBatchActionName = keyof typeof AnalyzeBatchActionNames;\n\n/** The State of a batched action */\nexport interface BatchActionState<Kind extends AnalyzeBatchActionName> {\n /**\n * The kind of the action results.\n */\n readonly kind: Kind;\n /**\n * The name of the action.\n */\n readonly actionName?: string;\n /**\n * Action statistics.\n */\n readonly statistics?: TextDocumentBatchStatistics;\n}\n\n/**\n * Action metadata.\n */\nexport interface ActionMetadata {\n /**\n * The model version used to perform the action.\n */\n readonly modelVersion: string;\n}\n\n/**\n * Custom action metadata.\n */\nexport interface CustomActionMetadata {\n /**\n * The name of the project used to perform the action.\n */\n readonly projectName: string;\n /**\n * The name of the deployment used to perform the action.\n */\n readonly deploymentName: string;\n}\n\n/**\n * The state of a succeeded batched action.\n */\nexport interface BatchActionSuccessResult<T, Kind extends AnalyzeBatchActionName>\n extends BatchActionState<Kind> {\n /**\n * The list of document results.\n */\n readonly results: T[];\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 BatchActionErrorResult<Kind extends AnalyzeBatchActionName>\n extends BatchActionState<Kind> {\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: TextAnalysisError;\n}\n\n/**\n * The result of a batched action.\n */\nexport type BatchActionResult<T, Kind extends AnalyzeBatchActionName> =\n | BatchActionSuccessResult<T, Kind>\n | BatchActionErrorResult<Kind>;\n\n/**\n * The result of an entity linking batch action.\n */\nexport type EntityLinkingBatchResult = ActionMetadata &\n BatchActionResult<EntityLinkingResult, \"EntityLinking\">;\n\n/**\n * The result of an entity recognition batch action.\n */\nexport type EntityRecognitionBatchResult = ActionMetadata &\n BatchActionResult<EntityRecognitionResult, \"EntityRecognition\">;\n\n/**\n * The result of a key phrase extraction batch action.\n */\nexport type KeyPhraseExtractionBatchResult = ActionMetadata &\n BatchActionResult<KeyPhraseExtractionResult, \"KeyPhraseExtraction\">;\n\n/**\n * The result of a pii entity recognition batch action.\n */\nexport type PiiEntityRecognitionBatchResult = ActionMetadata &\n BatchActionResult<PiiEntityRecognitionResult, \"PiiEntityRecognition\">;\n\n/**\n * The result of a sentiment analysis batch action.\n */\nexport type SentimentAnalysisBatchResult = ActionMetadata &\n BatchActionResult<SentimentAnalysisResult, \"SentimentAnalysis\">;\n\n/**\n * The result of a healthcare batch action.\n */\nexport type HealthcareBatchResult = ActionMetadata &\n BatchActionResult<HealthcareResult, \"Healthcare\">;\n\n/**\n * The result of an extractive summarization batch action.\n */\nexport type ExtractiveSummarizationBatchResult = ActionMetadata &\n BatchActionResult<SummarizationExtractionResult, \"ExtractiveSummarization\">;\n\n/**\n * The result of a custom entity recognition batch action.\n */\nexport type CustomEntityRecognitionBatchResult = CustomActionMetadata &\n BatchActionResult<CustomEntityRecognitionResult, \"CustomEntityRecognition\">;\n\n/**\n * The result of a custom single-label classification batch action.\n */\nexport type CustomSingleLabelClassificationBatchResult = CustomActionMetadata &\n BatchActionResult<CustomSingleLabelClassificationResult, \"CustomSingleLabelClassification\">;\n\n/**\n * The result of a custom multi-label classification batch action.\n */\nexport type CustomMultiLabelClassificationBatchResult = CustomActionMetadata &\n BatchActionResult<CustomMultiLabelClassificationResult, \"CustomMultiLabelClassification\">;\n/**\n * Results of a batch of actions.\n */\nexport type AnalyzeBatchResult =\n | EntityLinkingBatchResult\n | EntityRecognitionBatchResult\n | KeyPhraseExtractionBatchResult\n | PiiEntityRecognitionBatchResult\n | SentimentAnalysisBatchResult\n | HealthcareBatchResult\n | ExtractiveSummarizationBatchResult\n | CustomEntityRecognitionBatchResult\n | CustomSingleLabelClassificationBatchResult\n | CustomMultiLabelClassificationBatchResult;\n\n/**\n * An error result from a sentiment analysis action on a single document.\n */\nexport type SentimentAnalysisErrorResult = TextAnalysisErrorResult;\n\n/**\n * Paged results of the {@link TextAnalysisClient.beginAnalyzeBatch} operation.\n */\nexport type PagedAnalyzeBatchResult = PagedAsyncIterableIterator<AnalyzeBatchResult>;\n\n/**\n * A poller that polls long-running operations started by {@link TextAnalysisClient.beginAnalyzeBatch}.\n */\nexport type AnalyzeBatchPoller = PollerLike<AnalyzeBatchOperationState, PagedAnalyzeBatchResult>;\n\n/**\n * The metadata for long-running operations started by {@link TextAnalysisClient.beginAnalyzeBatch}.\n */\nexport interface AnalyzeBatchOperationMetadata {\n /**\n * The date and time the operation was created.\n */\n readonly createdOn: Date;\n /**\n * The date and time when the operation results will expire on the server.\n */\n readonly expiresOn?: Date;\n /**\n * The operation id.\n */\n readonly id: string;\n /**\n * The time the operation status was last updated.\n */\n readonly modifiedOn: Date;\n /**\n * The current status of the operation.\n */\n readonly status: OperationStatus;\n /**\n * Number of successfully completed actions.\n */\n readonly actionSucceededCount: number;\n /**\n * Number of failed actions.\n */\n readonly actionFailedCount: number;\n /**\n * Number of actions still in progress.\n */\n readonly actionInProgressCount: number;\n /**\n * The operation's display name.\n */\n readonly displayName?: string;\n}\n\n/**\n * The state of the begin analyze polling operation.\n */\nexport interface AnalyzeBatchOperationState\n extends PollOperationState<PagedAnalyzeBatchResult>,\n AnalyzeBatchOperationMetadata {}\n"]}
|
1
|
+
{"version":3,"file":"models.js","sourceRoot":"","sources":["../../src/models.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAiBL,cAAc,EACd,mBAAmB,GAYpB,MAAM,aAAa,CAAC;AA0DrB;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,aAAa,EAAE,eAAe;IAC9B,iBAAiB,EAAE,mBAAmB;IACtC,mBAAmB,EAAE,qBAAqB;IAC1C,oBAAoB,EAAE,sBAAsB;IAC5C,iBAAiB,EAAE,mBAAmB;IACtC,iBAAiB,EAAE,mBAAmB;CAC9B,CAAC;AAEX;;GAEG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC,iBAAiB,EAAE,mBAAmB;IACtC,iBAAiB,EAAE,mBAAmB;IACtC,oBAAoB,EAAE,sBAAsB;IAC5C,mBAAmB,EAAE,qBAAqB;IAC1C,aAAa,EAAE,eAAe;IAC9B,UAAU,EAAE,YAAY;IACxB,uBAAuB,EAAE,yBAAyB;IAClD,+BAA+B,EAAE,iCAAiC;IAClE,8BAA8B,EAAE,gCAAgC;CACxD,CAAC;AA+BX;;GAEG;AACH,MAAM,CAAC,MAAM,0BAA0B,mCAAQ,cAAc,GAAK,mBAAmB,CAAE,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n AssessmentSentiment,\n ClassificationCategory,\n CustomEntityRecognitionAction,\n CustomMultiLabelClassificationAction,\n CustomSingleLabelClassificationAction,\n DetectedLanguage,\n DocumentSentimentLabel,\n DocumentWarning,\n Entity,\n EntityDataSource,\n EntityLinkingAction,\n EntityRecognitionAction,\n HealthcareAction,\n HealthcareAssertion,\n HealthcareEntityCategory,\n KeyPhraseExtractionAction,\n KnownErrorCode,\n KnownInnerErrorCode,\n LanguageDetectionAction,\n LinkedEntity,\n PiiEntityRecognitionAction,\n RelationType,\n SentenceSentimentLabel,\n SentimentAnalysisAction,\n SentimentConfidenceScores,\n TargetConfidenceScores,\n TextDocumentBatchStatistics,\n TextDocumentStatistics,\n TokenSentimentLabel,\n} from \"./generated\";\nimport { CommonClientOptions, OperationOptions } from \"@azure/core-client\";\nimport { OperationState, SimplePollerLike } from \"@azure/core-lro\";\nimport { PagedAsyncIterableIterator } from \"@azure/core-paging\";\n\n/**\n * Configuration options for {@link TextAnalysisClient}.\n */\nexport interface TextAnalysisClientOptions extends CommonClientOptions {\n /**\n * The default country hint to use. Defaults to \"us\".\n */\n defaultCountryHint?: string;\n\n /**\n * The default language to use. Defaults to \"en\".\n */\n defaultLanguage?: string;\n /**\n * The version of the Cognitive Language Service API to use.\n */\n serviceVersion?: string;\n}\n\n/**\n * Options common to all operations.\n */\nexport interface TextAnalysisOperationOptions extends OperationOptions {\n /**\n * If set to true, response will contain input and document level statistics.\n */\n includeStatistics?: boolean;\n}\n\n/**\n * Options for the begin analyze actions operation.\n */\nexport interface BeginAnalyzeBatchOptions extends TextAnalysisOperationOptions {\n /**\n * Time delay between poll requests, in milliseconds.\n */\n updateIntervalInMs?: number;\n /**\n * The operation's display name.\n */\n displayName?: string;\n}\n\n/**\n * Options for the begin analyze actions operation.\n */\nexport interface RestoreAnalyzeBatchPollerOptions extends TextAnalysisOperationOptions {\n /**\n * Time delay between poll requests, in milliseconds.\n */\n updateIntervalInMs?: number;\n}\n\n/**\n * Type of actions supported by the {@link TextAnalysisClient.analyze} method.\n */\nexport const AnalyzeActionNames = {\n EntityLinking: \"EntityLinking\",\n EntityRecognition: \"EntityRecognition\",\n KeyPhraseExtraction: \"KeyPhraseExtraction\",\n PiiEntityRecognition: \"PiiEntityRecognition\",\n LanguageDetection: \"LanguageDetection\",\n SentimentAnalysis: \"SentimentAnalysis\",\n} as const;\n\n/**\n * Type of actions supported by the {@link TextAnalysisClient.beginAnalyzeBatch} method.\n */\nexport const AnalyzeBatchActionNames = {\n SentimentAnalysis: \"SentimentAnalysis\",\n EntityRecognition: \"EntityRecognition\",\n PiiEntityRecognition: \"PiiEntityRecognition\",\n KeyPhraseExtraction: \"KeyPhraseExtraction\",\n EntityLinking: \"EntityLinking\",\n Healthcare: \"Healthcare\",\n CustomEntityRecognition: \"CustomEntityRecognition\",\n CustomSingleLabelClassification: \"CustomSingleLabelClassification\",\n CustomMultiLabelClassification: \"CustomMultiLabelClassification\",\n} as const;\n\n/**\n * Type of actions supported by the {@link TextAnalysisClient.analyze} method.\n */\nexport type AnalyzeActionName = keyof typeof AnalyzeActionNames;\n\n/**\n * The type of parameters for every action in ${@link AnalyzeActionNames}.\n */\nexport type AnalyzeActionParameters<ActionName extends AnalyzeActionName> = {\n EntityLinking: EntityLinkingAction;\n EntityRecognition: EntityRecognitionAction;\n PiiEntityRecognition: PiiEntityRecognitionAction;\n KeyPhraseExtraction: KeyPhraseExtractionAction;\n SentimentAnalysis: SentimentAnalysisAction;\n LanguageDetection: LanguageDetectionAction;\n}[ActionName];\n\n/**\n * The type of results of every action in ${@link AnalyzeActionNames}.\n */\nexport type AnalyzeResult<ActionName extends AnalyzeActionName> = {\n EntityLinking: EntityLinkingResult[];\n EntityRecognition: EntityRecognitionResult[];\n PiiEntityRecognition: PiiEntityRecognitionResult[];\n KeyPhraseExtraction: KeyPhraseExtractionResult[];\n SentimentAnalysis: SentimentAnalysisResult[];\n LanguageDetection: LanguageDetectionResult[];\n}[ActionName];\n\n/**\n * Enum of possible error codes of a {@link TextAnalysisError}.\n */\nexport const KnownTextAnalysisErrorCode = { ...KnownErrorCode, ...KnownInnerErrorCode };\n\n/**\n * Type describing an API error.\n */\nexport interface TextAnalysisError {\n /**\n * A code describing the kind of error produced. See {@link KnownTextAnalysisErrorCode}.\n */\n readonly code: string;\n /**\n * A message from the service explaining the error\n */\n readonly message: string;\n /**\n * The target of the particular error (for example, the name of an invalid parameter)\n */\n readonly target?: string;\n}\n\n/**\n * Base type for results of an action corresponding to a single input document.\n */\nexport interface TextAnalysisSuccessResult {\n /**\n * Unique, non-empty document identifier.\n */\n readonly id: string;\n\n /**\n * Statistics about the input document and how it was processed by the service.\n * This property will have a value when includeStatistics is set to true in\n * the client call.\n */\n readonly statistics?: TextDocumentStatistics;\n\n /**\n * An array of warning data corresponding to this document.\n *\n * If no warnings were returned, this array will be empty.\n */\n readonly warnings: DocumentWarning[];\n\n /**\n * Discriminant to determine if this is an error result.\n */\n readonly error?: undefined;\n}\n\n/**\n * Base type for error results of an action corresponding to a single document.\n */\nexport interface TextAnalysisErrorResult {\n /**\n * Unique, non-empty document identifier.\n */\n readonly id: string;\n\n /**\n * The Error for this document result.\n */\n readonly error: TextAnalysisError;\n}\n\n/**\n * The result of an entity recognition action on a single document.\n */\nexport type EntityRecognitionResult = EntityRecognitionSuccessResult | EntityRecognitionErrorResult;\n\n/**\n * The result of an entity recognition action on a single document, containing\n * a collection of {@link Entity} objects identified in that document.\n */\nexport interface EntityRecognitionSuccessResult extends TextAnalysisSuccessResult {\n /**\n * The collection of entities identified in the input document.\n */\n readonly entities: Entity[];\n}\n\n/**\n * An error result from an entity recognition action on a single document.\n */\nexport type EntityRecognitionErrorResult = TextAnalysisErrorResult;\n\n/**\n * The result of an entity recognition action on a single document.\n */\nexport type PiiEntityRecognitionResult =\n | PiiEntityRecognitionSuccessResult\n | PiiEntityRecognitionErrorResult;\n\n/**\n * The result of a pii entity recognition action on a single document,\n * containing the collection of {@link Entity} objects identified in that\n * document.\n */\nexport interface PiiEntityRecognitionSuccessResult extends TextAnalysisSuccessResult {\n /**\n * The collection of entities identified in the input document.\n */\n readonly entities: Entity[];\n /**\n * The text redacted.\n */\n readonly redactedText: string;\n}\n\n/**\n * An error result from a pii entity recognition action on a single document.\n */\nexport type PiiEntityRecognitionErrorResult = TextAnalysisErrorResult;\n\n/**\n * The result of an entity linking action on a single document.\n */\nexport type EntityLinkingResult = EntityLinkingSuccessResult | EntityLinkingErrorResult;\n\n/**\n * The result of a entity linking action on a single document, containing a\n * collection of the {@link LinkedEntity} objects identified in that document.\n */\nexport interface EntityLinkingSuccessResult extends TextAnalysisSuccessResult {\n /**\n * The collection of entities identified in the input document.\n */\n readonly entities: LinkedEntity[];\n}\n\n/**\n * An error result from an entity linking action on a single document.\n */\nexport type EntityLinkingErrorResult = TextAnalysisErrorResult;\n\n/**\n * The result of a language detection action on a single document.\n */\nexport type LanguageDetectionResult = LanguageDetectionSuccessResult | LanguageDetectionErrorResult;\n\n/**\n * The result of a language detection action on a single document,\n * containing a prediction of what language the document is written in.\n */\nexport interface LanguageDetectionSuccessResult extends TextAnalysisSuccessResult {\n /**\n * The top detected language by confidence score.\n */\n readonly primaryLanguage: DetectedLanguage;\n}\n\n/**\n * An error result from a language detection action on a single document.\n */\nexport type LanguageDetectionErrorResult = TextAnalysisErrorResult;\n\n/**\n * The result of a sentiment analysis action on a single document.\n */\nexport type KeyPhraseExtractionResult =\n | KeyPhraseExtractionSuccessResult\n | KeyPhraseExtractionErrorResult;\n\n/**\n * The result of a key phrase extraction action on a single document,\n * containing a collection of the key phrases identified in that document.\n */\nexport interface KeyPhraseExtractionSuccessResult extends TextAnalysisSuccessResult {\n /**\n * A list of representative words or phrases. The number of key phrases\n * returned is proportional to the number of words in the input document.\n */\n readonly keyPhrases: string[];\n}\n\n/**\n * An error result from a key phrase extraction action on a single document.\n */\nexport type KeyPhraseExtractionErrorResult = TextAnalysisErrorResult;\n\n/**\n * The result of a sentiment analysis action on a single document.\n */\nexport type SentimentAnalysisResult = SentimentAnalysisSuccessResult | SentimentAnalysisErrorResult;\n\n/**\n * The result of a sentiment analysis action on a single document,\n * containing the predicted sentiment for each sentence as well as for the full\n * document.\n */\nexport interface SentimentAnalysisSuccessResult extends TextAnalysisSuccessResult {\n /**\n * Predicted sentiment for document. For a list of possible values, see {@link DocumentSentimentLabel}\n */\n readonly sentiment: DocumentSentimentLabel;\n /**\n * Document level sentiment confidence scores between 0 and 1 for each\n * sentiment class.\n */\n readonly confidenceScores: SentimentConfidenceScores;\n /**\n * The predicted sentiment for each sentence in the corresponding document.\n */\n readonly sentences: SentenceSentiment[];\n}\n\n/**\n * The predicted sentiment for a given span of text. For more information\n * regarding text sentiment, see {@link https://docs.microsoft.com//azure/cognitive-services/language-service/sentiment-opinion-mining/overview}.\n */\nexport interface SentenceSentiment {\n /**\n * The sentence text.\n */\n readonly text: string;\n /**\n * The predicted Sentiment for the sentence. For a list of possible values,\n * see {@link SentenceSentimentLabel}\n */\n readonly sentiment: SentenceSentimentLabel;\n /**\n * The sentiment confidence score between 0 and 1 for the sentence for all\n * classes.\n */\n readonly confidenceScores: SentimentConfidenceScores;\n /**\n * The sentence text offset from the start of the document.\n */\n readonly offset: number;\n /**\n * The length of the sentence text.\n */\n readonly length: number;\n /**\n * The list of opinions mined from this sentence. For example in \"The food is\n * good, but the service is bad\", the following two opinions will be returned:\n * \"food is good\" and \"service is bad\".\n *\n * It is non-empty only returned if {@link includeOpinionMining} was set to\n * `true`.\n */\n readonly opinions: Opinion[];\n}\n\n/**\n * TargetSentiment contains the predicted sentiment, confidence scores and other\n * information about a target of a product. A target of a product/service is a\n * key component of that product/service. For example in \"The food at Hotel Foo\n * is good\", \"food\" is a target of \"Hotel Foo\".\n */\nexport interface TargetSentiment {\n /**\n * The sentiment confidence score between 0 and 1 for the target for\n * 'positive' and 'negative' labels.\n */\n readonly confidenceScores: TargetConfidenceScores;\n /**\n * The predicted Sentiment for the Target. For a list of possible values,\n * see {@link TokenSentimentLabel}\n */\n readonly sentiment: TokenSentimentLabel;\n /**\n * The target text.\n */\n readonly text: string;\n /**\n * The Target text offset from the start of the sentence.\n */\n readonly offset: number;\n /**\n * The length of the Target text.\n */\n readonly length: number;\n}\n\n/**\n * A mined opinion object represents an opinion we've extracted from a sentence.\n * It consists of both a target that these assessments are about, and the actual\n * assessments themselves.\n */\nexport interface Opinion {\n /**\n * The target of a product/service that this assessment is about.\n */\n readonly target: TargetSentiment;\n /**\n * The actual assessments of the target.\n */\n readonly assessments: AssessmentSentiment[];\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 readonly normalizedText?: string;\n /**\n * Whether the entity is negated.\n */\n readonly assertion?: HealthcareAssertion;\n /**\n * Entity references in known data sources.\n */\n readonly 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 readonly 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 readonly entity: HealthcareEntity;\n /**\n * The role of the healthcare entity in a particular relation.\n */\n readonly 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 readonly relationType: RelationType;\n /**\n * The list of healthcare entities and their roles in the healthcare relation.\n */\n readonly roles: HealthcareEntityRelationRole[];\n}\n\n/**\n * The results of a successful healthcare analysis action for a single document.\n */\nexport interface HealthcareSuccessResult extends TextAnalysisSuccessResult {\n /**\n * Healthcare entities.\n */\n readonly entities: HealthcareEntity[];\n /**\n * Relations between healthcare entities.\n */\n readonly entityRelations: HealthcareEntityRelation[];\n}\n\n/**\n * An error result from the healthcare analysis action on a single document.\n */\nexport type HealthcareErrorResult = TextAnalysisErrorResult;\n\n/**\n * The result of the healthcare analysis action on a single document.\n */\nexport type HealthcareResult = HealthcareSuccessResult | HealthcareErrorResult;\n\n/**\n * The result of the custom entity recognition action on a single document.\n */\nexport type CustomEntityRecognitionResult =\n | CustomEntityRecognitionSuccessResult\n | CustomEntityRecognitionErrorResult;\n\n/**\n * The result of the custom entity recognition action on a single document,\n * containing a collection of the entities identified in that document.\n */\nexport interface CustomEntityRecognitionSuccessResult extends TextAnalysisSuccessResult {\n /**\n * The collection of entities identified in the input document.\n */\n readonly entities: Entity[];\n}\n\n/**\n * An error result from the custom entity recognition action on a single document.\n */\nexport type CustomEntityRecognitionErrorResult = TextAnalysisErrorResult;\n\n/**\n * The result of the single-label classification action on a single document.\n */\nexport type CustomSingleLabelClassificationResult =\n | CustomSingleLabelClassificationSuccessResult\n | CustomSingleLabelClassificationErrorResult;\n\n/**\n * The result of a successful single-label classification action on a single document,\n * containing the result of the classification.\n */\nexport interface CustomSingleLabelClassificationSuccessResult extends TextAnalysisSuccessResult {\n /**\n * The collection of classifications in the input document.\n */\n readonly classifications: ClassificationCategory[];\n}\n\n/**\n * An error result from the single-label classification action on a single document.\n */\nexport type CustomSingleLabelClassificationErrorResult = TextAnalysisErrorResult;\n\n/**\n * The result of the multi-label classification action on a multi document.\n */\nexport type CustomMultiLabelClassificationResult =\n | CustomMultiLabelClassificationSuccessResult\n | CustomMultiLabelClassificationErrorResult;\n\n/**\n * The result of a successful multi-label classification action on a multi document,\n * containing the result of the classification.\n */\nexport interface CustomMultiLabelClassificationSuccessResult extends TextAnalysisSuccessResult {\n /**\n * The collection of classifications in the input document.\n */\n readonly classifications: ClassificationCategory[];\n}\n\n/**\n * An error result from the multi-label classification action on a multi document.\n */\nexport type CustomMultiLabelClassificationErrorResult = TextAnalysisErrorResult;\n\n/**\n * Options common to all batch actions.\n */\nexport interface AnalyzeBatchActionCommon {\n /**\n * The name of the action.\n */\n actionName?: string;\n}\n\n/** Options for an entity linking batch action. */\nexport interface EntityLinkingBatchAction extends AnalyzeBatchActionCommon, EntityLinkingAction {\n /**\n * The kind of the action.\n */\n kind: \"EntityLinking\";\n}\n\n/** Options for an entity recognition batch action. */\nexport interface EntityRecognitionBatchAction\n extends AnalyzeBatchActionCommon,\n EntityRecognitionAction {\n /**\n * The kind of the action.\n */\n kind: \"EntityRecognition\";\n}\n\n/** Options for an key phrase extraction batch action. */\nexport interface KeyPhraseExtractionBatchAction\n extends AnalyzeBatchActionCommon,\n KeyPhraseExtractionAction {\n /**\n * The kind of the action.\n */\n kind: \"KeyPhraseExtraction\";\n}\n\n/** Options for a pii entity recognition batch action. */\nexport interface PiiEntityRecognitionBatchAction\n extends AnalyzeBatchActionCommon,\n PiiEntityRecognitionAction {\n /**\n * The kind of the action.\n */\n kind: \"PiiEntityRecognition\";\n}\n\n/** Options for a healthcare batch action. */\nexport interface HealthcareBatchAction extends AnalyzeBatchActionCommon, HealthcareAction {\n /**\n * The kind of the action.\n */\n kind: \"Healthcare\";\n}\n\n/** Options for a sentiment analysis batch action. */\nexport interface SentimentAnalysisBatchAction\n extends AnalyzeBatchActionCommon,\n SentimentAnalysisAction {\n /**\n * The kind of the action.\n */\n kind: \"SentimentAnalysis\";\n}\n\n/** Options for a custom entity recognition batch action. */\nexport interface CustomEntityRecognitionBatchAction\n extends AnalyzeBatchActionCommon,\n CustomEntityRecognitionAction {\n /**\n * The kind of the action.\n */\n kind: \"CustomEntityRecognition\";\n}\n\n/** Options for a custom single-label classification batch action. */\nexport interface CustomSingleLabelClassificationBatchAction\n extends AnalyzeBatchActionCommon,\n CustomSingleLabelClassificationAction {\n /**\n * The kind of the action.\n */\n kind: \"CustomSingleLabelClassification\";\n}\n\n/** Options for a custom multi-label classification batch action. */\nexport interface CustomMultiLabelClassificationBatchAction\n extends AnalyzeBatchActionCommon,\n CustomMultiLabelClassificationAction {\n /**\n * The kind of the action.\n */\n kind: \"CustomMultiLabelClassification\";\n}\n\n/**\n * Batch of actions.\n */\nexport type AnalyzeBatchAction =\n | EntityLinkingBatchAction\n | EntityRecognitionBatchAction\n | KeyPhraseExtractionBatchAction\n | PiiEntityRecognitionBatchAction\n | HealthcareBatchAction\n | SentimentAnalysisBatchAction\n | CustomEntityRecognitionBatchAction\n | CustomSingleLabelClassificationBatchAction\n | CustomMultiLabelClassificationBatchAction;\n\n/**\n * Type of actions supported by the {@link TextAnalysisClient.beginAnalyzeBatch} method.\n */\nexport type AnalyzeBatchActionName = keyof typeof AnalyzeBatchActionNames;\n\n/** The State of a batched action */\nexport interface BatchActionState<Kind extends AnalyzeBatchActionName> {\n /**\n * The kind of the action results.\n */\n readonly kind: Kind;\n /**\n * The name of the action.\n */\n readonly actionName?: string;\n /**\n * Action statistics.\n */\n readonly statistics?: TextDocumentBatchStatistics;\n}\n\n/**\n * Action metadata.\n */\nexport interface ActionMetadata {\n /**\n * The model version used to perform the action.\n */\n readonly modelVersion: string;\n}\n\n/**\n * Custom action metadata.\n */\nexport interface CustomActionMetadata {\n /**\n * The name of the project used to perform the action.\n */\n readonly projectName: string;\n /**\n * The name of the deployment used to perform the action.\n */\n readonly deploymentName: string;\n}\n\n/**\n * The state of a succeeded batched action.\n */\nexport interface BatchActionSuccessResult<T, Kind extends AnalyzeBatchActionName>\n extends BatchActionState<Kind> {\n /**\n * The list of document results.\n */\n readonly results: T[];\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 BatchActionErrorResult<Kind extends AnalyzeBatchActionName>\n extends BatchActionState<Kind> {\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: TextAnalysisError;\n}\n\n/**\n * The result of a batched action.\n */\nexport type BatchActionResult<T, Kind extends AnalyzeBatchActionName> =\n | BatchActionSuccessResult<T, Kind>\n | BatchActionErrorResult<Kind>;\n\n/**\n * The result of an entity linking batch action.\n */\nexport type EntityLinkingBatchResult = ActionMetadata &\n BatchActionResult<EntityLinkingResult, \"EntityLinking\">;\n\n/**\n * The result of an entity recognition batch action.\n */\nexport type EntityRecognitionBatchResult = ActionMetadata &\n BatchActionResult<EntityRecognitionResult, \"EntityRecognition\">;\n\n/**\n * The result of a key phrase extraction batch action.\n */\nexport type KeyPhraseExtractionBatchResult = ActionMetadata &\n BatchActionResult<KeyPhraseExtractionResult, \"KeyPhraseExtraction\">;\n\n/**\n * The result of a pii entity recognition batch action.\n */\nexport type PiiEntityRecognitionBatchResult = ActionMetadata &\n BatchActionResult<PiiEntityRecognitionResult, \"PiiEntityRecognition\">;\n\n/**\n * The result of a sentiment analysis batch action.\n */\nexport type SentimentAnalysisBatchResult = ActionMetadata &\n BatchActionResult<SentimentAnalysisResult, \"SentimentAnalysis\">;\n\n/**\n * The result of a healthcare batch action.\n */\nexport type HealthcareBatchResult = ActionMetadata &\n BatchActionResult<HealthcareResult, \"Healthcare\">;\n\n/**\n * The result of a custom entity recognition batch action.\n */\nexport type CustomEntityRecognitionBatchResult = CustomActionMetadata &\n BatchActionResult<CustomEntityRecognitionResult, \"CustomEntityRecognition\">;\n\n/**\n * The result of a custom single-label classification batch action.\n */\nexport type CustomSingleLabelClassificationBatchResult = CustomActionMetadata &\n BatchActionResult<CustomSingleLabelClassificationResult, \"CustomSingleLabelClassification\">;\n\n/**\n * The result of a custom multi-label classification batch action.\n */\nexport type CustomMultiLabelClassificationBatchResult = CustomActionMetadata &\n BatchActionResult<CustomMultiLabelClassificationResult, \"CustomMultiLabelClassification\">;\n/**\n * Results of a batch of actions.\n */\nexport type AnalyzeBatchResult =\n | EntityLinkingBatchResult\n | EntityRecognitionBatchResult\n | KeyPhraseExtractionBatchResult\n | PiiEntityRecognitionBatchResult\n | SentimentAnalysisBatchResult\n | HealthcareBatchResult\n | CustomEntityRecognitionBatchResult\n | CustomSingleLabelClassificationBatchResult\n | CustomMultiLabelClassificationBatchResult;\n\n/**\n * An error result from a sentiment analysis action on a single document.\n */\nexport type SentimentAnalysisErrorResult = TextAnalysisErrorResult;\n\n/**\n * Paged results of the {@link TextAnalysisClient.beginAnalyzeBatch} operation.\n */\nexport type PagedAnalyzeBatchResult = PagedAsyncIterableIterator<AnalyzeBatchResult>;\n\n/**\n * A poller that polls long-running operations started by {@link TextAnalysisClient.beginAnalyzeBatch}.\n */\nexport type AnalyzeBatchPoller = PollerLike<AnalyzeBatchOperationState, PagedAnalyzeBatchResult>;\n\n/**\n * The metadata for long-running operations started by {@link TextAnalysisClient.beginAnalyzeBatch}.\n */\nexport interface AnalyzeBatchOperationMetadata {\n /**\n * The date and time the operation was created.\n */\n readonly createdOn: Date;\n /**\n * The date and time when the operation results will expire on the server.\n */\n readonly expiresOn?: Date;\n /**\n * The operation id.\n */\n readonly id: string;\n /**\n * The time the operation status was last updated.\n */\n readonly modifiedOn: Date;\n /**\n * Number of successfully completed actions.\n */\n readonly actionSucceededCount: number;\n /**\n * Number of failed actions.\n */\n readonly actionFailedCount: number;\n /**\n * Number of actions still in progress.\n */\n readonly actionInProgressCount: number;\n /**\n * The operation's display name.\n */\n readonly displayName?: string;\n}\n\n/**\n * The state of the begin analyze polling operation.\n */\nexport interface AnalyzeBatchOperationState\n extends OperationState<PagedAnalyzeBatchResult>,\n AnalyzeBatchOperationMetadata {}\n\n/**\n * Abstract representation of a poller, intended to expose just the minimal API that the user needs to work with.\n */\nexport interface PollerLike<TState extends OperationState<TResult>, TResult>\n extends SimplePollerLike<TState, TResult> {\n /**\n * sends a cancellation request.\n */\n sendCancellationRequest: () => Promise<void>;\n}\n"]}
|
@@ -2,14 +2,14 @@
|
|
2
2
|
// Licensed under the MIT license.
|
3
3
|
import { __rest } from "tslib";
|
4
4
|
import { DEFAULT_COGNITIVE_SCOPE, SDK_VERSION } from "./constants";
|
5
|
-
import { bearerTokenAuthenticationPolicy, } from "@azure/core-rest-pipeline";
|
6
5
|
import { isTokenCredential } from "@azure/core-auth";
|
7
|
-
import { LroEngine } from "@azure/core-lro";
|
8
6
|
import { createTracingClient } from "@azure/core-tracing";
|
9
7
|
import { convertToLanguageDetectionInput, convertToTextDocumentInput, getOperationOptions, isStringArray, } from "./util";
|
10
|
-
import { createAnalyzeBatchLro,
|
8
|
+
import { createAnalyzeBatchLro, createCreateAnalyzeBatchPollerLro, createPollerWithCancellation, createUpdateAnalyzeState, getDocIDsFromState, processAnalyzeResult, } from "./lro";
|
11
9
|
import { throwError, transformActionResult } from "./transforms";
|
12
10
|
import { GeneratedClient } from "./generated/generatedClient";
|
11
|
+
import { bearerTokenAuthenticationPolicy } from "@azure/core-rest-pipeline";
|
12
|
+
import { createHttpPoller } from "@azure/core-lro";
|
13
13
|
import { logger } from "./logger";
|
14
14
|
import { textAnalyticsAzureKeyCredentialPolicy } from "./azureKeyCredentialPolicy";
|
15
15
|
/**
|
@@ -51,15 +51,15 @@ import { textAnalyticsAzureKeyCredentialPolicy } from "./azureKeyCredentialPolic
|
|
51
51
|
*/
|
52
52
|
export class TextAnalysisClient {
|
53
53
|
constructor(endpointUrl, credential, options = {}) {
|
54
|
-
const { defaultCountryHint = "us", defaultLanguage = "en" } = options, pipelineOptions = __rest(options, ["defaultCountryHint", "defaultLanguage"]);
|
54
|
+
const { defaultCountryHint = "us", defaultLanguage = "en", serviceVersion } = options, pipelineOptions = __rest(options, ["defaultCountryHint", "defaultLanguage", "serviceVersion"]);
|
55
55
|
this.defaultCountryHint = defaultCountryHint;
|
56
56
|
this.defaultLanguage = defaultLanguage;
|
57
|
-
const internalPipelineOptions = Object.assign(Object.assign({}, pipelineOptions), {
|
57
|
+
const internalPipelineOptions = Object.assign(Object.assign(Object.assign({}, pipelineOptions), {
|
58
58
|
loggingOptions: {
|
59
59
|
logger: logger.info,
|
60
60
|
additionalAllowedHeaderNames: ["x-ms-correlation-request-id", "x-ms-request-id"],
|
61
61
|
},
|
62
|
-
});
|
62
|
+
}), { apiVersion: serviceVersion });
|
63
63
|
this._client = new GeneratedClient(endpointUrl, internalPipelineOptions);
|
64
64
|
const authPolicy = isTokenCredential(credential)
|
65
65
|
? bearerTokenAuthenticationPolicy({ credential, scopes: DEFAULT_COGNITIVE_SCOPE })
|
@@ -105,7 +105,7 @@ export class TextAnalysisClient {
|
|
105
105
|
},
|
106
106
|
parameters: action,
|
107
107
|
}, updatedOptions)
|
108
|
-
.then((result) => transformActionResult(actionName, realInputs, result))));
|
108
|
+
.then((result) => transformActionResult(actionName, realInputs.map(({ id }) => id), result))));
|
109
109
|
}
|
110
110
|
// implementation
|
111
111
|
async beginAnalyzeBatch(actions, documents, languageOrOptions, options = {}) {
|
@@ -141,51 +141,66 @@ export class TextAnalysisClient {
|
|
141
141
|
tasks: realActions,
|
142
142
|
tracing: this._tracing,
|
143
143
|
});
|
144
|
-
const
|
144
|
+
const docIds = realInputs.map(({ id }) => id);
|
145
|
+
const state = { continuationToken: "" };
|
146
|
+
const poller = await createHttpPoller(lro, {
|
145
147
|
intervalInMs: updateIntervalInMs,
|
146
148
|
processResult: processAnalyzeResult({
|
147
149
|
client: this._client,
|
148
150
|
tracing: this._tracing,
|
149
|
-
|
151
|
+
docIds,
|
150
152
|
opOptions: Object.assign(Object.assign({}, rest), { includeStatistics }),
|
153
|
+
state,
|
151
154
|
}),
|
152
|
-
updateState: createUpdateAnalyzeState(
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
options: rest,
|
157
|
-
}),
|
155
|
+
updateState: createUpdateAnalyzeState(docIds),
|
156
|
+
withOperationLocation(operationLocation) {
|
157
|
+
state.continuationToken = operationLocation;
|
158
|
+
},
|
158
159
|
});
|
159
160
|
await poller.poll();
|
160
|
-
|
161
|
+
const id = poller.getOperationState().id;
|
162
|
+
return createPollerWithCancellation({
|
163
|
+
id,
|
164
|
+
client: this._client,
|
165
|
+
options,
|
166
|
+
poller,
|
167
|
+
tracing: this._tracing,
|
168
|
+
});
|
161
169
|
}
|
162
170
|
// implementation
|
163
171
|
async restoreAnalyzeBatchPoller(serializedState, options = {}) {
|
164
172
|
const { includeStatistics, updateIntervalInMs } = options, rest = __rest(options, ["includeStatistics", "updateIntervalInMs"]);
|
165
|
-
const
|
173
|
+
const docIds = getDocIDsFromState(serializedState);
|
166
174
|
const lro = createCreateAnalyzeBatchPollerLro({
|
167
175
|
client: this._client,
|
168
176
|
options: Object.assign(Object.assign({}, rest), { includeStatistics }),
|
169
177
|
tracing: this._tracing,
|
170
178
|
});
|
171
|
-
const
|
179
|
+
const state = { continuationToken: "" };
|
180
|
+
const poller = await createHttpPoller(lro, {
|
172
181
|
intervalInMs: updateIntervalInMs,
|
173
|
-
|
182
|
+
restoreFrom: serializedState,
|
174
183
|
processResult: processAnalyzeResult({
|
175
184
|
client: this._client,
|
176
185
|
tracing: this._tracing,
|
177
|
-
|
186
|
+
docIds,
|
178
187
|
opOptions: Object.assign(Object.assign({}, rest), { includeStatistics }),
|
188
|
+
state,
|
179
189
|
}),
|
180
190
|
updateState: createUpdateAnalyzeState(),
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
options: rest,
|
185
|
-
}),
|
191
|
+
withOperationLocation(operationLocation) {
|
192
|
+
state.continuationToken = operationLocation;
|
193
|
+
},
|
186
194
|
});
|
187
195
|
await poller.poll();
|
188
|
-
|
196
|
+
const id = poller.getOperationState().id;
|
197
|
+
return createPollerWithCancellation({
|
198
|
+
id,
|
199
|
+
client: this._client,
|
200
|
+
options,
|
201
|
+
poller,
|
202
|
+
tracing: this._tracing,
|
203
|
+
});
|
189
204
|
}
|
190
205
|
}
|
191
206
|
//# sourceMappingURL=textAnalysisClient.js.map
|