@azure/ai-text-analytics 5.1.1-alpha.20241029.1 → 5.1.1-alpha.20241031.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js.map +1 -1
- package/dist-esm/src/analyzeActionsResult.js +5 -5
- package/dist-esm/src/analyzeActionsResult.js.map +1 -1
- package/dist-esm/src/analyzeHealthcareEntitiesResult.js.map +1 -1
- package/dist-esm/src/analyzeSentimentResult.js.map +1 -1
- package/dist-esm/src/analyzeSentimentResultArray.js.map +1 -1
- package/dist-esm/src/azureKeyCredentialPolicy.js.map +1 -1
- package/dist-esm/src/detectLanguageResult.js.map +1 -1
- package/dist-esm/src/detectLanguageResultArray.js +1 -1
- package/dist-esm/src/detectLanguageResultArray.js.map +1 -1
- package/dist-esm/src/extractKeyPhrasesResult.js.map +1 -1
- package/dist-esm/src/extractKeyPhrasesResultArray.js.map +1 -1
- package/dist-esm/src/lro/analyze/operation.js +1 -1
- package/dist-esm/src/lro/analyze/operation.js.map +1 -1
- package/dist-esm/src/lro/analyze/poller.js +1 -1
- package/dist-esm/src/lro/analyze/poller.js.map +1 -1
- package/dist-esm/src/lro/health/operation.js +2 -2
- package/dist-esm/src/lro/health/operation.js.map +1 -1
- package/dist-esm/src/lro/health/poller.js +1 -1
- package/dist-esm/src/lro/health/poller.js.map +1 -1
- package/dist-esm/src/lro/poller.js.map +1 -1
- package/dist-esm/src/recognizeCategorizedEntitiesResult.js.map +1 -1
- package/dist-esm/src/recognizeCategorizedEntitiesResultArray.js.map +1 -1
- package/dist-esm/src/recognizeLinkedEntitiesResult.js.map +1 -1
- package/dist-esm/src/recognizeLinkedEntitiesResultArray.js.map +1 -1
- package/dist-esm/src/recognizePiiEntitiesResult.js.map +1 -1
- package/dist-esm/src/recognizePiiEntitiesResultArray.js.map +1 -1
- package/dist-esm/src/textAnalyticsClient.js +7 -7
- package/dist-esm/src/textAnalyticsClient.js.map +1 -1
- package/dist-esm/src/textAnalyticsOperationOptions.js.map +1 -1
- package/dist-esm/src/textAnalyticsResult.js.map +1 -1
- package/dist-esm/src/util.js.map +1 -1
- package/package.json +1 -1
- package/types/ai-text-analytics.d.ts +9 -9
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// Copyright (c) Microsoft Corporation.
|
|
2
2
|
// Licensed under the MIT License.
|
|
3
|
-
import { makeAnalyzeSentimentResultArray
|
|
4
|
-
import { makeExtractKeyPhrasesResultArray
|
|
5
|
-
import { makeRecognizeCategorizedEntitiesResultArray
|
|
6
|
-
import { makeRecognizeLinkedEntitiesResultArray
|
|
7
|
-
import { makeRecognizePiiEntitiesResultArray
|
|
3
|
+
import { makeAnalyzeSentimentResultArray } from "./analyzeSentimentResultArray";
|
|
4
|
+
import { makeExtractKeyPhrasesResultArray } from "./extractKeyPhrasesResultArray";
|
|
5
|
+
import { makeRecognizeCategorizedEntitiesResultArray } from "./recognizeCategorizedEntitiesResultArray";
|
|
6
|
+
import { makeRecognizeLinkedEntitiesResultArray } from "./recognizeLinkedEntitiesResultArray";
|
|
7
|
+
import { makeRecognizePiiEntitiesResultArray } from "./recognizePiiEntitiesResultArray";
|
|
8
8
|
import { intoTextAnalyticsError } from "./textAnalyticsResult";
|
|
9
9
|
/**
|
|
10
10
|
* Converts the service task name (in the JSON pointer in an action error) to an action type name.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analyzeActionsResult.js","sourceRoot":"","sources":["../../src/analyzeActionsResult.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAEL,+BAA+B,GAChC,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAEL,gCAAgC,GACjC,MAAM,gCAAgC,CAAC;AAExC,OAAO,EAEL,2CAA2C,GAC5C,MAAM,2CAA2C,CAAC;AACnD,OAAO,EAEL,sCAAsC,GACvC,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAEL,mCAAmC,GACpC,MAAM,mCAAmC,CAAC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EAAE,EAC3C,6BAA6B,CAC9B;QACD,2BAA2B,EAAE,gBAAgB,CAC3C,SAAS,EACT,mCAAmC,EACnC,MAAA,QAAQ,CAAC,KAAK,CAAC,yBAAyB,mCAAI,EAAE,EAC9C,gCAAgC,CACjC;QACD,wBAAwB,EAAE,gBAAgB,CACxC,SAAS,EACT,gCAAgC,EAChC,MAAA,QAAQ,CAAC,KAAK,CAAC,wBAAwB,mCAAI,EAAE,EAC7C,6BAA6B,CAC9B;QACD,8BAA8B,EAAE,gBAAgB,CAC9C,SAAS,EACT,sCAAsC,EACtC,MAAA,QAAQ,CAAC,KAAK,CAAC,kBAAkB,mCAAI,EAAE,EACvC,mCAAmC,CACpC;QACD,uBAAuB,EAAE,gBAAgB,CACvC,SAAS,EACT,+BAA+B,EAC/B,MAAA,QAAQ,CAAC,KAAK,CAAC,sBAAsB,mCAAI,EAAE,EAC3C,4BAA4B,CAC7B;KACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { PagedAsyncIterableIterator } from \"@azure/core-paging\";\nimport {\n AnalyzeSentimentResultArray,\n makeAnalyzeSentimentResultArray,\n} from \"./analyzeSentimentResultArray\";\nimport {\n ExtractKeyPhrasesResultArray,\n makeExtractKeyPhrasesResultArray,\n} from \"./extractKeyPhrasesResultArray\";\nimport { AnalyzeJobState as GeneratedResponse, TextDocumentInput } from \"./generated/models\";\nimport {\n RecognizeCategorizedEntitiesResultArray,\n makeRecognizeCategorizedEntitiesResultArray,\n} from \"./recognizeCategorizedEntitiesResultArray\";\nimport {\n RecognizeLinkedEntitiesResultArray,\n makeRecognizeLinkedEntitiesResultArray,\n} from \"./recognizeLinkedEntitiesResultArray\";\nimport {\n RecognizePiiEntitiesResultArray,\n makeRecognizePiiEntitiesResultArray,\n} from \"./recognizePiiEntitiesResultArray\";\nimport { ErrorCode, TextAnalyticsError, intoTextAnalyticsError } from \"./textAnalyticsResult\";\n\n/**\n * The results of an analyze Actions operation.\n */\nexport interface AnalyzeActionsResult {\n /**\n * Array of the results for each categorized entities recognition action.\n */\n recognizeEntitiesResults: RecognizeCategorizedEntitiesActionResult[];\n /**\n * Array of the results for each Pii entities recognition action.\n */\n recognizePiiEntitiesResults: RecognizePiiEntitiesActionResult[];\n /**\n * Array of the results for each key phrases extraction action.\n */\n extractKeyPhrasesResults: ExtractKeyPhrasesActionResult[];\n /**\n * Array of the results for each linked entities recognition action.\n */\n recognizeLinkedEntitiesResults: RecognizeLinkedEntitiesActionResult[];\n /**\n * Array of the results for each analyze sentiment action.\n */\n analyzeSentimentResults: AnalyzeSentimentActionResult[];\n}\n\n/**\n * The state of a succeeded action.\n */\nexport interface TextAnalyticsActionSuccessState {\n /**\n * When this action was completed by the service.\n */\n readonly completedOn: Date;\n /**\n * Discriminant to determine if that this is an error result.\n */\n readonly error?: undefined;\n}\n\n/**\n * The error of an analyze batch action.\n */\nexport interface TextAnalyticsActionErrorResult {\n /**\n * When this action was completed by the service.\n */\n readonly failedOn: Date;\n /**\n * The Error for this action result.\n */\n readonly error: TextAnalyticsError;\n}\n\n/**\n * The error of a recognize categorized entities action.\n */\nexport type RecognizeCategorizedEntitiesActionErrorResult = TextAnalyticsActionErrorResult;\n\n/**\n * The results of a succeeded recognize categorized entities action.\n */\nexport interface RecognizeCategorizedEntitiesActionSuccessResult\n extends TextAnalyticsActionSuccessState {\n /**\n * Array of the results for each categorized entities recognition action.\n */\n results: RecognizeCategorizedEntitiesResultArray;\n}\n\n/**\n * The result of a recognize categorized entities action.\n */\nexport type RecognizeCategorizedEntitiesActionResult =\n | RecognizeCategorizedEntitiesActionSuccessResult\n | RecognizeCategorizedEntitiesActionErrorResult;\n\n/**\n * The error of a recognize pii entities action.\n */\nexport type RecognizePiiEntitiesActionErrorResult = TextAnalyticsActionErrorResult;\n\n/**\n * The results of a succeeded recognize pii entities action.\n */\nexport interface RecognizePiiEntitiesActionSuccessResult extends TextAnalyticsActionSuccessState {\n /**\n * Array of the results for each pii entities recognition action.\n */\n results: RecognizePiiEntitiesResultArray;\n}\n\n/**\n * The result of a recognize pii entities action.\n */\nexport type RecognizePiiEntitiesActionResult =\n | RecognizePiiEntitiesActionSuccessResult\n | RecognizePiiEntitiesActionErrorResult;\n\n/**\n * The error of a extract key phrases action.\n */\nexport type ExtractKeyPhrasesActionErrorResult = TextAnalyticsActionErrorResult;\n\n/**\n * The results of a succeeded extract key phrases action.\n */\nexport interface ExtractKeyPhrasesActionSuccessResult extends TextAnalyticsActionSuccessState {\n /**\n * Array of the results for each extract key phrases action.\n */\n results: ExtractKeyPhrasesResultArray;\n}\n\n/**\n * The result of a extract key phrases action.\n */\nexport type ExtractKeyPhrasesActionResult =\n | ExtractKeyPhrasesActionSuccessResult\n | ExtractKeyPhrasesActionErrorResult;\n\n/**\n * The error of a recognize linked entities action.\n */\nexport type RecognizeLinkedEntitiesActionErrorResult = TextAnalyticsActionErrorResult;\n\n/**\n * The results of a succeeded recognize linked entities action.\n */\nexport interface RecognizeLinkedEntitiesActionSuccessResult\n extends TextAnalyticsActionSuccessState {\n /**\n * Array of the results for each linked entities recognition action.\n */\n results: RecognizeLinkedEntitiesResultArray;\n}\n\n/**\n * The result of a recognize linked entities action.\n */\nexport type RecognizeLinkedEntitiesActionResult =\n | RecognizeLinkedEntitiesActionSuccessResult\n | RecognizeLinkedEntitiesActionErrorResult;\n\n/**\n * The error of an analyze sentiment action.\n */\nexport type AnalyzeSentimentActionErrorResult = TextAnalyticsActionErrorResult;\n\n/**\n * The results of a succeeded analyze sentiment action.\n */\nexport interface AnalyzeSentimentActionSuccessResult extends TextAnalyticsActionSuccessState {\n /**\n * Array of the results for each analyze sentiment action.\n */\n results: AnalyzeSentimentResultArray;\n}\n\n/**\n * The result of an analyze sentiment action.\n */\nexport type AnalyzeSentimentActionResult =\n | AnalyzeSentimentActionSuccessResult\n | AnalyzeSentimentActionErrorResult;\n\n/**\n * The results of an analyze Actions operation represented as a paged iterator that\n * iterates over the results of the requested actions.\n */\nexport type PagedAsyncIterableAnalyzeActionsResult = PagedAsyncIterableIterator<\n AnalyzeActionsResult,\n AnalyzeActionsResult\n>;\n\n/**\n * The results of an analyze actions operation represented as a paged iterator that\n * iterates over the results of the requested actions.\n */\nexport interface PagedAnalyzeActionsResult extends PagedAsyncIterableAnalyzeActionsResult {\n // /**\n // * Statistics about the input document batch and how it was processed\n // * by the service. This property will have a value when includeStatistics is set to true\n // * in the client call.\n // */\n // statistics?: TextDocumentBatchStatistics;\n}\n\n/**\n * The type of different actions supported by the begin analyze actions operation.\n * @internal\n */\ntype TextAnalyticsActionType =\n | \"RecognizeCategorizedEntities\"\n | \"RecognizePiiEntities\"\n | \"ExtractKeyPhrases\"\n | \"RecognizeLinkedEntities\"\n | \"AnalyzeSentiment\";\n\n/**\n * The type of an action error with the type of the action that erred and its\n * index in the list of input actions.\n * @internal\n */\ninterface TextAnalyticsActionError {\n /**\n * A code describing the kind of error produced\n */\n readonly code: ErrorCode;\n /**\n * A message from the service explaining the error\n */\n readonly message: string;\n /**\n * The type of the action that erred\n */\n readonly type: TextAnalyticsActionType;\n /**\n * The index of the action that erred in the list of input actions\n */\n readonly index: number;\n}\n\n/**\n * Converts the service task name (in the JSON pointer in an action error) to an action type name.\n * @param serviceActionType - The task type name the service uses.\n * @returns the action type name that the package uses\n * @internal\n */\nfunction convertTaskTypeToActionType(taskType: string): TextAnalyticsActionType {\n switch (taskType) {\n case \"entityRecognitionTasks\": {\n return \"RecognizeCategorizedEntities\";\n }\n case \"entityRecognitionPiiTasks\": {\n return \"RecognizePiiEntities\";\n }\n case \"keyPhraseExtractionTasks\": {\n return \"ExtractKeyPhrases\";\n }\n case \"entityLinkingTasks\": {\n return \"RecognizeLinkedEntities\";\n }\n case \"sentimentAnalysisTasks\": {\n return \"AnalyzeSentiment\";\n }\n default: {\n throw new Error(`unexpected action type from the service: ${taskType}`);\n }\n }\n}\n\n/**\n * Converts a service action error to one with the JSON pointer converted to an action index.\n * @param erredActions - the action error the service sent\n * @returns an action error with an action type and index\n * @internal\n */\nexport function parseActionError(erredActions: TextAnalyticsError): TextAnalyticsActionError {\n if (erredActions.target) {\n const regex = new RegExp(\n /#\\/tasks\\/(entityRecognitionTasks|entityRecognitionPiiTasks|keyPhraseExtractionTasks|entityLinkingTasks|sentimentAnalysisTasks)\\/(\\d+)/,\n );\n const result = regex.exec(erredActions.target);\n if (result !== null) {\n return {\n code: erredActions.code,\n message: erredActions.message,\n index: parseInt(result[2]),\n type: convertTaskTypeToActionType(result[1]),\n };\n } else {\n throw new Error(`Pointer \"${erredActions.target}\" is not a valid action pointer`);\n }\n } else {\n throw new Error(\n \"expected an error with a target field referencing an action but did not get one\",\n );\n }\n}\n\n/**\n * Categorize each action error into a bucket according to its action type.\n * @param erredActions - list of action errors\n * @param recognizeEntitiesActionErrors - a list of recognize entities action errors to be filled from the errors list\n * @param recognizePiiEntitiesActionErrors - a list of recognize pii entities action errors to be filled from the errors list\n * @param extractKeyPhrasesActionErrors - a list of extract key phrases action errors to be filled from the errors list\n * @internal\n */\nfunction categorizeActionErrors(\n erredActions: TextAnalyticsError[],\n recognizeEntitiesActionErrors: TextAnalyticsActionError[],\n recognizePiiEntitiesActionErrors: TextAnalyticsActionError[],\n extractKeyPhrasesActionErrors: TextAnalyticsActionError[],\n recognizeLinkedEntitiesActionErrors: TextAnalyticsActionError[],\n analyzeSentimentActionErrors: TextAnalyticsActionError[],\n): void {\n for (const error of erredActions) {\n const actionError = parseActionError(error);\n switch (actionError.type) {\n case \"RecognizeCategorizedEntities\": {\n recognizeEntitiesActionErrors.push(actionError);\n break;\n }\n case \"RecognizePiiEntities\": {\n recognizePiiEntitiesActionErrors.push(actionError);\n break;\n }\n case \"ExtractKeyPhrases\": {\n extractKeyPhrasesActionErrors.push(actionError);\n break;\n }\n case \"RecognizeLinkedEntities\": {\n recognizeLinkedEntitiesActionErrors.push(actionError);\n break;\n }\n case \"AnalyzeSentiment\": {\n analyzeSentimentActionErrors.push(actionError);\n break;\n }\n }\n }\n}\n\n/**\n * @internal\n * @param error - the error the service sent for a task\n * @param lastUpdateDateTime - the time when this task failed\n */\nfunction createErredAction(\n error: TextAnalyticsActionError,\n lastUpdateDateTime: Date,\n): TextAnalyticsActionErrorResult {\n return { error: intoTextAnalyticsError(error), failedOn: lastUpdateDateTime };\n}\n\ninterface TaskSuccessResult<T> {\n results?: T;\n lastUpdateDateTime: Date;\n}\n\ntype ActionResult<TSuccess> =\n | {\n results: TSuccess;\n completedOn: Date;\n }\n | TextAnalyticsActionErrorResult;\n\n/**\n * Creates a list of results for any action.\n * @param documents - list of input documents\n * @param makeResultsArray - a function to convert the results of a service response to the SDK's one\n * @param succeededTasks - list of succeeded action results\n * @param erredActions - list of erred actions\n * @internal\n */\nfunction makeActionResult<TTaskResult, TActionResult>(\n documents: TextDocumentInput[],\n makeResultsArray: (docs: TextDocumentInput[], x: TTaskResult) => TActionResult,\n succeededTasks: TaskSuccessResult<TTaskResult>[],\n erredActions: TextAnalyticsActionError[],\n): ActionResult<TActionResult>[] {\n let errorIndex = 0;\n function convertTasksToActions(\n actions: ActionResult<TActionResult>[],\n task: TaskSuccessResult<TTaskResult>,\n ): ActionResult<TActionResult>[] {\n const { results: actionResults, lastUpdateDateTime } = task;\n if (actionResults !== undefined) {\n const recognizeEntitiesResults = makeResultsArray(documents, actionResults);\n return [\n ...actions,\n {\n results: recognizeEntitiesResults,\n completedOn: lastUpdateDateTime,\n },\n ];\n } else {\n return [...actions, createErredAction(erredActions[errorIndex++], lastUpdateDateTime)];\n }\n }\n return succeededTasks.reduce(convertTasksToActions, []);\n}\n\n/**\n * Creates the user-friendly action results object for the begin analyze actions operation.\n * @param response - the begin analyze actions operation response\n * @param documents - the list of input documents\n * @returns - the user-friendly action results object\n * @internal\n */\nexport function createAnalyzeActionsResult(\n response: GeneratedResponse,\n documents: TextDocumentInput[],\n): AnalyzeActionsResult {\n const recognizeEntitiesActionErrors: TextAnalyticsActionError[] = [];\n const recognizePiiEntitiesActionErrors: TextAnalyticsActionError[] = [];\n const extractKeyPhrasesActionErrors: TextAnalyticsActionError[] = [];\n const recognizeLinkedEntitiesActionErrors: TextAnalyticsActionError[] = [];\n const analyzeSentimentActionErrors: TextAnalyticsActionError[] = [];\n categorizeActionErrors(\n response?.errors ?? [],\n recognizeEntitiesActionErrors,\n recognizePiiEntitiesActionErrors,\n extractKeyPhrasesActionErrors,\n recognizeLinkedEntitiesActionErrors,\n analyzeSentimentActionErrors,\n );\n return {\n recognizeEntitiesResults: makeActionResult(\n documents,\n makeRecognizeCategorizedEntitiesResultArray,\n response.tasks.entityRecognitionTasks ?? [],\n recognizeEntitiesActionErrors,\n ),\n recognizePiiEntitiesResults: makeActionResult(\n documents,\n makeRecognizePiiEntitiesResultArray,\n response.tasks.entityRecognitionPiiTasks ?? [],\n recognizePiiEntitiesActionErrors,\n ),\n extractKeyPhrasesResults: makeActionResult(\n documents,\n makeExtractKeyPhrasesResultArray,\n response.tasks.keyPhraseExtractionTasks ?? [],\n extractKeyPhrasesActionErrors,\n ),\n recognizeLinkedEntitiesResults: makeActionResult(\n documents,\n makeRecognizeLinkedEntitiesResultArray,\n response.tasks.entityLinkingTasks ?? [],\n recognizeLinkedEntitiesActionErrors,\n ),\n analyzeSentimentResults: makeActionResult(\n documents,\n makeAnalyzeSentimentResultArray,\n response.tasks.sentimentAnalysisTasks ?? [],\n analyzeSentimentActionErrors,\n ),\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"analyzeActionsResult.js","sourceRoot":"","sources":["../../src/analyzeActionsResult.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC,OAAO,EAAE,+BAA+B,EAAE,MAAM,+BAA+B,CAAC;AAEhF,OAAO,EAAE,gCAAgC,EAAE,MAAM,gCAAgC,CAAC;AAGlF,OAAO,EAAE,2CAA2C,EAAE,MAAM,2CAA2C,CAAC;AAExG,OAAO,EAAE,sCAAsC,EAAE,MAAM,sCAAsC,CAAC;AAE9F,OAAO,EAAE,mCAAmC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K,CAAC,sBAAsB,mCAAI,EAAE,EAC3C,6BAA6B,CAC9B;QACD,2BAA2B,EAAE,gBAAgB,CAC3C,SAAS,EACT,mCAAmC,EACnC,MAAA,QAAQ,CAAC,KAAK,CAAC,yBAAyB,mCAAI,EAAE,EAC9C,gCAAgC,CACjC;QACD,wBAAwB,EAAE,gBAAgB,CACxC,SAAS,EACT,gCAAgC,EAChC,MAAA,QAAQ,CAAC,KAAK,CAAC,wBAAwB,mCAAI,EAAE,EAC7C,6BAA6B,CAC9B;QACD,8BAA8B,EAAE,gBAAgB,CAC9C,SAAS,EACT,sCAAsC,EACtC,MAAA,QAAQ,CAAC,KAAK,CAAC,kBAAkB,mCAAI,EAAE,EACvC,mCAAmC,CACpC;QACD,uBAAuB,EAAE,gBAAgB,CACvC,SAAS,EACT,+BAA+B,EAC/B,MAAA,QAAQ,CAAC,KAAK,CAAC,sBAAsB,mCAAI,EAAE,EAC3C,4BAA4B,CAC7B;KACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { PagedAsyncIterableIterator } from \"@azure/core-paging\";\nimport type { AnalyzeSentimentResultArray } from \"./analyzeSentimentResultArray\";\nimport { makeAnalyzeSentimentResultArray } from \"./analyzeSentimentResultArray\";\nimport type { ExtractKeyPhrasesResultArray } from \"./extractKeyPhrasesResultArray\";\nimport { makeExtractKeyPhrasesResultArray } from \"./extractKeyPhrasesResultArray\";\nimport type { AnalyzeJobState as GeneratedResponse, TextDocumentInput } from \"./generated/models\";\nimport type { RecognizeCategorizedEntitiesResultArray } from \"./recognizeCategorizedEntitiesResultArray\";\nimport { makeRecognizeCategorizedEntitiesResultArray } from \"./recognizeCategorizedEntitiesResultArray\";\nimport type { RecognizeLinkedEntitiesResultArray } from \"./recognizeLinkedEntitiesResultArray\";\nimport { makeRecognizeLinkedEntitiesResultArray } from \"./recognizeLinkedEntitiesResultArray\";\nimport type { RecognizePiiEntitiesResultArray } from \"./recognizePiiEntitiesResultArray\";\nimport { makeRecognizePiiEntitiesResultArray } from \"./recognizePiiEntitiesResultArray\";\nimport type { ErrorCode, TextAnalyticsError } from \"./textAnalyticsResult\";\nimport { intoTextAnalyticsError } from \"./textAnalyticsResult\";\n\n/**\n * The results of an analyze Actions operation.\n */\nexport interface AnalyzeActionsResult {\n /**\n * Array of the results for each categorized entities recognition action.\n */\n recognizeEntitiesResults: RecognizeCategorizedEntitiesActionResult[];\n /**\n * Array of the results for each Pii entities recognition action.\n */\n recognizePiiEntitiesResults: RecognizePiiEntitiesActionResult[];\n /**\n * Array of the results for each key phrases extraction action.\n */\n extractKeyPhrasesResults: ExtractKeyPhrasesActionResult[];\n /**\n * Array of the results for each linked entities recognition action.\n */\n recognizeLinkedEntitiesResults: RecognizeLinkedEntitiesActionResult[];\n /**\n * Array of the results for each analyze sentiment action.\n */\n analyzeSentimentResults: AnalyzeSentimentActionResult[];\n}\n\n/**\n * The state of a succeeded action.\n */\nexport interface TextAnalyticsActionSuccessState {\n /**\n * When this action was completed by the service.\n */\n readonly completedOn: Date;\n /**\n * Discriminant to determine if that this is an error result.\n */\n readonly error?: undefined;\n}\n\n/**\n * The error of an analyze batch action.\n */\nexport interface TextAnalyticsActionErrorResult {\n /**\n * When this action was completed by the service.\n */\n readonly failedOn: Date;\n /**\n * The Error for this action result.\n */\n readonly error: TextAnalyticsError;\n}\n\n/**\n * The error of a recognize categorized entities action.\n */\nexport type RecognizeCategorizedEntitiesActionErrorResult = TextAnalyticsActionErrorResult;\n\n/**\n * The results of a succeeded recognize categorized entities action.\n */\nexport interface RecognizeCategorizedEntitiesActionSuccessResult\n extends TextAnalyticsActionSuccessState {\n /**\n * Array of the results for each categorized entities recognition action.\n */\n results: RecognizeCategorizedEntitiesResultArray;\n}\n\n/**\n * The result of a recognize categorized entities action.\n */\nexport type RecognizeCategorizedEntitiesActionResult =\n | RecognizeCategorizedEntitiesActionSuccessResult\n | RecognizeCategorizedEntitiesActionErrorResult;\n\n/**\n * The error of a recognize pii entities action.\n */\nexport type RecognizePiiEntitiesActionErrorResult = TextAnalyticsActionErrorResult;\n\n/**\n * The results of a succeeded recognize pii entities action.\n */\nexport interface RecognizePiiEntitiesActionSuccessResult extends TextAnalyticsActionSuccessState {\n /**\n * Array of the results for each pii entities recognition action.\n */\n results: RecognizePiiEntitiesResultArray;\n}\n\n/**\n * The result of a recognize pii entities action.\n */\nexport type RecognizePiiEntitiesActionResult =\n | RecognizePiiEntitiesActionSuccessResult\n | RecognizePiiEntitiesActionErrorResult;\n\n/**\n * The error of a extract key phrases action.\n */\nexport type ExtractKeyPhrasesActionErrorResult = TextAnalyticsActionErrorResult;\n\n/**\n * The results of a succeeded extract key phrases action.\n */\nexport interface ExtractKeyPhrasesActionSuccessResult extends TextAnalyticsActionSuccessState {\n /**\n * Array of the results for each extract key phrases action.\n */\n results: ExtractKeyPhrasesResultArray;\n}\n\n/**\n * The result of a extract key phrases action.\n */\nexport type ExtractKeyPhrasesActionResult =\n | ExtractKeyPhrasesActionSuccessResult\n | ExtractKeyPhrasesActionErrorResult;\n\n/**\n * The error of a recognize linked entities action.\n */\nexport type RecognizeLinkedEntitiesActionErrorResult = TextAnalyticsActionErrorResult;\n\n/**\n * The results of a succeeded recognize linked entities action.\n */\nexport interface RecognizeLinkedEntitiesActionSuccessResult\n extends TextAnalyticsActionSuccessState {\n /**\n * Array of the results for each linked entities recognition action.\n */\n results: RecognizeLinkedEntitiesResultArray;\n}\n\n/**\n * The result of a recognize linked entities action.\n */\nexport type RecognizeLinkedEntitiesActionResult =\n | RecognizeLinkedEntitiesActionSuccessResult\n | RecognizeLinkedEntitiesActionErrorResult;\n\n/**\n * The error of an analyze sentiment action.\n */\nexport type AnalyzeSentimentActionErrorResult = TextAnalyticsActionErrorResult;\n\n/**\n * The results of a succeeded analyze sentiment action.\n */\nexport interface AnalyzeSentimentActionSuccessResult extends TextAnalyticsActionSuccessState {\n /**\n * Array of the results for each analyze sentiment action.\n */\n results: AnalyzeSentimentResultArray;\n}\n\n/**\n * The result of an analyze sentiment action.\n */\nexport type AnalyzeSentimentActionResult =\n | AnalyzeSentimentActionSuccessResult\n | AnalyzeSentimentActionErrorResult;\n\n/**\n * The results of an analyze Actions operation represented as a paged iterator that\n * iterates over the results of the requested actions.\n */\nexport type PagedAsyncIterableAnalyzeActionsResult = PagedAsyncIterableIterator<\n AnalyzeActionsResult,\n AnalyzeActionsResult\n>;\n\n/**\n * The results of an analyze actions operation represented as a paged iterator that\n * iterates over the results of the requested actions.\n */\nexport interface PagedAnalyzeActionsResult extends PagedAsyncIterableAnalyzeActionsResult {\n // /**\n // * Statistics about the input document batch and how it was processed\n // * by the service. This property will have a value when includeStatistics is set to true\n // * in the client call.\n // */\n // statistics?: TextDocumentBatchStatistics;\n}\n\n/**\n * The type of different actions supported by the begin analyze actions operation.\n * @internal\n */\ntype TextAnalyticsActionType =\n | \"RecognizeCategorizedEntities\"\n | \"RecognizePiiEntities\"\n | \"ExtractKeyPhrases\"\n | \"RecognizeLinkedEntities\"\n | \"AnalyzeSentiment\";\n\n/**\n * The type of an action error with the type of the action that erred and its\n * index in the list of input actions.\n * @internal\n */\ninterface TextAnalyticsActionError {\n /**\n * A code describing the kind of error produced\n */\n readonly code: ErrorCode;\n /**\n * A message from the service explaining the error\n */\n readonly message: string;\n /**\n * The type of the action that erred\n */\n readonly type: TextAnalyticsActionType;\n /**\n * The index of the action that erred in the list of input actions\n */\n readonly index: number;\n}\n\n/**\n * Converts the service task name (in the JSON pointer in an action error) to an action type name.\n * @param serviceActionType - The task type name the service uses.\n * @returns the action type name that the package uses\n * @internal\n */\nfunction convertTaskTypeToActionType(taskType: string): TextAnalyticsActionType {\n switch (taskType) {\n case \"entityRecognitionTasks\": {\n return \"RecognizeCategorizedEntities\";\n }\n case \"entityRecognitionPiiTasks\": {\n return \"RecognizePiiEntities\";\n }\n case \"keyPhraseExtractionTasks\": {\n return \"ExtractKeyPhrases\";\n }\n case \"entityLinkingTasks\": {\n return \"RecognizeLinkedEntities\";\n }\n case \"sentimentAnalysisTasks\": {\n return \"AnalyzeSentiment\";\n }\n default: {\n throw new Error(`unexpected action type from the service: ${taskType}`);\n }\n }\n}\n\n/**\n * Converts a service action error to one with the JSON pointer converted to an action index.\n * @param erredActions - the action error the service sent\n * @returns an action error with an action type and index\n * @internal\n */\nexport function parseActionError(erredActions: TextAnalyticsError): TextAnalyticsActionError {\n if (erredActions.target) {\n const regex = new RegExp(\n /#\\/tasks\\/(entityRecognitionTasks|entityRecognitionPiiTasks|keyPhraseExtractionTasks|entityLinkingTasks|sentimentAnalysisTasks)\\/(\\d+)/,\n );\n const result = regex.exec(erredActions.target);\n if (result !== null) {\n return {\n code: erredActions.code,\n message: erredActions.message,\n index: parseInt(result[2]),\n type: convertTaskTypeToActionType(result[1]),\n };\n } else {\n throw new Error(`Pointer \"${erredActions.target}\" is not a valid action pointer`);\n }\n } else {\n throw new Error(\n \"expected an error with a target field referencing an action but did not get one\",\n );\n }\n}\n\n/**\n * Categorize each action error into a bucket according to its action type.\n * @param erredActions - list of action errors\n * @param recognizeEntitiesActionErrors - a list of recognize entities action errors to be filled from the errors list\n * @param recognizePiiEntitiesActionErrors - a list of recognize pii entities action errors to be filled from the errors list\n * @param extractKeyPhrasesActionErrors - a list of extract key phrases action errors to be filled from the errors list\n * @internal\n */\nfunction categorizeActionErrors(\n erredActions: TextAnalyticsError[],\n recognizeEntitiesActionErrors: TextAnalyticsActionError[],\n recognizePiiEntitiesActionErrors: TextAnalyticsActionError[],\n extractKeyPhrasesActionErrors: TextAnalyticsActionError[],\n recognizeLinkedEntitiesActionErrors: TextAnalyticsActionError[],\n analyzeSentimentActionErrors: TextAnalyticsActionError[],\n): void {\n for (const error of erredActions) {\n const actionError = parseActionError(error);\n switch (actionError.type) {\n case \"RecognizeCategorizedEntities\": {\n recognizeEntitiesActionErrors.push(actionError);\n break;\n }\n case \"RecognizePiiEntities\": {\n recognizePiiEntitiesActionErrors.push(actionError);\n break;\n }\n case \"ExtractKeyPhrases\": {\n extractKeyPhrasesActionErrors.push(actionError);\n break;\n }\n case \"RecognizeLinkedEntities\": {\n recognizeLinkedEntitiesActionErrors.push(actionError);\n break;\n }\n case \"AnalyzeSentiment\": {\n analyzeSentimentActionErrors.push(actionError);\n break;\n }\n }\n }\n}\n\n/**\n * @internal\n * @param error - the error the service sent for a task\n * @param lastUpdateDateTime - the time when this task failed\n */\nfunction createErredAction(\n error: TextAnalyticsActionError,\n lastUpdateDateTime: Date,\n): TextAnalyticsActionErrorResult {\n return { error: intoTextAnalyticsError(error), failedOn: lastUpdateDateTime };\n}\n\ninterface TaskSuccessResult<T> {\n results?: T;\n lastUpdateDateTime: Date;\n}\n\ntype ActionResult<TSuccess> =\n | {\n results: TSuccess;\n completedOn: Date;\n }\n | TextAnalyticsActionErrorResult;\n\n/**\n * Creates a list of results for any action.\n * @param documents - list of input documents\n * @param makeResultsArray - a function to convert the results of a service response to the SDK's one\n * @param succeededTasks - list of succeeded action results\n * @param erredActions - list of erred actions\n * @internal\n */\nfunction makeActionResult<TTaskResult, TActionResult>(\n documents: TextDocumentInput[],\n makeResultsArray: (docs: TextDocumentInput[], x: TTaskResult) => TActionResult,\n succeededTasks: TaskSuccessResult<TTaskResult>[],\n erredActions: TextAnalyticsActionError[],\n): ActionResult<TActionResult>[] {\n let errorIndex = 0;\n function convertTasksToActions(\n actions: ActionResult<TActionResult>[],\n task: TaskSuccessResult<TTaskResult>,\n ): ActionResult<TActionResult>[] {\n const { results: actionResults, lastUpdateDateTime } = task;\n if (actionResults !== undefined) {\n const recognizeEntitiesResults = makeResultsArray(documents, actionResults);\n return [\n ...actions,\n {\n results: recognizeEntitiesResults,\n completedOn: lastUpdateDateTime,\n },\n ];\n } else {\n return [...actions, createErredAction(erredActions[errorIndex++], lastUpdateDateTime)];\n }\n }\n return succeededTasks.reduce(convertTasksToActions, []);\n}\n\n/**\n * Creates the user-friendly action results object for the begin analyze actions operation.\n * @param response - the begin analyze actions operation response\n * @param documents - the list of input documents\n * @returns - the user-friendly action results object\n * @internal\n */\nexport function createAnalyzeActionsResult(\n response: GeneratedResponse,\n documents: TextDocumentInput[],\n): AnalyzeActionsResult {\n const recognizeEntitiesActionErrors: TextAnalyticsActionError[] = [];\n const recognizePiiEntitiesActionErrors: TextAnalyticsActionError[] = [];\n const extractKeyPhrasesActionErrors: TextAnalyticsActionError[] = [];\n const recognizeLinkedEntitiesActionErrors: TextAnalyticsActionError[] = [];\n const analyzeSentimentActionErrors: TextAnalyticsActionError[] = [];\n categorizeActionErrors(\n response?.errors ?? [],\n recognizeEntitiesActionErrors,\n recognizePiiEntitiesActionErrors,\n extractKeyPhrasesActionErrors,\n recognizeLinkedEntitiesActionErrors,\n analyzeSentimentActionErrors,\n );\n return {\n recognizeEntitiesResults: makeActionResult(\n documents,\n makeRecognizeCategorizedEntitiesResultArray,\n response.tasks.entityRecognitionTasks ?? [],\n recognizeEntitiesActionErrors,\n ),\n recognizePiiEntitiesResults: makeActionResult(\n documents,\n makeRecognizePiiEntitiesResultArray,\n response.tasks.entityRecognitionPiiTasks ?? [],\n recognizePiiEntitiesActionErrors,\n ),\n extractKeyPhrasesResults: makeActionResult(\n documents,\n makeExtractKeyPhrasesResultArray,\n response.tasks.keyPhraseExtractionTasks ?? [],\n extractKeyPhrasesActionErrors,\n ),\n recognizeLinkedEntitiesResults: makeActionResult(\n documents,\n makeRecognizeLinkedEntitiesResultArray,\n response.tasks.entityLinkingTasks ?? [],\n recognizeLinkedEntitiesActionErrors,\n ),\n analyzeSentimentResults: makeActionResult(\n documents,\n makeAnalyzeSentimentResultArray,\n response.tasks.sentimentAnalysisTasks ?? [],\n analyzeSentimentActionErrors,\n ),\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analyzeHealthcareEntitiesResult.js","sourceRoot":"","sources":["../../src/analyzeHealthcareEntitiesResult.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;
|
|
1
|
+
{"version":3,"file":"analyze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;;;GAIG;AACH,MAAM,UAAU,4BAA4B,CAC1C,QAAoC;IAEpC,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAE,GAAG,QAAQ,CAAC;IACnE,MAAM,WAAW,GAAG,QAAQ,CAAC,GAAG,CAAC,sCAAsC,CAAC,CAAC;IACzE,uCACK,8BAA8B,CAAC,EAAE,EAAE,QAAQ,EAAE,UAAU,CAAC,KAC3D,QAAQ,EAAE,WAAW,EACrB,eAAe,EAAE,uBAAuB,CAAC,WAAW,EAAE,SAAS,CAAC,IAChE;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iCAAiC,CAC/C,EAAU,EACV,KAAyB;IAEzB,OAAO,4BAA4B,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;AACjD,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { PagedAsyncIterableIterator } from \"@azure/core-paging\";\nimport type {\n DocumentHealthcareEntities,\n Entity,\n HealthcareEntity as GeneratedHealthcareEntity,\n HealthcareAssertion,\n HealthcareEntityCategory,\n HealthcareRelation,\n HealthcareRelationEntity,\n RelationType,\n TextAnalyticsError,\n TextDocumentBatchStatistics,\n} from \"./generated/models\";\nimport type { TextAnalyticsErrorResult, TextAnalyticsSuccessResult } from \"./textAnalyticsResult\";\nimport {\n makeTextAnalyticsErrorResult,\n makeTextAnalyticsSuccessResult,\n} from \"./textAnalyticsResult\";\nimport { parseHealthcareEntityIndex } from \"./util\";\n\n/**\n * A type representing a reference for the healthcare entity into a specific\n * entity catalog.\n */\nexport interface EntityDataSource {\n /**\n * Entity Catalog. Examples include: UMLS, CHV, MSH, etc.\n */\n name: string;\n /**\n * Entity id in the given source catalog.\n */\n entityId: string;\n}\n\n/**\n * A healthcare entity represented as a node in a directed graph where the edges are\n * a particular type of relationship between the source and target nodes.\n */\nexport interface HealthcareEntity extends Entity {\n /**\n * Normalized name for the entity. For example, the normalized text for \"histologically\" is \"histologic\".\n */\n normalizedText?: string;\n /**\n * Whether the entity is negated.\n */\n assertion?: HealthcareAssertion;\n /**\n * Entity references in known data sources.\n */\n dataSources: EntityDataSource[];\n /**\n * Defines values for HealthcareEntityCategory.\n * {@link KnownHealthcareEntityCategory} can be used interchangeably with HealthcareEntityCategory,\n * this enum contains the known values that the service supports.\n * ### Known values supported by the service\n * **BODY_STRUCTURE**\n * **AGE**\n * **GENDER**\n * **EXAMINATION_NAME**\n * **DATE**\n * **DIRECTION**\n * **FREQUENCY**\n * **MEASUREMENT_VALUE**\n * **MEASUREMENT_UNIT**\n * **RELATIONAL_OPERATOR**\n * **TIME**\n * **GENE_OR_PROTEIN**\n * **VARIANT**\n * **ADMINISTRATIVE_EVENT**\n * **CARE_ENVIRONMENT**\n * **HEALTHCARE_PROFESSION**\n * **DIAGNOSIS**\n * **SYMPTOM_OR_SIGN**\n * **CONDITION_QUALIFIER**\n * **MEDICATION_CLASS**\n * **MEDICATION_NAME**\n * **DOSAGE**\n * **MEDICATION_FORM**\n * **MEDICATION_ROUTE**\n * **FAMILY_RELATION**\n * **TREATMENT_NAME**\n */\n category: HealthcareEntityCategory;\n}\n\n/**\n * The type of different roles a healthcare entity can play in a relation.\n */\nexport type HealthcareEntityRelationRoleType = string;\n\n/**\n * A healthcare entity that plays a specific role in a relation.\n */\nexport interface HealthcareEntityRelationRole {\n /**\n * A healthcare entity\n */\n entity: HealthcareEntity;\n /**\n * The role of the healthcare entity in a particular relation.\n */\n name: HealthcareEntityRelationRoleType;\n}\n\n/**\n * A relationship between two or more healthcare entities.\n */\nexport interface HealthcareEntityRelation {\n /**\n * The type of the healthcare relation.\n */\n relationType: RelationType;\n /**\n * The list of healthcare entities and their roles in the healthcare relation.\n */\n roles: HealthcareEntityRelationRole[];\n}\n\n/**\n * The results of a successful healthcare operation for a single document.\n */\nexport interface AnalyzeHealthcareEntitiesSuccessResult extends TextAnalyticsSuccessResult {\n /**\n * Healthcare entities.\n */\n entities: HealthcareEntity[];\n /**\n * Relations between healthcare entities.\n */\n entityRelations: HealthcareEntityRelation[];\n}\n\n/**\n * An error result from the healthcare operation on a single document.\n */\nexport type AnalyzeHealthcareEntitiesErrorResult = TextAnalyticsErrorResult;\n\n/**\n * The result of the healthcare operation on a single document.\n */\nexport type AnalyzeHealthcareEntitiesResult =\n | AnalyzeHealthcareEntitiesSuccessResult\n | AnalyzeHealthcareEntitiesErrorResult;\n\n/**\n * Array of {@link AnalyzeHealthcareEntitiesResult}\n */\nexport interface AnalyzeHealthcareEntitiesResultArray\n extends Array<AnalyzeHealthcareEntitiesResult> {}\n\n/**\n * The results of a healthcare operation represented as a paged iterator that can\n * either iterate over the results on a document-by-document basis or, by\n * byPage(), can iterate over pages of documents.\n */\nexport type PagedAsyncIterableAnalyzeHealthcareEntitiesResult = PagedAsyncIterableIterator<\n AnalyzeHealthcareEntitiesResult,\n AnalyzeHealthcareEntitiesResultArray\n>;\n\n/**\n * The results of a healthcare operation represented as a paged iterator that can\n * either iterate over the results on a document-by-document basis or, by\n * byPage(), can iterate over pages of documents.\n */\nexport interface PagedAnalyzeHealthcareEntitiesResult\n extends PagedAsyncIterableAnalyzeHealthcareEntitiesResult {\n /**\n * Statistics about the input document batch and how it was processed\n * by the service. This property will have a value when includeStatistics is set to true\n * in the client call.\n */\n statistics?: TextDocumentBatchStatistics;\n /**\n * The version of the text analytics model used by this operation on this\n * batch of input documents.\n */\n modelVersion: string;\n}\n\n/**\n * Creates a user-friendly healthcare entity represented as a node in a graph\n * @param entity - the healthcare entity returned by the service\n * @internal\n */\nfunction makeHealthcareEntitiesWithoutNeighbors(\n entity: GeneratedHealthcareEntity,\n): HealthcareEntity {\n const { category, confidenceScore, assertion, offset, text, links, subcategory, length, name } =\n entity;\n return {\n category,\n confidenceScore,\n assertion,\n offset,\n length,\n text,\n normalizedText: name,\n subCategory: subcategory,\n dataSources:\n links?.map(({ dataSource, id }): EntityDataSource => ({ name: dataSource, entityId: id })) ??\n [],\n };\n}\n\n/**\n * @internal\n */\nfunction makeHealthcareRelations(\n entities: HealthcareEntity[],\n relations: HealthcareRelation[],\n): HealthcareEntityRelation[] {\n return relations.map(\n (relation: HealthcareRelation): HealthcareEntityRelation => ({\n relationType: relation.relationType,\n roles: relation.entities.map(\n (role: HealthcareRelationEntity): HealthcareEntityRelationRole => ({\n entity: entities[parseHealthcareEntityIndex(role.ref)],\n name: role.role,\n }),\n ),\n }),\n );\n}\n\n/**\n * Creates a healthcare entity in the convenience layer from the one sent by the service.\n * @param document - incoming results sent by the service for a particular document\n * @internal\n */\nexport function makeHealthcareEntitiesResult(\n document: DocumentHealthcareEntities,\n): AnalyzeHealthcareEntitiesSuccessResult {\n const { id, entities, relations, warnings, statistics } = document;\n const newEntities = entities.map(makeHealthcareEntitiesWithoutNeighbors);\n return {\n ...makeTextAnalyticsSuccessResult(id, warnings, statistics),\n entities: newEntities,\n entityRelations: makeHealthcareRelations(newEntities, relations),\n };\n}\n\n/**\n * @internal\n */\nexport function makeHealthcareEntitiesErrorResult(\n id: string,\n error: TextAnalyticsError,\n): AnalyzeHealthcareEntitiesErrorResult {\n return makeTextAnalyticsErrorResult(id, error);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analyzeSentimentResult.js","sourceRoot":"","sources":["../../src/analyzeSentimentResult.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;
|
|
1
|
+
{"version":3,"file":"analyzeSentimentResult.js","sourceRoot":"","sources":["../../src/analyzeSentimentResult.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EACL,4BAA4B,EAC5B,8BAA8B,GAC/B,MAAM,uBAAuB,CAAC;AAe/B,OAAO,EAAE,oBAAoB,EAAE,MAAM,QAAQ,CAAC;AAuH9C;;;GAGG;AACH,MAAM,UAAU,0BAA0B,CACxC,MAAyB;IAEzB,MAAM,EACJ,EAAE,EACF,SAAS,EACT,gBAAgB,EAChB,kBAA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C,QAAQ,EAAE,MAAM,CAAC,CAAC;aACnF,CAAC,CACH;YACH,CAAC,CAAC,EAAE;KACP,CAAC;AACJ,CAAC;AAED;;;;;;;;;GASG;AACH,SAAS,0CAA0C,CACjD,cAA8B,EAC9B,MAAyB;;IAEzB,MAAM,aAAa,GAAG,cAAc,CAAC,GAAG,CAAC;IACzC,MAAM,eAAe,GAAoB,oBAAoB,CAAC,aAAa,CAAC,CAAC;IAC7E,MAAM,UAAU,GACd,MAAA,MAAA,MAAM,CAAC,kBAAkB,0CAAG,eAAe,CAAC,QAAQ,EAAE,WAAW,0CAAG,eAAe,CAAC,UAAU,CAAC,CAAC;IAClG,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;QAC7B,OAAO,UAAU,CAAC;IACpB,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,KAAK,CAAC,YAAY,aAAa,qCAAqC,CAAC,CAAC;IAClF,CAAC;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { TextAnalyticsErrorResult, TextAnalyticsSuccessResult } from \"./textAnalyticsResult\";\nimport {\n makeTextAnalyticsErrorResult,\n makeTextAnalyticsSuccessResult,\n} from \"./textAnalyticsResult\";\nimport type {\n DocumentSentiment,\n DocumentSentimentLabel,\n SentenceSentiment as GeneratedSentenceSentiment,\n SentenceAssessment,\n SentenceSentimentLabel,\n SentenceTarget,\n TokenSentimentValue as SentenceTargetSentiment,\n SentimentConfidenceScores,\n TargetConfidenceScoreLabel,\n TargetRelation,\n TextAnalyticsError,\n} from \"./generated/models\";\nimport type { AssessmentIndex } from \"./util\";\nimport { parseAssessmentIndex } from \"./util\";\n\n/**\n * The result of the analyze sentiment operation on a single document.\n */\nexport type AnalyzeSentimentResult = AnalyzeSentimentSuccessResult | AnalyzeSentimentErrorResult;\n\n/**\n * The result of the analyze sentiment operation on a single document,\n * containing the predicted sentiment for each sentence as well as for the full document.\n */\nexport interface AnalyzeSentimentSuccessResult extends TextAnalyticsSuccessResult {\n /**\n * Predicted sentiment for document. Possible values\n * include: 'positive', 'neutral', 'negative', 'mixed'\n */\n sentiment: DocumentSentimentLabel;\n /**\n * Document level sentiment confidence scores between 0 and 1 for each sentiment class.\n */\n confidenceScores: SentimentConfidenceScores;\n /**\n * The predicted sentiment for each sentence in the corresponding document.\n */\n sentences: SentenceSentiment[];\n}\n\n/**\n * The predicted sentiment for a given span of text. For more information regarding text sentiment, see https://docs.microsoft.com/azure/cognitive-services/Text-Analytics/how-tos/text-analytics-how-to-sentiment-analysis.\n */\nexport interface SentenceSentiment {\n /**\n * The sentence text.\n */\n text: string;\n /**\n * The predicted Sentiment for the sentence.\n */\n sentiment: SentenceSentimentLabel;\n /**\n * The sentiment confidence score between 0 and 1 for the sentence for all classes.\n */\n confidenceScores: SentimentConfidenceScores;\n /**\n * The sentence text offset from the start of the document.\n */\n offset: number;\n /**\n * The length of the sentence text.\n */\n 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\", we would mine these two opinions \"food is\n * good\", \"service is bad\". Only returned if `includeOpinionMining` is set to\n * True in the call to `analyzeSentiment`.\n */\n opinions: Opinion[];\n}\n\n/**\n * TargetSentiment contains the predicted sentiment, confidence scores and other\n * information about an 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 confidenceScores: TargetConfidenceScoreLabel;\n /**\n * The predicted Sentiment for the Target. Possible values include 'positive',\n * 'mixed', and 'negative'.\n */\n sentiment: SentenceTargetSentiment;\n /**\n * The target text.\n */\n text: string;\n /**\n * The Target text offset from the start of the sentence.\n */\n offset: number;\n /**\n * The length of the Target text.\n */\n length: number;\n}\n\n/**\n * AssessmentSentiment contains the predicted sentiment, confidence scores and\n * other information about an assessment of a target. For example, in the sentence\n * \"The food is good\", the assessment of the target 'food' is 'good'.\n */\nexport interface AssessmentSentiment extends SentenceAssessment {}\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 target: TargetSentiment;\n /**\n * The actual assessments of the target.\n */\n assessments: AssessmentSentiment[];\n}\n\n/**\n * An error result from the analyze sentiment operation on a single document.\n */\nexport type AnalyzeSentimentErrorResult = TextAnalyticsErrorResult;\n\n/**\n * @param document - A document result coming from the service.\n * @internal\n */\nexport function makeAnalyzeSentimentResult(\n result: DocumentSentiment,\n): AnalyzeSentimentSuccessResult {\n const {\n id,\n sentiment,\n confidenceScores,\n sentenceSentiments: sentences,\n warnings,\n statistics,\n } = result;\n return {\n ...makeTextAnalyticsSuccessResult(id, warnings, statistics),\n sentiment,\n confidenceScores,\n sentences: sentences.map((sentence) => convertGeneratedSentenceSentiment(sentence, result)),\n };\n}\n\n/**\n * @internal\n */\nexport function makeAnalyzeSentimentErrorResult(\n id: string,\n error: TextAnalyticsError,\n): AnalyzeSentimentErrorResult {\n return makeTextAnalyticsErrorResult(id, error);\n}\n\n/**\n * Converts a sentence sentiment object returned by the service to another that\n * is user-friendly.\n *\n * @param sentence - The sentence sentiment object to be converted.\n * @param response - The entire response returned by the service.\n * @returns The user-friendly sentence sentiment object.\n * @internal\n */\nfunction convertGeneratedSentenceSentiment(\n sentence: GeneratedSentenceSentiment,\n result: DocumentSentiment,\n): SentenceSentiment {\n return {\n confidenceScores: sentence.confidenceScores,\n sentiment: sentence.sentiment,\n text: sentence.text,\n offset: sentence.offset,\n length: sentence.length,\n opinions: sentence.targets\n ? sentence.targets.map(\n (target: SentenceTarget): Opinion => ({\n target: {\n confidenceScores: target.confidenceScores,\n sentiment: target.sentiment,\n text: target.text,\n offset: target.offset,\n length: target.length,\n },\n assessments: target.relations\n .filter((relation) => relation.relationType === \"assessment\")\n .map((relation) => convertTargetRelationToAssessmentSentiment(relation, result)),\n }),\n )\n : [],\n };\n}\n\n/**\n * Converts a target relation object returned by the service to an assessment\n * sentiment object where JSON pointers in the former are realized in the\n * latter.\n *\n * @param targetRelation - The target relation object to be converted.\n * @param response - The entire response returned by the service.\n * @returns The user-friendly assessment sentiment object.\n * @internal\n */\nfunction convertTargetRelationToAssessmentSentiment(\n targetRelation: TargetRelation,\n result: DocumentSentiment,\n): AssessmentSentiment {\n const assessmentPtr = targetRelation.ref;\n const assessmentIndex: AssessmentIndex = parseAssessmentIndex(assessmentPtr);\n const assessment: SentenceAssessment | undefined =\n result.sentenceSentiments?.[assessmentIndex.sentence].assessments?.[assessmentIndex.assessment];\n if (assessment !== undefined) {\n return assessment;\n } else {\n throw new Error(`Pointer \"${assessmentPtr}\" is not a valid Assessment pointer`);\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analyzeSentimentResultArray.js","sourceRoot":"","sources":["../../src/analyzeSentimentResultArray.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;
|
|
1
|
+
{"version":3,"file":"analyzeSentimentResultArray.js","sourceRoot":"","sources":["../../src/analyzeSentimentResultArray.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAQlC,OAAO,EACL,+BAA+B,EAC/B,0BAA0B,GAC3B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,mEAAmE,EAAE,MAAM,uBAAuB,CAAC;AAoB5G;;GAEG;AACH,MAAM,UAAU,+BAA+B,CAC7C,KAA0B,EAC1B,QAA2B;IAE3B,OAAO,mEAAmE,CACxE,KAAK,EACL,QAAQ,EACR,0BAA0B,EAC1B,+BAA+B,CAChC,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type {\n SentimentResponse,\n TextDocumentBatchStatistics,\n TextDocumentInput,\n} from \"./generated/models\";\nimport type { AnalyzeSentimentResult } from \"./analyzeSentimentResult\";\nimport {\n makeAnalyzeSentimentErrorResult,\n makeAnalyzeSentimentResult,\n} from \"./analyzeSentimentResult\";\nimport { combineSuccessfulAndErroneousDocumentsWithStatisticsAndModelVersion } from \"./textAnalyticsResult\";\n\n/**\n * Array of `AnalyzeSentimentResult` objects corresponding to a batch of input documents, and\n * annotated with information about the batch operation.\n */\nexport interface AnalyzeSentimentResultArray extends Array<AnalyzeSentimentResult> {\n /**\n * Statistics about the input document batch and how it was processed\n * by the service. This property will have a value when includeStatistics is set to true\n * in the client call.\n */\n statistics?: TextDocumentBatchStatistics;\n /**\n * The version of the text analytics model used by this operation on this\n * batch of input documents.\n */\n modelVersion: string;\n}\n\n/**\n * @internal\n */\nexport function makeAnalyzeSentimentResultArray(\n input: TextDocumentInput[],\n response: SentimentResponse,\n): AnalyzeSentimentResultArray {\n return combineSuccessfulAndErroneousDocumentsWithStatisticsAndModelVersion(\n input,\n response,\n makeAnalyzeSentimentResult,\n makeAnalyzeSentimentErrorResult,\n );\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"azureKeyCredentialPolicy.js","sourceRoot":"","sources":["../../src/azureKeyCredentialPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAUlC,MAAM,mBAAmB,GAAG,2BAA2B,CAAC;AAExD;;GAEG;AACH,MAAM,yCAAyC,GAAG,uCAAuC,CAAC;AAE1F;;;;GAIG;AACH,MAAM,UAAU,qCAAqC,CAAC,UAAyB;IAC7E,OAAO;QACL,IAAI,EAAE,yCAAyC;QAC/C,WAAW,CAAC,OAAwB,EAAE,IAAiB;YACrD,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC;YACzD,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;QACvB,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { KeyCredential } from \"@azure/core-auth\";\nimport {\n PipelinePolicy,\n PipelineRequest,\n PipelineResponse,\n SendRequest,\n} from \"@azure/core-rest-pipeline\";\n\nconst API_KEY_HEADER_NAME = \"Ocp-Apim-Subscription-Key\";\n\n/**\n * The programmatic identifier of the textAnalyticsAzureKeyCredentialPolicy.\n */\nconst textAnalyticsAzureKeyCredentialPolicyName = \"textAnalyticsAzureKeyCredentialPolicy\";\n\n/**\n * Create an HTTP pipeline policy to authenticate a request\n * using an `AzureKeyCredential` for Text Analytics\n * @internal\n */\nexport function textAnalyticsAzureKeyCredentialPolicy(credential: KeyCredential): PipelinePolicy {\n return {\n name: textAnalyticsAzureKeyCredentialPolicyName,\n sendRequest(request: PipelineRequest, next: SendRequest): Promise<PipelineResponse> {\n request.headers.set(API_KEY_HEADER_NAME, credential.key);\n return next(request);\n },\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"azureKeyCredentialPolicy.js","sourceRoot":"","sources":["../../src/azureKeyCredentialPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAUlC,MAAM,mBAAmB,GAAG,2BAA2B,CAAC;AAExD;;GAEG;AACH,MAAM,yCAAyC,GAAG,uCAAuC,CAAC;AAE1F;;;;GAIG;AACH,MAAM,UAAU,qCAAqC,CAAC,UAAyB;IAC7E,OAAO;QACL,IAAI,EAAE,yCAAyC;QAC/C,WAAW,CAAC,OAAwB,EAAE,IAAiB;YACrD,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC;YACzD,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;QACvB,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { KeyCredential } from \"@azure/core-auth\";\nimport type {\n PipelinePolicy,\n PipelineRequest,\n PipelineResponse,\n SendRequest,\n} from \"@azure/core-rest-pipeline\";\n\nconst API_KEY_HEADER_NAME = \"Ocp-Apim-Subscription-Key\";\n\n/**\n * The programmatic identifier of the textAnalyticsAzureKeyCredentialPolicy.\n */\nconst textAnalyticsAzureKeyCredentialPolicyName = \"textAnalyticsAzureKeyCredentialPolicy\";\n\n/**\n * Create an HTTP pipeline policy to authenticate a request\n * using an `AzureKeyCredential` for Text Analytics\n * @internal\n */\nexport function textAnalyticsAzureKeyCredentialPolicy(credential: KeyCredential): PipelinePolicy {\n return {\n name: textAnalyticsAzureKeyCredentialPolicyName,\n sendRequest(request: PipelineRequest, next: SendRequest): Promise<PipelineResponse> {\n request.headers.set(API_KEY_HEADER_NAME, credential.key);\n return next(request);\n },\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"detectLanguageResult.js","sourceRoot":"","sources":["../../src/detectLanguageResult.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;
|
|
1
|
+
{"version":3,"file":"detectLanguageResult.js","sourceRoot":"","sources":["../../src/detectLanguageResult.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EACL,4BAA4B,EAC5B,8BAA8B,GAC/B,MAAM,uBAAuB,CAAC;AAwB/B;;GAEG;AACH,MAAM,UAAU,wBAAwB,CAAC,QAA0B;IACjE,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,gBAAgB,EAAE,GAAG,QAAQ,CAAC;IAChE,uCACK,8BAA8B,CAAC,EAAE,EAAE,QAAQ,EAAE,UAAU,CAAC,KAC3D,eAAe,EAAE,gBAAgB,IACjC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,6BAA6B,CAC3C,EAAU,EACV,KAAyB;IAEzB,OAAO,4BAA4B,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;AACjD,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { TextAnalyticsErrorResult, TextAnalyticsSuccessResult } from \"./textAnalyticsResult\";\nimport {\n makeTextAnalyticsErrorResult,\n makeTextAnalyticsSuccessResult,\n} from \"./textAnalyticsResult\";\nimport type { DetectedLanguage, DocumentLanguage, TextAnalyticsError } from \"./generated/models\";\n\n/**\n * The result of the detect language operation on a single document.\n */\nexport type DetectLanguageResult = DetectLanguageSuccessResult | DetectLanguageErrorResult;\n\n/**\n * The result of the detect language operation on a single document,\n * containing a prediction of what language the document is written in.\n */\nexport interface DetectLanguageSuccessResult extends TextAnalyticsSuccessResult {\n /**\n * The top detected language by confidence score.\n */\n readonly primaryLanguage: DetectedLanguage;\n}\n\n/**\n * An error result from the detect languge operation on a single document.\n */\nexport type DetectLanguageErrorResult = TextAnalyticsErrorResult;\n\n/**\n * @internal\n */\nexport function makeDetectLanguageResult(response: DocumentLanguage): DetectLanguageSuccessResult {\n const { id, warnings, statistics, detectedLanguage } = response;\n return {\n ...makeTextAnalyticsSuccessResult(id, warnings, statistics),\n primaryLanguage: detectedLanguage,\n };\n}\n\n/**\n * @internal\n */\nexport function makeDetectLanguageErrorResult(\n id: string,\n error: TextAnalyticsError,\n): DetectLanguageErrorResult {\n return makeTextAnalyticsErrorResult(id, error);\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Copyright (c) Microsoft Corporation.
|
|
2
2
|
// Licensed under the MIT License.
|
|
3
|
-
import { makeDetectLanguageErrorResult, makeDetectLanguageResult
|
|
3
|
+
import { makeDetectLanguageErrorResult, makeDetectLanguageResult } from "./detectLanguageResult";
|
|
4
4
|
import { combineSuccessfulAndErroneousDocumentsWithStatisticsAndModelVersion } from "./textAnalyticsResult";
|
|
5
5
|
/**
|
|
6
6
|
* @internal
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"detectLanguageResultArray.js","sourceRoot":"","sources":["../../src/detectLanguageResultArray.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;
|
|
1
|
+
{"version":3,"file":"detectLanguageResultArray.js","sourceRoot":"","sources":["../../src/detectLanguageResultArray.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAQlC,OAAO,EAAE,6BAA6B,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AACjG,OAAO,EAAE,mEAAmE,EAAE,MAAM,uBAAuB,CAAC;AAoB5G;;GAEG;AACH,MAAM,UAAU,6BAA6B,CAC3C,KAA0B,EAC1B,QAAwB;IAExB,OAAO,mEAAmE,CACxE,KAAK,EACL,QAAQ,EACR,wBAAwB,EACxB,6BAA6B,CAC9B,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type {\n LanguageResult,\n TextDocumentBatchStatistics,\n TextDocumentInput,\n} from \"./generated/models\";\nimport type { DetectLanguageResult } from \"./detectLanguageResult\";\nimport { makeDetectLanguageErrorResult, makeDetectLanguageResult } from \"./detectLanguageResult\";\nimport { combineSuccessfulAndErroneousDocumentsWithStatisticsAndModelVersion } from \"./textAnalyticsResult\";\n\n/**\n * Array of `DetectLanguageResult` objects corresponding to a batch of input documents, and\n * annotated with information about the batch operation.\n */\nexport interface DetectLanguageResultArray extends Array<DetectLanguageResult> {\n /**\n * Statistics about the input document batch and how it was processed\n * by the service. This property will have a value when includeStatistics is set to true\n * in the client call.\n */\n statistics?: TextDocumentBatchStatistics;\n /**\n * The version of the text analytics model used by this operation on this\n * batch of input documents.\n */\n modelVersion: string;\n}\n\n/**\n * @internal\n */\nexport function makeDetectLanguageResultArray(\n input: TextDocumentInput[],\n response: LanguageResult,\n): DetectLanguageResultArray {\n return combineSuccessfulAndErroneousDocumentsWithStatisticsAndModelVersion(\n input,\n response,\n makeDetectLanguageResult,\n makeDetectLanguageErrorResult,\n );\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extractKeyPhrasesResult.js","sourceRoot":"","sources":["../../src/extractKeyPhrasesResult.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;
|
|
1
|
+
{"version":3,"file":"extractKeyPhrasesResult.js","sourceRoot":"","sources":["../../src/extractKeyPhrasesResult.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EACL,4BAA4B,EAC5B,8BAA8B,GAC/B,MAAM,uBAAuB,CAAC;AAyB/B;;GAEG;AACH,MAAM,UAAU,2BAA2B,CACzC,MAA0B;IAE1B,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,MAAM,CAAC;IACxD,uCACK,8BAA8B,CAAC,EAAE,EAAE,QAAQ,EAAE,UAAU,CAAC,KAC3D,UAAU,IACV;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gCAAgC,CAC9C,EAAU,EACV,KAAyB;IAEzB,OAAO,4BAA4B,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;AACjD,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { TextAnalyticsErrorResult, TextAnalyticsSuccessResult } from \"./textAnalyticsResult\";\nimport {\n makeTextAnalyticsErrorResult,\n makeTextAnalyticsSuccessResult,\n} from \"./textAnalyticsResult\";\nimport type { DocumentKeyPhrases, TextAnalyticsError } from \"./generated/models\";\n\n/**\n * The result of the extract key phrases operation on a single document.\n */\nexport type ExtractKeyPhrasesResult = ExtractKeyPhrasesSuccessResult | ExtractKeyPhrasesErrorResult;\n\n/**\n * The result of the extract key phrases operation on a single document,\n * containing a collection of the key phrases identified in that document.\n */\nexport interface ExtractKeyPhrasesSuccessResult extends TextAnalyticsSuccessResult {\n /**\n * A list of representative words or phrases. The number of key phrases returned is proportional\n * to the number of words in the input document.\n */\n keyPhrases: string[];\n}\n\n/**\n * An error result from the extract key phrases operation on a single document.\n */\nexport type ExtractKeyPhrasesErrorResult = TextAnalyticsErrorResult;\n\n/**\n * @internal\n */\nexport function makeExtractKeyPhrasesResult(\n result: DocumentKeyPhrases,\n): ExtractKeyPhrasesSuccessResult {\n const { id, warnings, statistics, keyPhrases } = result;\n return {\n ...makeTextAnalyticsSuccessResult(id, warnings, statistics),\n keyPhrases,\n };\n}\n\n/**\n * @internal\n */\nexport function makeExtractKeyPhrasesErrorResult(\n id: string,\n error: TextAnalyticsError,\n): ExtractKeyPhrasesErrorResult {\n return makeTextAnalyticsErrorResult(id, error);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extractKeyPhrasesResultArray.js","sourceRoot":"","sources":["../../src/extractKeyPhrasesResultArray.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;
|
|
1
|
+
{"version":3,"file":"extractKeyPhrasesResultArray.js","sourceRoot":"","sources":["../../src/extractKeyPhrasesResultArray.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAQlC,OAAO,EACL,gCAAgC,EAChC,2BAA2B,GAC5B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,mEAAmE,EAAE,MAAM,uBAAuB,CAAC;AAoB5G;;GAEG;AACH,MAAM,UAAU,gCAAgC,CAC9C,KAA0B,EAC1B,QAAyB;IAEzB,OAAO,mEAAmE,CACxE,KAAK,EACL,QAAQ,EACR,2BAA2B,EAC3B,gCAAgC,CACjC,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type {\n KeyPhraseResult,\n TextDocumentBatchStatistics,\n TextDocumentInput,\n} from \"./generated/models\";\nimport type { ExtractKeyPhrasesResult } from \"./extractKeyPhrasesResult\";\nimport {\n makeExtractKeyPhrasesErrorResult,\n makeExtractKeyPhrasesResult,\n} from \"./extractKeyPhrasesResult\";\nimport { combineSuccessfulAndErroneousDocumentsWithStatisticsAndModelVersion } from \"./textAnalyticsResult\";\n\n/**\n * Array of `ExtractKeyPhrasesResult` objects corresponding to a batch of input documents, and\n * annotated with information about the batch operation.\n */\nexport interface ExtractKeyPhrasesResultArray extends Array<ExtractKeyPhrasesResult> {\n /**\n * Statistics about the input document batch and how it was processed\n * by the service. This property will have a value when includeStatistics is set to true\n * in the client call.\n */\n statistics?: TextDocumentBatchStatistics;\n /**\n * The version of the text analytics model used by this operation on this\n * batch of input documents.\n */\n modelVersion: string;\n}\n\n/**\n * @internal\n */\nexport function makeExtractKeyPhrasesResultArray(\n input: TextDocumentInput[],\n response: KeyPhraseResult,\n): ExtractKeyPhrasesResultArray {\n return combineSuccessfulAndErroneousDocumentsWithStatisticsAndModelVersion(\n input,\n response,\n makeExtractKeyPhrasesResult,\n makeExtractKeyPhrasesErrorResult,\n );\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Copyright (c) Microsoft Corporation.
|
|
2
2
|
// Licensed under the MIT License.
|
|
3
3
|
import { __asyncGenerator, __await } from "tslib";
|
|
4
|
-
import { createAnalyzeActionsResult
|
|
4
|
+
import { createAnalyzeActionsResult } from "../../analyzeActionsResult";
|
|
5
5
|
import { getOperationId, nextLinkToTopAndSkip, throwError } from "../../util";
|
|
6
6
|
import { AnalysisPollOperation } from "../poller";
|
|
7
7
|
import { logger } from "../../logger";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operation.js","sourceRoot":"","sources":["../../../../src/lro/analyze/operation.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;AAclC,OAAO,EAIL,0BAA0B,GAC3B,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC9E,OAAO,EAAE,qBAAqB,EAAiD,MAAM,WAAW,CAAC;AAEjG,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAoFtC;;GAEG;AACH,SAAS,uBAAuB,CAC9B,QAAyB;IAEzB,OAAO;QACL,SAAS,EAAE,QAAQ,CAAC,eAAe;QACnC,cAAc,EAAE,QAAQ,CAAC,kBAAkB;QAC3C,SAAS,EAAE,QAA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gB,CAAC,sBAAsB,CAAC;QACvF,KAAK,CAAC,WAAW,GAAG,MAAA,eAAe,CAAC,gBAAgB,0CAAE,WAAW,CAAC;QAElE,IAAI,CAAC,KAAK,CAAC,WAAW,IAAI,eAAe,CAAC,IAAI,EAAE,CAAC;YAC/C,MAAM,aAAa,GAAG,IAAI,CAAC,yBAAyB,CAAC,KAAK,CAAC,WAAY,EAAE;gBACvE,WAAW,EAAE,IAAI,CAAC,OAAO,CAAC,WAAW;gBACrC,cAAc,EAAE,IAAI,CAAC,OAAO,CAAC,cAAc;gBAC3C,iBAAiB,EAAE,IAAI,CAAC,OAAO,CAAC,iBAAiB;gBACjD,UAAU,EAAE,IAAI,CAAC,OAAO,CAAC,UAAU;gBACnC,iBAAiB,EAAE,IAAI,CAAC,OAAO,CAAC,iBAAiB;aAClD,CAAC,CAAC;YACH,oDAAoD;YACpD,yDAAyD;YACzD,gDAAgD;YAChD,2CAA2C;YAC3C,MAAM;YACN,KAAK,CAAC,MAAM,GAAG,aAAa,CAAC;YAC7B,KAAK,CAAC,WAAW,GAAG,IAAI,CAAC;QAC3B,CAAC;QAED,IAAI,OAAO,OAAO,CAAC,YAAY,KAAK,UAAU,EAAE,CAAC;YAC/C,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;QAC9B,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,MAAM;QACV,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QACzB,MAAM,CAAC,OAAO,CAAC,iEAAiE,CAAC,CAAC;QAClF,KAAK,CAAC,WAAW,GAAG,IAAI,CAAC;QACzB,OAAO,IAAI,CAAC;IACd,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { OperationOptions } from \"@azure/core-client\";\n\nimport { AbortSignalLike } from \"@azure/abort-controller\";\n\nimport {\n AnalyzeStatusOptionalParams as AnalyzeActionsOperationStatusOptions,\n AnalyzeJobState,\n AnalyzeResponse as BeginAnalyzeResponse,\n JobManifestTasks as GeneratedActions,\n TextDocumentBatchStatistics,\n TextDocumentInput,\n} from \"../../generated/models\";\nimport {\n AnalyzeActionsResult,\n PagedAnalyzeActionsResult,\n PagedAsyncIterableAnalyzeActionsResult,\n createAnalyzeActionsResult,\n} from \"../../analyzeActionsResult\";\nimport { PageSettings } from \"@azure/core-paging\";\nimport { getOperationId, nextLinkToTopAndSkip, throwError } from \"../../util\";\nimport { AnalysisPollOperation, AnalysisPollOperationState, OperationMetadata } from \"../poller\";\nimport { GeneratedClient as Client } from \"../../generated\";\nimport { logger } from \"../../logger\";\nimport { TracingClient } from \"@azure/core-tracing\";\n\n/**\n * @internal\n */\ninterface AnalyzeResultsWithPagination {\n result: AnalyzeActionsResult;\n top?: number;\n skip?: number;\n}\n\n/**\n * The metadata for beginAnalyzeActions operations.\n */\nexport interface AnalyzeActionsOperationMetadata extends OperationMetadata {\n /**\n * Number of successfully completed actions.\n */\n actionsSucceededCount: number;\n /**\n * Number of failed actions.\n */\n actionsFailedCount: number;\n /**\n * Number of actions still in progress.\n */\n actionsInProgressCount: number;\n /**\n * The operation's display name.\n */\n displayName?: string;\n}\n\n/**\n * @internal\n */\ninterface AnalyzeActionsOperationStatus {\n done: boolean;\n /**\n * Statistics about the input document batch and how it was processed\n * by the service. This property will have a value when includeStatistics is set to true\n * in the client call.\n */\n statistics?: TextDocumentBatchStatistics;\n operationMetdata: Omit<AnalyzeActionsOperationMetadata, \"operationId\">;\n}\n\n/**\n * @internal\n */\ninterface BeginAnalyzeInternalOptions extends OperationOptions {\n displayName?: string;\n}\n\n/**\n * Options for the begin analyze actions operation.\n */\nexport interface BeginAnalyzeActionsOptions extends OperationOptions {\n /**\n * Delay to wait until next poll, in milliseconds.\n */\n updateIntervalInMs?: number;\n /**\n * A serialized poller which can be used to resume an existing paused Long-Running-Operation.\n */\n resumeFrom?: string;\n /**\n * If set to true, response will contain input and document level statistics.\n */\n includeStatistics?: boolean;\n /**\n * The operation's display name.\n */\n displayName?: string;\n}\n\n/**\n * The state of the begin analyze polling operation.\n */\nexport interface AnalyzeActionsOperationState\n extends AnalysisPollOperationState<PagedAnalyzeActionsResult>,\n AnalyzeActionsOperationMetadata {}\n\n/**\n * @internal\n */\nfunction getMetaInfoFromResponse(\n response: AnalyzeJobState,\n): Omit<AnalyzeActionsOperationMetadata, \"operationId\"> {\n return {\n createdOn: response.createdDateTime,\n lastModifiedOn: response.lastUpdateDateTime,\n expiresOn: response.expirationDateTime,\n status: response.status,\n actionsSucceededCount: response.tasks.completed,\n actionsFailedCount: response.tasks.failed,\n actionsInProgressCount: response.tasks.inProgress,\n displayName: response.displayName,\n };\n}\n\n/**\n * Class that represents a poller that waits for results of the analyze\n * operation.\n * @internal\n */\nexport class BeginAnalyzeActionsPollerOperation extends AnalysisPollOperation<\n AnalyzeActionsOperationState,\n PagedAnalyzeActionsResult\n> {\n constructor(\n public state: AnalyzeActionsOperationState,\n // eslint-disable-next-line @azure/azure-sdk/ts-use-interface-parameters\n private client: Client,\n private tracing: TracingClient,\n private documents: TextDocumentInput[],\n private actions: GeneratedActions,\n private options: BeginAnalyzeActionsOptions = {},\n ) {\n super(state);\n }\n\n /**\n * should be called only after all the status of the analyze actions operations became\n * \"succeeded\" and it returns an iterator for the results and provides a\n * byPage method to return the results paged.\n */\n private listAnalyzeActionsResults(\n operationId: string,\n options: AnalyzeActionsOperationStatusOptions = {},\n ): PagedAsyncIterableAnalyzeActionsResult {\n const iter = this._listAnalyzeActionsResultsPaged(operationId, options);\n return {\n next() {\n return iter.next();\n },\n [Symbol.asyncIterator]() {\n return this;\n },\n byPage: (settings?: PageSettings) => {\n const pageOptions = { ...options, top: settings?.maxPageSize };\n return this._listAnalyzeActionsResultsPaged(operationId, pageOptions);\n },\n };\n }\n\n /**\n * returns an iterator to arrays of the results of an analyze actions operation.\n */\n private async *_listAnalyzeActionsResultsPaged(\n operationId: string,\n options?: AnalyzeActionsOperationStatusOptions,\n ): AsyncIterableIterator<AnalyzeActionsResult> {\n let response = await this._listAnalyzeActionsResultsSinglePage(operationId, options);\n yield response.result;\n while (response.skip) {\n const optionsWithContinuation: AnalyzeActionsOperationStatusOptions = {\n ...options,\n top: response.top,\n skip: response.skip,\n };\n response = await this._listAnalyzeActionsResultsSinglePage(\n operationId,\n optionsWithContinuation,\n );\n yield response.result;\n }\n }\n\n /**\n * returns an iterator to arrays of the sorted results of an analyze actions operation.\n */\n private async _listAnalyzeActionsResultsSinglePage(\n operationId: string,\n options?: AnalyzeActionsOperationStatusOptions,\n ): Promise<AnalyzeResultsWithPagination> {\n const response = await this.tracing.withSpan(\n \"TextAnalyticsClient-_listAnalyzeActionsResultsSinglePage\",\n options || {},\n (finalOptions) => this.client.analyzeStatus(operationId, finalOptions),\n );\n const result = createAnalyzeActionsResult(response, this.documents);\n return response.nextLink ? { result, ...nextLinkToTopAndSkip(response.nextLink) } : { result };\n }\n\n /**\n * returns whether the analyze actions operation is done and if so returns also\n * statistics.\n */\n private async getAnalyzeActionsOperationStatus(\n operationId: string,\n options?: AnalyzeActionsOperationStatusOptions,\n ): Promise<AnalyzeActionsOperationStatus> {\n const response = await this.tracing.withSpan(\n \"TextAnalyticsClient-getAnalyzeActionsOperationStatus\",\n options || {},\n (finalOptions) => this.client.analyzeStatus(operationId, finalOptions),\n );\n switch (response.status) {\n case \"notStarted\":\n case \"running\":\n break;\n default: {\n return {\n done: true,\n statistics: response.statistics,\n operationMetdata: getMetaInfoFromResponse(response),\n };\n }\n }\n return { done: false, operationMetdata: getMetaInfoFromResponse(response) };\n }\n\n private async beginAnalyzeActions(\n documents: TextDocumentInput[],\n actions: GeneratedActions,\n options?: BeginAnalyzeInternalOptions,\n ): Promise<BeginAnalyzeResponse> {\n return this.tracing.withSpan(\n \"TextAnalyticsClient-beginAnalyze\",\n options || {},\n (finalOptions) =>\n throwError(\n this.client.analyze({\n body: {\n analysisInput: { documents: documents },\n tasks: actions,\n displayName: options?.displayName,\n },\n ...finalOptions,\n }),\n ),\n );\n }\n\n async update(\n options: {\n abortSignal?: AbortSignalLike;\n fireProgress?: (state: AnalyzeActionsOperationState) => void;\n } = {},\n ): Promise<BeginAnalyzeActionsPollerOperation> {\n const state = this.state;\n const updatedAbortSignal = options.abortSignal;\n if (!state.isStarted) {\n state.isStarted = true;\n const response = await this.beginAnalyzeActions(this.documents, this.actions, {\n displayName: this.options.displayName,\n tracingOptions: this.options.tracingOptions,\n requestOptions: this.options.requestOptions,\n abortSignal: updatedAbortSignal ? updatedAbortSignal : this.options.abortSignal,\n });\n if (!response.operationLocation) {\n throw new Error(\n \"Expects a valid 'operationLocation' to retrieve analyze results but did not find any\",\n );\n }\n state.operationId = getOperationId(response.operationLocation);\n }\n\n const operationStatus = await this.getAnalyzeActionsOperationStatus(state.operationId!, {\n abortSignal: updatedAbortSignal ? updatedAbortSignal : options.abortSignal,\n includeStatistics: this.options.includeStatistics,\n tracingOptions: this.options.tracingOptions,\n });\n\n state.createdOn = operationStatus.operationMetdata.createdOn;\n state.expiresOn = operationStatus.operationMetdata.expiresOn;\n state.lastModifiedOn = operationStatus.operationMetdata.lastModifiedOn;\n state.status = operationStatus.operationMetdata.status;\n state.actionsSucceededCount = operationStatus.operationMetdata.actionsSucceededCount;\n state.actionsFailedCount = operationStatus.operationMetdata.actionsFailedCount;\n state.actionsInProgressCount = operationStatus.operationMetdata.actionsInProgressCount;\n state.displayName = operationStatus.operationMetdata?.displayName;\n\n if (!state.isCompleted && operationStatus.done) {\n const pagedIterator = this.listAnalyzeActionsResults(state.operationId!, {\n abortSignal: this.options.abortSignal,\n tracingOptions: this.options.tracingOptions,\n includeStatistics: this.options.includeStatistics,\n onResponse: this.options.onResponse,\n serializerOptions: this.options.serializerOptions,\n });\n // Attach stats if the service starts to return them\n // https://github.com/Azure/azure-sdk-for-js/issues/14139\n // state.result = Object.assign(pagedIterator, {\n // statistics: operationStatus.statistics\n // });\n state.result = pagedIterator;\n state.isCompleted = true;\n }\n\n if (typeof options.fireProgress === \"function\") {\n options.fireProgress(state);\n }\n return this;\n }\n\n async cancel(): Promise<BeginAnalyzeActionsPollerOperation> {\n const state = this.state;\n logger.warning(`The service does not yet support cancellation for beginAnalyze.`);\n state.isCancelled = true;\n return this;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"operation.js","sourceRoot":"","sources":["../../../../src/lro/analyze/operation.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;AAmBlC,OAAO,EAAE,0BAA0B,EAAE,MAAM,4BAA4B,CAAC;AAExE,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE9E,OAAO,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAElD,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAoFtC;;GAEG;AACH,SAAS,uBAAuB,CAC9B,QAAyB;IAEzB,OAAO;QACL,SAAS,EAAE,QAAQ,CAAC,eAAe;QACnC,cAAc,EAAE,QAAQ,CAAC,kBAAkB;QAC3C,SAAS,EAAE,QAAQ,CAAC,kBAAkB;QACtC,MAAM,EAAE,QAAQ,CAAC,MAAM;QACvB,qBAAqB,EAAE,QAAQ,CAAC,KAAK,CAAC,SAAS;QAC/C,kBAAkB,EAAE,QAAQ,CAAC,KAAK,CAAC,MAAM;QACzC,sBAAsB,EAAE,QAAQ,CAAC,KAAK,CAAC,UAAU;QACjD,WAAW,EAAE,QAAQ,CAAC,WAAW;KAClC,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,OAAO,kCAAmC,SAAQ,qBAGvD;IACC,YACS,KAAmC;IAC1C,wEAAwE;IAChE,MAAc,EACd,OAAsB,EACtB,SAA8B,EAC9B,OAAyB,EACzB,UAAsC,EAAE;QAEhD,KAAK,CAAC,KAAK,CAAC,CAAC;QARN,UAAK,GAAL,KAAK,CAA8B;QAElC,WAAM,GAAN,MAAM,CAAQ;QACd,YAAO,GAAP,OAAO,CAAe;QACtB,cAAS,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2CAA2C;YAC3C,MAAM;YACN,KAAK,CAAC,MAAM,GAAG,aAAa,CAAC;YAC7B,KAAK,CAAC,WAAW,GAAG,IAAI,CAAC;QAC3B,CAAC;QAED,IAAI,OAAO,OAAO,CAAC,YAAY,KAAK,UAAU,EAAE,CAAC;YAC/C,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;QAC9B,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,MAAM;QACV,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QACzB,MAAM,CAAC,OAAO,CAAC,iEAAiE,CAAC,CAAC;QAClF,KAAK,CAAC,WAAW,GAAG,IAAI,CAAC;QACzB,OAAO,IAAI,CAAC;IACd,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { OperationOptions } from \"@azure/core-client\";\n\nimport type { AbortSignalLike } from \"@azure/abort-controller\";\n\nimport type {\n AnalyzeStatusOptionalParams as AnalyzeActionsOperationStatusOptions,\n AnalyzeJobState,\n AnalyzeResponse as BeginAnalyzeResponse,\n JobManifestTasks as GeneratedActions,\n TextDocumentBatchStatistics,\n TextDocumentInput,\n} from \"../../generated/models\";\nimport type {\n AnalyzeActionsResult,\n PagedAnalyzeActionsResult,\n PagedAsyncIterableAnalyzeActionsResult,\n} from \"../../analyzeActionsResult\";\nimport { createAnalyzeActionsResult } from \"../../analyzeActionsResult\";\nimport type { PageSettings } from \"@azure/core-paging\";\nimport { getOperationId, nextLinkToTopAndSkip, throwError } from \"../../util\";\nimport type { AnalysisPollOperationState, OperationMetadata } from \"../poller\";\nimport { AnalysisPollOperation } from \"../poller\";\nimport type { GeneratedClient as Client } from \"../../generated\";\nimport { logger } from \"../../logger\";\nimport type { TracingClient } from \"@azure/core-tracing\";\n\n/**\n * @internal\n */\ninterface AnalyzeResultsWithPagination {\n result: AnalyzeActionsResult;\n top?: number;\n skip?: number;\n}\n\n/**\n * The metadata for beginAnalyzeActions operations.\n */\nexport interface AnalyzeActionsOperationMetadata extends OperationMetadata {\n /**\n * Number of successfully completed actions.\n */\n actionsSucceededCount: number;\n /**\n * Number of failed actions.\n */\n actionsFailedCount: number;\n /**\n * Number of actions still in progress.\n */\n actionsInProgressCount: number;\n /**\n * The operation's display name.\n */\n displayName?: string;\n}\n\n/**\n * @internal\n */\ninterface AnalyzeActionsOperationStatus {\n done: boolean;\n /**\n * Statistics about the input document batch and how it was processed\n * by the service. This property will have a value when includeStatistics is set to true\n * in the client call.\n */\n statistics?: TextDocumentBatchStatistics;\n operationMetdata: Omit<AnalyzeActionsOperationMetadata, \"operationId\">;\n}\n\n/**\n * @internal\n */\ninterface BeginAnalyzeInternalOptions extends OperationOptions {\n displayName?: string;\n}\n\n/**\n * Options for the begin analyze actions operation.\n */\nexport interface BeginAnalyzeActionsOptions extends OperationOptions {\n /**\n * Delay to wait until next poll, in milliseconds.\n */\n updateIntervalInMs?: number;\n /**\n * A serialized poller which can be used to resume an existing paused Long-Running-Operation.\n */\n resumeFrom?: string;\n /**\n * If set to true, response will contain input and document level statistics.\n */\n includeStatistics?: boolean;\n /**\n * The operation's display name.\n */\n displayName?: string;\n}\n\n/**\n * The state of the begin analyze polling operation.\n */\nexport interface AnalyzeActionsOperationState\n extends AnalysisPollOperationState<PagedAnalyzeActionsResult>,\n AnalyzeActionsOperationMetadata {}\n\n/**\n * @internal\n */\nfunction getMetaInfoFromResponse(\n response: AnalyzeJobState,\n): Omit<AnalyzeActionsOperationMetadata, \"operationId\"> {\n return {\n createdOn: response.createdDateTime,\n lastModifiedOn: response.lastUpdateDateTime,\n expiresOn: response.expirationDateTime,\n status: response.status,\n actionsSucceededCount: response.tasks.completed,\n actionsFailedCount: response.tasks.failed,\n actionsInProgressCount: response.tasks.inProgress,\n displayName: response.displayName,\n };\n}\n\n/**\n * Class that represents a poller that waits for results of the analyze\n * operation.\n * @internal\n */\nexport class BeginAnalyzeActionsPollerOperation extends AnalysisPollOperation<\n AnalyzeActionsOperationState,\n PagedAnalyzeActionsResult\n> {\n constructor(\n public state: AnalyzeActionsOperationState,\n // eslint-disable-next-line @azure/azure-sdk/ts-use-interface-parameters\n private client: Client,\n private tracing: TracingClient,\n private documents: TextDocumentInput[],\n private actions: GeneratedActions,\n private options: BeginAnalyzeActionsOptions = {},\n ) {\n super(state);\n }\n\n /**\n * should be called only after all the status of the analyze actions operations became\n * \"succeeded\" and it returns an iterator for the results and provides a\n * byPage method to return the results paged.\n */\n private listAnalyzeActionsResults(\n operationId: string,\n options: AnalyzeActionsOperationStatusOptions = {},\n ): PagedAsyncIterableAnalyzeActionsResult {\n const iter = this._listAnalyzeActionsResultsPaged(operationId, options);\n return {\n next() {\n return iter.next();\n },\n [Symbol.asyncIterator]() {\n return this;\n },\n byPage: (settings?: PageSettings) => {\n const pageOptions = { ...options, top: settings?.maxPageSize };\n return this._listAnalyzeActionsResultsPaged(operationId, pageOptions);\n },\n };\n }\n\n /**\n * returns an iterator to arrays of the results of an analyze actions operation.\n */\n private async *_listAnalyzeActionsResultsPaged(\n operationId: string,\n options?: AnalyzeActionsOperationStatusOptions,\n ): AsyncIterableIterator<AnalyzeActionsResult> {\n let response = await this._listAnalyzeActionsResultsSinglePage(operationId, options);\n yield response.result;\n while (response.skip) {\n const optionsWithContinuation: AnalyzeActionsOperationStatusOptions = {\n ...options,\n top: response.top,\n skip: response.skip,\n };\n response = await this._listAnalyzeActionsResultsSinglePage(\n operationId,\n optionsWithContinuation,\n );\n yield response.result;\n }\n }\n\n /**\n * returns an iterator to arrays of the sorted results of an analyze actions operation.\n */\n private async _listAnalyzeActionsResultsSinglePage(\n operationId: string,\n options?: AnalyzeActionsOperationStatusOptions,\n ): Promise<AnalyzeResultsWithPagination> {\n const response = await this.tracing.withSpan(\n \"TextAnalyticsClient-_listAnalyzeActionsResultsSinglePage\",\n options || {},\n (finalOptions) => this.client.analyzeStatus(operationId, finalOptions),\n );\n const result = createAnalyzeActionsResult(response, this.documents);\n return response.nextLink ? { result, ...nextLinkToTopAndSkip(response.nextLink) } : { result };\n }\n\n /**\n * returns whether the analyze actions operation is done and if so returns also\n * statistics.\n */\n private async getAnalyzeActionsOperationStatus(\n operationId: string,\n options?: AnalyzeActionsOperationStatusOptions,\n ): Promise<AnalyzeActionsOperationStatus> {\n const response = await this.tracing.withSpan(\n \"TextAnalyticsClient-getAnalyzeActionsOperationStatus\",\n options || {},\n (finalOptions) => this.client.analyzeStatus(operationId, finalOptions),\n );\n switch (response.status) {\n case \"notStarted\":\n case \"running\":\n break;\n default: {\n return {\n done: true,\n statistics: response.statistics,\n operationMetdata: getMetaInfoFromResponse(response),\n };\n }\n }\n return { done: false, operationMetdata: getMetaInfoFromResponse(response) };\n }\n\n private async beginAnalyzeActions(\n documents: TextDocumentInput[],\n actions: GeneratedActions,\n options?: BeginAnalyzeInternalOptions,\n ): Promise<BeginAnalyzeResponse> {\n return this.tracing.withSpan(\n \"TextAnalyticsClient-beginAnalyze\",\n options || {},\n (finalOptions) =>\n throwError(\n this.client.analyze({\n body: {\n analysisInput: { documents: documents },\n tasks: actions,\n displayName: options?.displayName,\n },\n ...finalOptions,\n }),\n ),\n );\n }\n\n async update(\n options: {\n abortSignal?: AbortSignalLike;\n fireProgress?: (state: AnalyzeActionsOperationState) => void;\n } = {},\n ): Promise<BeginAnalyzeActionsPollerOperation> {\n const state = this.state;\n const updatedAbortSignal = options.abortSignal;\n if (!state.isStarted) {\n state.isStarted = true;\n const response = await this.beginAnalyzeActions(this.documents, this.actions, {\n displayName: this.options.displayName,\n tracingOptions: this.options.tracingOptions,\n requestOptions: this.options.requestOptions,\n abortSignal: updatedAbortSignal ? updatedAbortSignal : this.options.abortSignal,\n });\n if (!response.operationLocation) {\n throw new Error(\n \"Expects a valid 'operationLocation' to retrieve analyze results but did not find any\",\n );\n }\n state.operationId = getOperationId(response.operationLocation);\n }\n\n const operationStatus = await this.getAnalyzeActionsOperationStatus(state.operationId!, {\n abortSignal: updatedAbortSignal ? updatedAbortSignal : options.abortSignal,\n includeStatistics: this.options.includeStatistics,\n tracingOptions: this.options.tracingOptions,\n });\n\n state.createdOn = operationStatus.operationMetdata.createdOn;\n state.expiresOn = operationStatus.operationMetdata.expiresOn;\n state.lastModifiedOn = operationStatus.operationMetdata.lastModifiedOn;\n state.status = operationStatus.operationMetdata.status;\n state.actionsSucceededCount = operationStatus.operationMetdata.actionsSucceededCount;\n state.actionsFailedCount = operationStatus.operationMetdata.actionsFailedCount;\n state.actionsInProgressCount = operationStatus.operationMetdata.actionsInProgressCount;\n state.displayName = operationStatus.operationMetdata?.displayName;\n\n if (!state.isCompleted && operationStatus.done) {\n const pagedIterator = this.listAnalyzeActionsResults(state.operationId!, {\n abortSignal: this.options.abortSignal,\n tracingOptions: this.options.tracingOptions,\n includeStatistics: this.options.includeStatistics,\n onResponse: this.options.onResponse,\n serializerOptions: this.options.serializerOptions,\n });\n // Attach stats if the service starts to return them\n // https://github.com/Azure/azure-sdk-for-js/issues/14139\n // state.result = Object.assign(pagedIterator, {\n // statistics: operationStatus.statistics\n // });\n state.result = pagedIterator;\n state.isCompleted = true;\n }\n\n if (typeof options.fireProgress === \"function\") {\n options.fireProgress(state);\n }\n return this;\n }\n\n async cancel(): Promise<BeginAnalyzeActionsPollerOperation> {\n const state = this.state;\n logger.warning(`The service does not yet support cancellation for beginAnalyze.`);\n state.isCancelled = true;\n return this;\n }\n}\n"]}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Licensed under the MIT License.
|
|
3
3
|
import { delay } from "../../util";
|
|
4
4
|
import { AnalysisPoller } from "../poller";
|
|
5
|
-
import { BeginAnalyzeActionsPollerOperation
|
|
5
|
+
import { BeginAnalyzeActionsPollerOperation } from "./operation";
|
|
6
6
|
/**
|
|
7
7
|
* Class that represents a poller that waits for the analyze actions results.
|
|
8
8
|
* @internal
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"poller.js","sourceRoot":"","sources":["../../../../src/lro/analyze/poller.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAKlC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"poller.js","sourceRoot":"","sources":["../../../../src/lro/analyze/poller.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAKlC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAGnC,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE3C,OAAO,EAAE,kCAAkC,EAAE,MAAM,aAAa,CAAC;AAkBjE;;;GAGG;AACH,MAAM,OAAO,yBAA0B,SAAQ,cAG9C;IACC,wEAAwE;IACxE,YAAY,aAA0C;QACpD,MAAM,EACJ,MAAM,EACN,OAAO,EACP,SAAS,EACT,OAAO,EACP,OAAO,EACP,kBAAkB,GAAG,IAAI,EACzB,UAAU,GACX,GAAG,aAAa,CAAC;QAElB,IAAI,KAA+C,CAAC;QAEpD,IAAI,UAAU,EAAE,CAAC;YACf,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC;QACvC,CAAC;QACD,MAAM,SAAS,GAAG,IAAI,kCAAkC,CACtD,CAAC,KAAK,IAAI,EAAE,CAAQ,EACpB,MAAM,EACN,OAAO,EACP,SAAS,EACT,OAAO,EACP,OAAO,CACR,CAAC;QAEF,KAAK,CAAC,SAAS,CAAC,CAAC;QAEjB,IAAI,CAAC,kBAAkB,GAAG,kBAAkB,CAAC;IAC/C,CAAC;IAEM,KAAK;QACV,OAAO,KAAK,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;IACxC,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { PollerLike } from \"@azure/core-lro\";\nimport type { PagedAnalyzeActionsResult } from \"../../analyzeActionsResult\";\nimport type { JobManifestTasks as GeneratedActions } from \"../../generated/models\";\nimport { delay } from \"../../util\";\n\nimport type { AnalysisPollerOptions } from \"../poller\";\nimport { AnalysisPoller } from \"../poller\";\nimport type { AnalyzeActionsOperationState, BeginAnalyzeActionsOptions } from \"./operation\";\nimport { BeginAnalyzeActionsPollerOperation } from \"./operation\";\n\n/**\n * @internal\n */\ninterface AnalyzeActionsPollerOptions extends AnalysisPollerOptions {\n actions: GeneratedActions;\n readonly options: BeginAnalyzeActionsOptions;\n}\n\n/**\n * Result type of the Begin Analyze Actions Long-Running-Operation (LRO).\n */\nexport type AnalyzeActionsPollerLike = PollerLike<\n AnalyzeActionsOperationState,\n PagedAnalyzeActionsResult\n>;\n\n/**\n * Class that represents a poller that waits for the analyze actions results.\n * @internal\n */\nexport class BeginAnalyzeActionsPoller extends AnalysisPoller<\n AnalyzeActionsOperationState,\n PagedAnalyzeActionsResult\n> {\n // eslint-disable-next-line @azure/azure-sdk/ts-use-interface-parameters\n constructor(pollerOptions: AnalyzeActionsPollerOptions) {\n const {\n client,\n tracing,\n documents,\n actions,\n options,\n updateIntervalInMs = 5000,\n resumeFrom,\n } = pollerOptions;\n\n let state: AnalyzeActionsOperationState | undefined;\n\n if (resumeFrom) {\n state = JSON.parse(resumeFrom).state;\n }\n const operation = new BeginAnalyzeActionsPollerOperation(\n (state || {}) as any,\n client,\n tracing,\n documents,\n actions,\n options,\n );\n\n super(operation);\n\n this.updateIntervalInMs = updateIntervalInMs;\n }\n\n public delay(): Promise<void> {\n return delay(this.updateIntervalInMs);\n }\n}\n"]}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
// Licensed under the MIT License.
|
|
3
3
|
import { __asyncDelegator, __asyncGenerator, __asyncValues, __await } from "tslib";
|
|
4
4
|
import { makeHealthcareEntitiesErrorResult, makeHealthcareEntitiesResult, } from "../../analyzeHealthcareEntitiesResult";
|
|
5
|
-
import { addStrEncodingParam, getOperationId, nextLinkToTopAndSkip, throwError
|
|
6
|
-
import { AnalysisPollOperation
|
|
5
|
+
import { addStrEncodingParam, getOperationId, nextLinkToTopAndSkip, throwError } from "../../util";
|
|
6
|
+
import { AnalysisPollOperation } from "../poller";
|
|
7
7
|
import { processAndCombineSuccessfulAndErroneousDocuments } from "../../textAnalyticsResult";
|
|
8
8
|
/**
|
|
9
9
|
* @internal
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operation.js","sourceRoot":"","sources":["../../../../src/lro/health/operation.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;AAYlC,OAAO,EAKL,iCAAiC,EACjC,4BAA4B,GAC7B,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EAEL,mBAAmB,EACnB,cAAc,EACd,oBAAoB,EACpB,UAAU,GACX,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,qBAAqB,GAGtB,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,gDAAgD,EAAE,MAAM,2BAA2B,CAAC;AAiF7F;;GAEG;AACH,SAAS,uBAAuB,CAC9B,QAA4B;IAE5B,OAAO;QACL,SAAS,EAAE,QAAQ,CAAC,eAAe;QACnC,cAAc,EAAE,QAAQ,CAAC,kBAAkB;QAC3C,SAAS,EAAE,QAAQ,CAAC,kBAAkB;QACtC,MAAM,EAAE,QAAQ,CAAC,MAAM;KACxB,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,OAAO,qCAAsC,SAAQ,qBAG1D;IACC,YACS,KAAsC;IAC7C,wEAAwE;IAChE,MAAc,EACd,OAAsB,EACtB,SAA8B,EAC9B,UAAiD,EAAE;QAE3D,KAAK,CAAC,KAAK,CAAC,CAAC;QAPN,UAAK,GAAL,KAAK,CAAiC;QAErC,WAAM,GAAN,MAAM,CAAQ;QACd,YAAO,GAAP,OAAO,CAAe;QACtB,cAAS,GAAT,SAAS,CAAqB;QAC9B,YAAO,GAAP,OAAO,CAA4C;IAG7D,CAAC;IAED;;;;OAIG;IACK,4BAA4B,CAClC,WAAmB,EACnB,UAAsC,EAAE;QAExC,MAAM,IAAI,GAAG,IAAI,CAAC,uBAAuB,CAAC,WA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} from \"@azure/abort-controller\";\nimport { OperationOptions } from \"@azure/core-client\";\n\nimport {\n HealthResponse as BeginAnalyzeHealthcareResponse,\n HealthcareJobState,\n HealthStatusOptionalParams as HealthcareJobStatusOptions,\n TextDocumentBatchStatistics,\n TextDocumentInput,\n} from \"../../generated/models\";\nimport {\n AnalyzeHealthcareEntitiesResult,\n AnalyzeHealthcareEntitiesResultArray,\n PagedAnalyzeHealthcareEntitiesResult,\n PagedAsyncIterableAnalyzeHealthcareEntitiesResult,\n makeHealthcareEntitiesErrorResult,\n makeHealthcareEntitiesResult,\n} from \"../../analyzeHealthcareEntitiesResult\";\nimport { PageSettings } from \"@azure/core-paging\";\nimport {\n StringIndexType,\n addStrEncodingParam,\n getOperationId,\n nextLinkToTopAndSkip,\n throwError,\n} from \"../../util\";\nimport {\n AnalysisPollOperation,\n AnalysisPollOperationState,\n OperationMetadata as AnalyzeHealthcareEntitiesOperationMetadata,\n} from \"../poller\";\nimport { GeneratedClient as Client } from \"../../generated\";\nimport { processAndCombineSuccessfulAndErroneousDocuments } from \"../../textAnalyticsResult\";\nimport { TextAnalyticsOperationOptions } from \"../../textAnalyticsOperationOptions\";\nimport { TracingClient } from \"@azure/core-tracing\";\n\n/**\n * @internal\n */\ninterface AnalyzeHealthcareEntitiesResultWithPagination {\n result: AnalyzeHealthcareEntitiesResultArray;\n top?: number;\n skip?: number;\n}\n\n/**\n * @internal\n */\ninterface HealthcareJobStatus {\n done: boolean;\n /**\n * Statistics about the input document batch and how it was processed\n * by the service. This property will have a value when includeStatistics is set to true\n * in the client call.\n */\n statistics?: TextDocumentBatchStatistics;\n /**\n * The version of the text analytics model used by this operation on this\n * batch of input documents.\n */\n modelVersion?: string;\n operationMetdata: Omit<AnalyzeHealthcareEntitiesOperationMetadata, \"operationId\">;\n}\n\n/**\n * @internal\n */\ninterface BeginAnalyzeHealthcareInternalOptions extends OperationOptions {\n /**\n * This value indicates which model will be used for scoring. If a model-version is\n * not specified, the API should default to the latest, non-preview version.\n * For supported model versions, see operation-specific documentation, for example:\n * https://docs.microsoft.com/azure/cognitive-services/text-analytics/how-tos/text-analytics-how-to-sentiment-analysis#model-versioning\n */\n modelVersion?: string;\n /**\n * Specifies the measurement unit used to calculate the offset and length properties.\n * Possible units are \"TextElements_v8\", \"UnicodeCodePoint\", and \"Utf16CodeUnit\".\n * The default is the JavaScript's default which is \"Utf16CodeUnit\".\n */\n stringIndexType?: StringIndexType;\n /**\n * If set to false, you opt-in to have your text input logged for troubleshooting. By default, Text Analytics\n * will not log your input text for healthcare entities analysis. Setting this parameter to false,\n * enables input logging.\n */\n loggingOptOut?: boolean;\n}\n\n/**\n * Options for the begin analyze healthcare entities operation.\n */\nexport interface BeginAnalyzeHealthcareEntitiesOptions extends TextAnalyticsOperationOptions {\n /**\n * Delay to wait until next poll, in milliseconds.\n */\n stringIndexType?: StringIndexType;\n /**\n * Delay to wait until next poll, in milliseconds.\n */\n updateIntervalInMs?: number;\n /**\n * A serialized poller which can be used to resume an existing paused Long-Running-Operation.\n */\n resumeFrom?: string;\n}\n\n/**\n * The state of the begin analyze healthcare polling operation.\n */\nexport interface AnalyzeHealthcareOperationState\n extends AnalysisPollOperationState<PagedAnalyzeHealthcareEntitiesResult> {}\n\n/**\n * @internal\n */\nfunction getMetaInfoFromResponse(\n response: HealthcareJobState,\n): Omit<AnalyzeHealthcareEntitiesOperationMetadata, \"operationId\"> {\n return {\n createdOn: response.createdDateTime,\n lastModifiedOn: response.lastUpdateDateTime,\n expiresOn: response.expirationDateTime,\n status: response.status,\n };\n}\n\n/**\n * Class that represents a poller that waits for the healthcare results.\n * @internal\n */\nexport class BeginAnalyzeHealthcarePollerOperation extends AnalysisPollOperation<\n AnalyzeHealthcareOperationState,\n PagedAnalyzeHealthcareEntitiesResult\n> {\n constructor(\n public state: AnalyzeHealthcareOperationState,\n // eslint-disable-next-line @azure/azure-sdk/ts-use-interface-parameters\n private client: Client,\n private tracing: TracingClient,\n private documents: TextDocumentInput[],\n private options: BeginAnalyzeHealthcareEntitiesOptions = {},\n ) {\n super(state);\n }\n\n /**\n * should be called only after all the status of the healthcare operations became\n * \"succeeded\" and it returns an iterator for the results and provides a\n * byPage method to return the results paged.\n */\n private listHealthcareEntitiesByPage(\n operationId: string,\n options: HealthcareJobStatusOptions = {},\n ): PagedAsyncIterableAnalyzeHealthcareEntitiesResult {\n const iter = this._listHealthcareEntities(operationId, options);\n return {\n next() {\n return iter.next();\n },\n [Symbol.asyncIterator]() {\n return this;\n },\n byPage: (settings?: PageSettings) => {\n const pageOptions = { ...options, top: settings?.maxPageSize };\n return this._listHealthcareEntitiesPaged(operationId, pageOptions);\n },\n };\n }\n\n /**\n * returns an iterator to the results of a healthcare operation.\n */\n private async *_listHealthcareEntities(\n operationId: string,\n options?: HealthcareJobStatusOptions,\n ): AsyncIterableIterator<AnalyzeHealthcareEntitiesResult> {\n for await (const page of this._listHealthcareEntitiesPaged(operationId, options)) {\n yield* page;\n }\n }\n\n /**\n * returns an iterator to arrays of the results of a healthcare operation.\n */\n private async *_listHealthcareEntitiesPaged(\n operationId: string,\n options?: HealthcareJobStatusOptions,\n ): AsyncIterableIterator<AnalyzeHealthcareEntitiesResultArray> {\n let response = await this._listHealthcareEntitiesSinglePage(operationId, options);\n yield response.result;\n while (response.skip) {\n const optionsWithContinuation: HealthcareJobStatusOptions = {\n ...options,\n top: response.top,\n skip: response.skip,\n };\n response = await this._listHealthcareEntitiesSinglePage(operationId, optionsWithContinuation);\n yield response.result;\n }\n }\n\n /**\n * returns an iterator to arrays of the sorted results of a healthcare operation.\n */\n private async _listHealthcareEntitiesSinglePage(\n operationId: string,\n options?: HealthcareJobStatusOptions,\n ): Promise<AnalyzeHealthcareEntitiesResultWithPagination> {\n const response = await this.tracing.withSpan(\n \"TextAnalyticsClient-_listHealthcareEntitiesSinglePage\",\n options || {},\n (finalOptions) => this.client.healthStatus(operationId, finalOptions),\n );\n if (response.results) {\n const result = processAndCombineSuccessfulAndErroneousDocuments(\n this.documents,\n response.results,\n makeHealthcareEntitiesResult,\n makeHealthcareEntitiesErrorResult,\n );\n return response.nextLink\n ? { result, ...nextLinkToTopAndSkip(response.nextLink) }\n : { result };\n } else {\n throw new Error(\"Healthcare action has succeeded but the there are no results!\");\n }\n }\n\n /**\n * returns whether the healthcare operation is done and if so returns also\n * statistics and the model version used.\n */\n private async getHealthStatus(\n operationId: string,\n options?: HealthcareJobStatusOptions,\n ): Promise<HealthcareJobStatus> {\n const response = await this.tracing.withSpan(\n \"TextAnalyticsClient-getHealthStatus\",\n options || {},\n (finalOptions) => this.client.healthStatus(operationId, finalOptions),\n );\n switch (response.status) {\n case \"notStarted\":\n case \"running\":\n break;\n case \"failed\": {\n const errors = response.errors\n ?.map((e) => ` code ${e.code}, message: '${e.message}'`)\n .join(\"\\n\");\n const message = `Healthcare analysis failed. Error(s): ${errors || \"\"}`;\n throw new Error(message);\n }\n default: {\n if (response.results) {\n return {\n done: true,\n statistics: response.results.statistics,\n modelVersion: response.results.modelVersion,\n operationMetdata: getMetaInfoFromResponse(response),\n };\n } else {\n throw new Error(\"Healthcare action has finished but the there are no results!\");\n }\n }\n }\n return { done: false, operationMetdata: getMetaInfoFromResponse(response) };\n }\n\n private async beginAnalyzeHealthcare(\n documents: TextDocumentInput[],\n options?: BeginAnalyzeHealthcareInternalOptions,\n ): Promise<BeginAnalyzeHealthcareResponse> {\n return this.tracing.withSpan(\n \"TextAnalyticsClient-beginAnalyzeHealthcare\",\n addStrEncodingParam(options || {}),\n (finalOptions) => throwError(this.client.health({ documents: documents }, finalOptions)),\n );\n }\n\n async update(\n options: {\n abortSignal?: AbortSignalLike;\n fireProgress?: (state: AnalyzeHealthcareOperationState) => void;\n } = {},\n ): Promise<BeginAnalyzeHealthcarePollerOperation> {\n const state = this.state;\n const updatedAbortSignal = options.abortSignal;\n if (!state.isStarted) {\n state.isStarted = true;\n const response = await this.beginAnalyzeHealthcare(this.documents, {\n requestOptions: this.options.requestOptions,\n tracingOptions: this.options.tracingOptions,\n abortSignal: updatedAbortSignal ? updatedAbortSignal : options.abortSignal,\n modelVersion: this.options.modelVersion,\n stringIndexType: this.options.stringIndexType,\n loggingOptOut: this.options.disableServiceLogs,\n });\n if (!response.operationLocation) {\n throw new Error(\n \"Expects a valid 'operationLocation' to retrieve health results but did not find any\",\n );\n }\n state.operationId = getOperationId(response.operationLocation);\n }\n const operationStatus = await this.getHealthStatus(state.operationId!, {\n abortSignal: updatedAbortSignal ? updatedAbortSignal : options.abortSignal,\n includeStatistics: this.options.includeStatistics,\n tracingOptions: this.options.tracingOptions,\n onResponse: this.options.onResponse,\n serializerOptions: this.options.serializerOptions,\n });\n\n state.createdOn = operationStatus.operationMetdata.createdOn;\n state.expiresOn = operationStatus.operationMetdata.expiresOn;\n state.lastModifiedOn = operationStatus.operationMetdata.lastModifiedOn;\n state.status = operationStatus.operationMetdata.status;\n\n if (!state.isCompleted && operationStatus.done) {\n const pagedIterator = this.listHealthcareEntitiesByPage(state.operationId!, {\n abortSignal: this.options.abortSignal,\n tracingOptions: this.options.tracingOptions,\n });\n state.result = Object.assign(pagedIterator, {\n statistics: operationStatus.statistics,\n modelVersion: operationStatus.modelVersion!,\n });\n state.isCompleted = true;\n }\n if (typeof options.fireProgress === \"function\") {\n options.fireProgress(state);\n }\n return this;\n }\n\n async cancel(): Promise<BeginAnalyzeHealthcarePollerOperation> {\n const state = this.state;\n if (state.operationId) {\n await this.client.cancelHealthJob(state.operationId, {\n abortSignal: this.options.abortSignal,\n tracingOptions: this.options.tracingOptions,\n });\n }\n state.isCancelled = true;\n return this;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"operation.js","sourceRoot":"","sources":["../../../../src/lro/health/operation.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;AAkBlC,OAAO,EACL,iCAAiC,EACjC,4BAA4B,GAC7B,MAAM,uCAAuC,CAAC;AAG/C,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM,YA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CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,aAAa,EAAE;gBAC1C,UAAU,EAAE,eAAe,CAAC,UAAU;gBACtC,YAAY,EAAE,eAAe,CAAC,YAAa;aAC5C,CAAC,CAAC;YACH,KAAK,CAAC,WAAW,GAAG,IAAI,CAAC;QAC3B,CAAC;QACD,IAAI,OAAO,OAAO,CAAC,YAAY,KAAK,UAAU,EAAE,CAAC;YAC/C,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;QAC9B,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,MAAM;QACV,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QACzB,IAAI,KAAK,CAAC,WAAW,EAAE,CAAC;YACtB,MAAM,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,KAAK,CAAC,WAAW,EAAE;gBACnD,WAAW,EAAE,IAAI,CAAC,OAAO,CAAC,WAAW;gBACrC,cAAc,EAAE,IAAI,CAAC,OAAO,CAAC,cAAc;aAC5C,CAAC,CAAC;QACL,CAAC;QACD,KAAK,CAAC,WAAW,GAAG,IAAI,CAAC;QACzB,OAAO,IAAI,CAAC;IACd,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { AbortSignalLike } from \"@azure/abort-controller\";\nimport type { OperationOptions } from \"@azure/core-client\";\n\nimport type {\n HealthResponse as BeginAnalyzeHealthcareResponse,\n HealthcareJobState,\n HealthStatusOptionalParams as HealthcareJobStatusOptions,\n TextDocumentBatchStatistics,\n TextDocumentInput,\n} from \"../../generated/models\";\nimport type {\n AnalyzeHealthcareEntitiesResult,\n AnalyzeHealthcareEntitiesResultArray,\n PagedAnalyzeHealthcareEntitiesResult,\n PagedAsyncIterableAnalyzeHealthcareEntitiesResult,\n} from \"../../analyzeHealthcareEntitiesResult\";\nimport {\n makeHealthcareEntitiesErrorResult,\n makeHealthcareEntitiesResult,\n} from \"../../analyzeHealthcareEntitiesResult\";\nimport type { PageSettings } from \"@azure/core-paging\";\nimport type { StringIndexType } from \"../../util\";\nimport { addStrEncodingParam, getOperationId, nextLinkToTopAndSkip, throwError } from \"../../util\";\nimport type {\n AnalysisPollOperationState,\n OperationMetadata as AnalyzeHealthcareEntitiesOperationMetadata,\n} from \"../poller\";\nimport { AnalysisPollOperation } from \"../poller\";\nimport type { GeneratedClient as Client } from \"../../generated\";\nimport { processAndCombineSuccessfulAndErroneousDocuments } from \"../../textAnalyticsResult\";\nimport type { TextAnalyticsOperationOptions } from \"../../textAnalyticsOperationOptions\";\nimport type { TracingClient } from \"@azure/core-tracing\";\n\n/**\n * @internal\n */\ninterface AnalyzeHealthcareEntitiesResultWithPagination {\n result: AnalyzeHealthcareEntitiesResultArray;\n top?: number;\n skip?: number;\n}\n\n/**\n * @internal\n */\ninterface HealthcareJobStatus {\n done: boolean;\n /**\n * Statistics about the input document batch and how it was processed\n * by the service. This property will have a value when includeStatistics is set to true\n * in the client call.\n */\n statistics?: TextDocumentBatchStatistics;\n /**\n * The version of the text analytics model used by this operation on this\n * batch of input documents.\n */\n modelVersion?: string;\n operationMetdata: Omit<AnalyzeHealthcareEntitiesOperationMetadata, \"operationId\">;\n}\n\n/**\n * @internal\n */\ninterface BeginAnalyzeHealthcareInternalOptions extends OperationOptions {\n /**\n * This value indicates which model will be used for scoring. If a model-version is\n * not specified, the API should default to the latest, non-preview version.\n * For supported model versions, see operation-specific documentation, for example:\n * https://docs.microsoft.com/azure/cognitive-services/text-analytics/how-tos/text-analytics-how-to-sentiment-analysis#model-versioning\n */\n modelVersion?: string;\n /**\n * Specifies the measurement unit used to calculate the offset and length properties.\n * Possible units are \"TextElements_v8\", \"UnicodeCodePoint\", and \"Utf16CodeUnit\".\n * The default is the JavaScript's default which is \"Utf16CodeUnit\".\n */\n stringIndexType?: StringIndexType;\n /**\n * If set to false, you opt-in to have your text input logged for troubleshooting. By default, Text Analytics\n * will not log your input text for healthcare entities analysis. Setting this parameter to false,\n * enables input logging.\n */\n loggingOptOut?: boolean;\n}\n\n/**\n * Options for the begin analyze healthcare entities operation.\n */\nexport interface BeginAnalyzeHealthcareEntitiesOptions extends TextAnalyticsOperationOptions {\n /**\n * Delay to wait until next poll, in milliseconds.\n */\n stringIndexType?: StringIndexType;\n /**\n * Delay to wait until next poll, in milliseconds.\n */\n updateIntervalInMs?: number;\n /**\n * A serialized poller which can be used to resume an existing paused Long-Running-Operation.\n */\n resumeFrom?: string;\n}\n\n/**\n * The state of the begin analyze healthcare polling operation.\n */\nexport interface AnalyzeHealthcareOperationState\n extends AnalysisPollOperationState<PagedAnalyzeHealthcareEntitiesResult> {}\n\n/**\n * @internal\n */\nfunction getMetaInfoFromResponse(\n response: HealthcareJobState,\n): Omit<AnalyzeHealthcareEntitiesOperationMetadata, \"operationId\"> {\n return {\n createdOn: response.createdDateTime,\n lastModifiedOn: response.lastUpdateDateTime,\n expiresOn: response.expirationDateTime,\n status: response.status,\n };\n}\n\n/**\n * Class that represents a poller that waits for the healthcare results.\n * @internal\n */\nexport class BeginAnalyzeHealthcarePollerOperation extends AnalysisPollOperation<\n AnalyzeHealthcareOperationState,\n PagedAnalyzeHealthcareEntitiesResult\n> {\n constructor(\n public state: AnalyzeHealthcareOperationState,\n // eslint-disable-next-line @azure/azure-sdk/ts-use-interface-parameters\n private client: Client,\n private tracing: TracingClient,\n private documents: TextDocumentInput[],\n private options: BeginAnalyzeHealthcareEntitiesOptions = {},\n ) {\n super(state);\n }\n\n /**\n * should be called only after all the status of the healthcare operations became\n * \"succeeded\" and it returns an iterator for the results and provides a\n * byPage method to return the results paged.\n */\n private listHealthcareEntitiesByPage(\n operationId: string,\n options: HealthcareJobStatusOptions = {},\n ): PagedAsyncIterableAnalyzeHealthcareEntitiesResult {\n const iter = this._listHealthcareEntities(operationId, options);\n return {\n next() {\n return iter.next();\n },\n [Symbol.asyncIterator]() {\n return this;\n },\n byPage: (settings?: PageSettings) => {\n const pageOptions = { ...options, top: settings?.maxPageSize };\n return this._listHealthcareEntitiesPaged(operationId, pageOptions);\n },\n };\n }\n\n /**\n * returns an iterator to the results of a healthcare operation.\n */\n private async *_listHealthcareEntities(\n operationId: string,\n options?: HealthcareJobStatusOptions,\n ): AsyncIterableIterator<AnalyzeHealthcareEntitiesResult> {\n for await (const page of this._listHealthcareEntitiesPaged(operationId, options)) {\n yield* page;\n }\n }\n\n /**\n * returns an iterator to arrays of the results of a healthcare operation.\n */\n private async *_listHealthcareEntitiesPaged(\n operationId: string,\n options?: HealthcareJobStatusOptions,\n ): AsyncIterableIterator<AnalyzeHealthcareEntitiesResultArray> {\n let response = await this._listHealthcareEntitiesSinglePage(operationId, options);\n yield response.result;\n while (response.skip) {\n const optionsWithContinuation: HealthcareJobStatusOptions = {\n ...options,\n top: response.top,\n skip: response.skip,\n };\n response = await this._listHealthcareEntitiesSinglePage(operationId, optionsWithContinuation);\n yield response.result;\n }\n }\n\n /**\n * returns an iterator to arrays of the sorted results of a healthcare operation.\n */\n private async _listHealthcareEntitiesSinglePage(\n operationId: string,\n options?: HealthcareJobStatusOptions,\n ): Promise<AnalyzeHealthcareEntitiesResultWithPagination> {\n const response = await this.tracing.withSpan(\n \"TextAnalyticsClient-_listHealthcareEntitiesSinglePage\",\n options || {},\n (finalOptions) => this.client.healthStatus(operationId, finalOptions),\n );\n if (response.results) {\n const result = processAndCombineSuccessfulAndErroneousDocuments(\n this.documents,\n response.results,\n makeHealthcareEntitiesResult,\n makeHealthcareEntitiesErrorResult,\n );\n return response.nextLink\n ? { result, ...nextLinkToTopAndSkip(response.nextLink) }\n : { result };\n } else {\n throw new Error(\"Healthcare action has succeeded but the there are no results!\");\n }\n }\n\n /**\n * returns whether the healthcare operation is done and if so returns also\n * statistics and the model version used.\n */\n private async getHealthStatus(\n operationId: string,\n options?: HealthcareJobStatusOptions,\n ): Promise<HealthcareJobStatus> {\n const response = await this.tracing.withSpan(\n \"TextAnalyticsClient-getHealthStatus\",\n options || {},\n (finalOptions) => this.client.healthStatus(operationId, finalOptions),\n );\n switch (response.status) {\n case \"notStarted\":\n case \"running\":\n break;\n case \"failed\": {\n const errors = response.errors\n ?.map((e) => ` code ${e.code}, message: '${e.message}'`)\n .join(\"\\n\");\n const message = `Healthcare analysis failed. Error(s): ${errors || \"\"}`;\n throw new Error(message);\n }\n default: {\n if (response.results) {\n return {\n done: true,\n statistics: response.results.statistics,\n modelVersion: response.results.modelVersion,\n operationMetdata: getMetaInfoFromResponse(response),\n };\n } else {\n throw new Error(\"Healthcare action has finished but the there are no results!\");\n }\n }\n }\n return { done: false, operationMetdata: getMetaInfoFromResponse(response) };\n }\n\n private async beginAnalyzeHealthcare(\n documents: TextDocumentInput[],\n options?: BeginAnalyzeHealthcareInternalOptions,\n ): Promise<BeginAnalyzeHealthcareResponse> {\n return this.tracing.withSpan(\n \"TextAnalyticsClient-beginAnalyzeHealthcare\",\n addStrEncodingParam(options || {}),\n (finalOptions) => throwError(this.client.health({ documents: documents }, finalOptions)),\n );\n }\n\n async update(\n options: {\n abortSignal?: AbortSignalLike;\n fireProgress?: (state: AnalyzeHealthcareOperationState) => void;\n } = {},\n ): Promise<BeginAnalyzeHealthcarePollerOperation> {\n const state = this.state;\n const updatedAbortSignal = options.abortSignal;\n if (!state.isStarted) {\n state.isStarted = true;\n const response = await this.beginAnalyzeHealthcare(this.documents, {\n requestOptions: this.options.requestOptions,\n tracingOptions: this.options.tracingOptions,\n abortSignal: updatedAbortSignal ? updatedAbortSignal : options.abortSignal,\n modelVersion: this.options.modelVersion,\n stringIndexType: this.options.stringIndexType,\n loggingOptOut: this.options.disableServiceLogs,\n });\n if (!response.operationLocation) {\n throw new Error(\n \"Expects a valid 'operationLocation' to retrieve health results but did not find any\",\n );\n }\n state.operationId = getOperationId(response.operationLocation);\n }\n const operationStatus = await this.getHealthStatus(state.operationId!, {\n abortSignal: updatedAbortSignal ? updatedAbortSignal : options.abortSignal,\n includeStatistics: this.options.includeStatistics,\n tracingOptions: this.options.tracingOptions,\n onResponse: this.options.onResponse,\n serializerOptions: this.options.serializerOptions,\n });\n\n state.createdOn = operationStatus.operationMetdata.createdOn;\n state.expiresOn = operationStatus.operationMetdata.expiresOn;\n state.lastModifiedOn = operationStatus.operationMetdata.lastModifiedOn;\n state.status = operationStatus.operationMetdata.status;\n\n if (!state.isCompleted && operationStatus.done) {\n const pagedIterator = this.listHealthcareEntitiesByPage(state.operationId!, {\n abortSignal: this.options.abortSignal,\n tracingOptions: this.options.tracingOptions,\n });\n state.result = Object.assign(pagedIterator, {\n statistics: operationStatus.statistics,\n modelVersion: operationStatus.modelVersion!,\n });\n state.isCompleted = true;\n }\n if (typeof options.fireProgress === \"function\") {\n options.fireProgress(state);\n }\n return this;\n }\n\n async cancel(): Promise<BeginAnalyzeHealthcarePollerOperation> {\n const state = this.state;\n if (state.operationId) {\n await this.client.cancelHealthJob(state.operationId, {\n abortSignal: this.options.abortSignal,\n tracingOptions: this.options.tracingOptions,\n });\n }\n state.isCancelled = true;\n return this;\n }\n}\n"]}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Licensed under the MIT License.
|
|
3
3
|
import { delay } from "../../util";
|
|
4
4
|
import { AnalysisPoller } from "../poller";
|
|
5
|
-
import { BeginAnalyzeHealthcarePollerOperation
|
|
5
|
+
import { BeginAnalyzeHealthcarePollerOperation } from "./operation";
|
|
6
6
|
/**
|
|
7
7
|
* Class that represents a poller that waits for the healthcare results.
|
|
8
8
|
* @internal
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"poller.js","sourceRoot":"","sources":["../../../../src/lro/health/poller.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAKlC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"poller.js","sourceRoot":"","sources":["../../../../src/lro/health/poller.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAKlC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAGnC,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAK3C,OAAO,EAAE,qCAAqC,EAAE,MAAM,aAAa,CAAC;AAyEpE;;;GAGG;AACH,MAAM,OAAO,4BAA6B,SAAQ,cAGjD;IACC,wEAAwE;IACxE,YAAY,MAA+B;QACzC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,kBAAkB,GAAG,IAAI,EAAE,UAAU,EAAE,GAAG,MAAM,CAAC;QAE9F,IAAI,KAAkD,CAAC;QAEvD,IAAI,UAAU,EAAE,CAAC;YACf,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC;QACvC,CAAC;QACD,MAAM,SAAS,GAAG,IAAI,qCAAqC,CACzD,CAAC,KAAK,IAAI,EAAE,CAAQ,EACpB,MAAM,EACN,OAAO,EACP,SAAS,EACT,OAAO,CACR,CAAC;QAEF,KAAK,CAAC,SAAS,CAAC,CAAC;QAEjB,IAAI,CAAC,kBAAkB,GAAG,kBAAkB,CAAC;IAC/C,CAAC;IAEM,KAAK;QACV,OAAO,KAAK,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;IACxC,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { AbortSignalLike } from \"@azure/abort-controller\";\nimport type { CancelOnProgress, PollOperationState } from \"@azure/core-lro\";\nimport type { PagedAnalyzeHealthcareEntitiesResult } from \"../../analyzeHealthcareEntitiesResult\";\nimport { delay } from \"../../util\";\n\nimport type { AnalysisPollerOptions } from \"../poller\";\nimport { AnalysisPoller } from \"../poller\";\nimport type {\n AnalyzeHealthcareOperationState,\n BeginAnalyzeHealthcareEntitiesOptions,\n} from \"./operation\";\nimport { BeginAnalyzeHealthcarePollerOperation } from \"./operation\";\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 PollerLikeWithCancellation<TState extends PollOperationState<TResult>, TResult> {\n /**\n * Returns a promise that will resolve once a single polling request finishes.\n * It does this by calling the update method of the Poller's operation.\n */\n poll(options?: { abortSignal?: AbortSignalLike }): Promise<void>;\n /**\n * Returns a promise that will resolve once the underlying operation is completed.\n */\n pollUntilDone(): Promise<TResult>;\n /**\n * Invokes the provided callback after each polling is completed,\n * sending the current state of the poller's operation.\n *\n * It returns a method that can be used to stop receiving updates on the given callback function.\n */\n onProgress(callback: (state: TState) => void): CancelOnProgress;\n /**\n * Returns true if the poller has finished polling.\n */\n isDone(): boolean;\n /**\n * Stops the poller. After this, no manual or automated requests can be sent.\n */\n stopPolling(): void;\n /**\n * Returns true if the poller is stopped.\n */\n isStopped(): boolean;\n /**\n * Attempts to cancel the underlying operation.\n */\n cancelOperation(options?: { abortSignal?: AbortSignalLike }): Promise<void>;\n /**\n * Returns the state of the operation.\n * The TState defined in PollerLike can be a subset of the TState defined in\n * the Poller implementation.\n */\n getOperationState(): TState;\n /**\n * Returns the result value of the operation,\n * regardless of the state of the poller.\n * It can return undefined or an incomplete form of the final TResult value\n * depending on the implementation.\n */\n getResult(): TResult | undefined;\n /**\n * Returns a serialized version of the poller's operation\n * by invoking the operation's toString method.\n */\n toString(): string;\n}\n\n/**\n * @internal\n */\ninterface HealthcarePollerOptions extends AnalysisPollerOptions {\n readonly options?: BeginAnalyzeHealthcareEntitiesOptions;\n}\n\n/**\n * Result type of the Health Long-Running-Operation (LRO)\n */\nexport type AnalyzeHealthcareEntitiesPollerLike = PollerLikeWithCancellation<\n AnalyzeHealthcareOperationState,\n PagedAnalyzeHealthcareEntitiesResult\n>;\n\n/**\n * Class that represents a poller that waits for the healthcare results.\n * @internal\n */\nexport class BeginAnalyzeHealthcarePoller extends AnalysisPoller<\n AnalyzeHealthcareOperationState,\n PagedAnalyzeHealthcareEntitiesResult\n> {\n // eslint-disable-next-line @azure/azure-sdk/ts-use-interface-parameters\n constructor(inputs: HealthcarePollerOptions) {\n const { client, tracing, documents, options, updateIntervalInMs = 5000, resumeFrom } = inputs;\n\n let state: AnalyzeHealthcareOperationState | undefined;\n\n if (resumeFrom) {\n state = JSON.parse(resumeFrom).state;\n }\n const operation = new BeginAnalyzeHealthcarePollerOperation(\n (state || {}) as any,\n client,\n tracing,\n documents,\n options,\n );\n\n super(operation);\n\n this.updateIntervalInMs = updateIntervalInMs;\n }\n\n public delay(): Promise<void> {\n return delay(this.updateIntervalInMs);\n }\n}\n"]}
|