@azure/ai-text-analytics 5.2.0-beta.1 → 5.2.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/README.md +3 -1
  3. package/dist/index.js +919 -234
  4. package/dist/index.js.map +1 -1
  5. package/dist-esm/src/analyzeActionsResult.js +48 -10
  6. package/dist-esm/src/analyzeActionsResult.js.map +1 -1
  7. package/dist-esm/src/analyzeLro.js +18 -16
  8. package/dist-esm/src/analyzeLro.js.map +1 -1
  9. package/dist-esm/src/generated/generatedClientContext.js +2 -2
  10. package/dist-esm/src/generated/generatedClientContext.js.map +1 -1
  11. package/dist-esm/src/generated/models/index.js.map +1 -1
  12. package/dist-esm/src/generated/models/mappers.js +620 -1
  13. package/dist-esm/src/generated/models/mappers.js.map +1 -1
  14. package/dist-esm/src/generated/models/parameters.js +2 -1
  15. package/dist-esm/src/generated/models/parameters.js.map +1 -1
  16. package/dist-esm/src/healthLro.js +23 -15
  17. package/dist-esm/src/healthLro.js.map +1 -1
  18. package/dist-esm/src/index.js.map +1 -1
  19. package/dist-esm/src/multiCategoryClassifyResult.js +17 -0
  20. package/dist-esm/src/multiCategoryClassifyResult.js.map +1 -0
  21. package/dist-esm/src/multiCategoryClassifyResultArray.js +11 -0
  22. package/dist-esm/src/multiCategoryClassifyResultArray.js.map +1 -0
  23. package/dist-esm/src/recognizeCustomEntitiesResult.js +17 -0
  24. package/dist-esm/src/recognizeCustomEntitiesResult.js.map +1 -0
  25. package/dist-esm/src/recognizeCustomEntitiesResultArray.js +11 -0
  26. package/dist-esm/src/recognizeCustomEntitiesResultArray.js.map +1 -0
  27. package/dist-esm/src/singleCategoryClassifyResult.js +17 -0
  28. package/dist-esm/src/singleCategoryClassifyResult.js.map +1 -0
  29. package/dist-esm/src/singleCategoryClassifyResultArray.js +11 -0
  30. package/dist-esm/src/singleCategoryClassifyResultArray.js.map +1 -0
  31. package/dist-esm/src/textAnalyticsAction.js.map +1 -1
  32. package/dist-esm/src/textAnalyticsClient.js +7 -19
  33. package/dist-esm/src/textAnalyticsClient.js.map +1 -1
  34. package/dist-esm/src/textAnalyticsResult.js +16 -0
  35. package/dist-esm/src/textAnalyticsResult.js.map +1 -1
  36. package/dist-esm/src/util.js +28 -44
  37. package/dist-esm/src/util.js.map +1 -1
  38. package/package.json +7 -9
  39. package/types/ai-text-analytics.d.ts +348 -40
  40. package/dist-esm/src/paging.js +0 -83
  41. package/dist-esm/src/paging.js.map +0 -1
  42. package/dist-esm/src/utils/url.browser.js +0 -6
  43. package/dist-esm/src/utils/url.browser.js.map +0 -1
  44. package/dist-esm/src/utils/url.js +0 -4
  45. package/dist-esm/src/utils/url.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"textAnalyticsClient.js","sourceRoot":"","sources":["../../src/textAnalyticsClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;AAGlC,OAAO,EAEL,+BAA+B,EAChC,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAkC,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrF,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAalC,OAAO,EAEL,6BAA6B,EAC9B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAEL,2CAA2C,EAC5C,MAAM,2CAA2C,CAAC;AACnD,OAAO,EAEL,+BAA+B,EAChC,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,gCAAgC,EAEjC,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAEL,mCAAmC,EACpC,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAEL,sCAAsC,EACvC,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC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C,MAAM,CAAC,eAAe,CAAC;KAClE,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { CommonClientOptions } from \"@azure/core-client\";\nimport {\n InternalPipelineOptions,\n bearerTokenAuthenticationPolicy\n} from \"@azure/core-rest-pipeline\";\nimport { TokenCredential, KeyCredential, isTokenCredential } from \"@azure/core-auth\";\nimport { GeneratedClient } from \"./generated/generatedClient\";\nimport { logger } from \"./logger\";\nimport {\n JobManifestTasks as GeneratedActions,\n DetectLanguageInput,\n GeneratedClientEntitiesRecognitionPiiOptionalParams as GeneratedRecognizePiiEntitiesOptions,\n GeneratedClientSentimentOptionalParams as GeneratedAnalyzeSentimentOptions,\n GeneratedClientEntitiesRecognitionGeneralOptionalParams as GeneratedRecognizeCategorizedEntitiesOptions,\n GeneratedClientEntitiesLinkingOptionalParams as GeneratedRecognizeLinkedEntitiesOptions,\n GeneratedClientKeyPhrasesOptionalParams as GeneratedExtractKeyPhrasesOptions,\n GeneratedClientLanguagesOptionalParams as GeneratedDetectLanguageOptions,\n TextDocumentInput,\n PiiCategory\n} from \"./generated/models\";\nimport {\n DetectLanguageResultArray,\n makeDetectLanguageResultArray\n} from \"./detectLanguageResultArray\";\nimport {\n RecognizeCategorizedEntitiesResultArray,\n makeRecognizeCategorizedEntitiesResultArray\n} from \"./recognizeCategorizedEntitiesResultArray\";\nimport {\n AnalyzeSentimentResultArray,\n makeAnalyzeSentimentResultArray\n} from \"./analyzeSentimentResultArray\";\nimport {\n makeExtractKeyPhrasesResultArray,\n ExtractKeyPhrasesResultArray\n} from \"./extractKeyPhrasesResultArray\";\nimport {\n RecognizePiiEntitiesResultArray,\n makeRecognizePiiEntitiesResultArray\n} from \"./recognizePiiEntitiesResultArray\";\nimport {\n RecognizeLinkedEntitiesResultArray,\n makeRecognizeLinkedEntitiesResultArray\n} from \"./recognizeLinkedEntitiesResultArray\";\nimport { createSpan } from \"./tracing\";\nimport { SpanStatusCode } from \"@azure/core-tracing\";\nimport { textAnalyticsAzureKeyCredentialPolicy } from \"./azureKeyCredentialPolicy\";\nimport {\n addParamsToTask,\n compose,\n handleInvalidDocumentBatch,\n setCategoriesFilter,\n setOpinionMining,\n setOrderBy,\n setSentenceCount,\n setStrEncodingParam,\n setStrEncodingParamValue,\n StringIndexType\n} from \"./util\";\nimport { TextAnalyticsOperationOptions } from \"./textAnalyticsOperationOptions\";\nimport { AnalysisPollOperationState, OperationMetadata } from \"./pollerModels\";\nimport { TextAnalyticsAction } from \"./textAnalyticsAction\";\nimport {\n AnalyzeHealthcareEntitiesPollerLike,\n AnalyzeHealthcareOperationState,\n BeginAnalyzeHealthcareEntitiesOptions,\n HealthLro,\n isHealthDone,\n processHealthResult,\n updateHealthState\n} from \"./healthLro\";\nimport { LroEngine } from \"@azure/core-lro\";\nimport { PagedAnalyzeHealthcareEntitiesResult } from \"./analyzeHealthcareEntitiesResult\";\nimport {\n AnalyzeActionsOperationMetadata,\n AnalyzeActionsOperationState,\n AnalyzeActionsPollerLike,\n AnalyzeLro,\n BeginAnalyzeActionsOptions,\n isAnalyzeDone,\n processAnalyzeResult,\n updateAnalyzeState\n} from \"./analyzeLro\";\nimport { PagedAnalyzeActionsResult } from \"./analyzeActionsResult\";\n\nexport {\n BeginAnalyzeActionsOptions,\n AnalyzeActionsPollerLike,\n AnalyzeActionsOperationState,\n BeginAnalyzeHealthcareEntitiesOptions,\n AnalyzeHealthcareEntitiesPollerLike,\n AnalyzeHealthcareOperationState,\n AnalysisPollOperationState,\n OperationMetadata,\n AnalyzeActionsOperationMetadata,\n StringIndexType\n};\n\nconst DEFAULT_COGNITIVE_SCOPE = \"https://cognitiveservices.azure.com/.default\";\n\n/**\n * Client options used to configure TextAnalytics API requests.\n */\nexport interface TextAnalyticsClientOptions extends CommonClientOptions {\n /**\n * The default country hint to use. Defaults to \"us\".\n */\n defaultCountryHint?: string;\n\n /**\n * The default language to use. Defaults to \"en\".\n */\n defaultLanguage?: string;\n}\n\n/**\n * Options for the detect languages operation.\n */\nexport interface DetectLanguageOptions extends TextAnalyticsOperationOptions {}\n\n/**\n * Options for the recognize entities operation.\n */\nexport interface RecognizeCategorizedEntitiesOptions extends TextAnalyticsOperationOptions {\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\n/**\n * Options for the analyze sentiment operation.\n */\nexport interface AnalyzeSentimentOptions extends TextAnalyticsOperationOptions {\n /**\n * Whether to mine the opinions of a sentence and conduct more granular\n * analysis around the aspects of a product or service (also known as\n * aspect-based sentiment analysis). If set to true, the returned\n * `SentenceSentiment` objects will have property `opinions` containing\n * the result of this analysis.\n * More information about the feature can be found here: {@link https://docs.microsoft.com/azure/cognitive-services/text-analytics/how-tos/text-analytics-how-to-sentiment-analysis?tabs=version-3-1#opinion-mining}\n */\n includeOpinionMining?: boolean;\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\n/**\n * The types of PII domains the user can choose from.\n */\nexport enum PiiEntityDomain {\n /**\n * @see {@link https://aka.ms/tanerpii} for more information.\n */\n PROTECTED_HEALTH_INFORMATION = \"PHI\"\n}\n\n/**\n * Options for the recognize PII entities operation.\n */\nexport interface RecognizePiiEntitiesOptions extends TextAnalyticsOperationOptions {\n /**\n * Filters entities to ones only included in the specified domain (e.g., if\n * set to 'PHI', entities in the Protected Healthcare Information domain will\n * only be returned). @see {@link https://aka.ms/tanerpii} for more information.\n */\n domainFilter?: PiiEntityDomain;\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 * Filters entities to ones only included in the specified array of categories\n */\n categoriesFilter?: PiiCategory[];\n}\n\n/**\n * Options for the extract key phrases operation.\n */\nexport interface ExtractKeyPhrasesOptions extends TextAnalyticsOperationOptions {}\n\n/**\n * Options for the recognize linked entities operation.\n */\nexport interface RecognizeLinkedEntitiesOptions extends TextAnalyticsOperationOptions {\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\n/**\n * Options for an entities recognition action.\n */\nexport interface RecognizeCategorizedEntitiesAction extends TextAnalyticsAction {\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 true, you opt-out of having your text input logged for troubleshooting. By default, Text Analytics\n * logs your input text for 48 hours, solely to allow for troubleshooting issues. Setting this parameter to true,\n * disables input logging and may limit our ability to remediate issues that occur.\n */\n disableServiceLogs?: boolean;\n}\n\n/**\n * Options for a Pii entities recognition action.\n */\nexport interface RecognizePiiEntitiesAction extends TextAnalyticsAction {\n /**\n * Filters entities to ones only included in the specified domain (e.g., if\n * set to 'PHI', entities in the Protected Healthcare Information domain will\n * only be returned). @see {@link https://aka.ms/tanerpii} for more information.\n */\n domainFilter?: PiiEntityDomain;\n /**\n * Filters entities to ones only included in the specified array of categories\n */\n categoriesFilter?: PiiCategory[];\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 pii entities recognition. Setting this parameter to false,\n * enables input logging.\n */\n disableServiceLogs?: boolean;\n}\n\n/**\n * Options for a key phrases recognition action.\n */\nexport interface ExtractKeyPhrasesAction extends TextAnalyticsAction {\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 pii entities recognition. Setting this parameter to false,\n * enables input logging.\n */\n disableServiceLogs?: boolean;\n}\n\n/**\n * Options for an entities linking action.\n */\nexport interface RecognizeLinkedEntitiesAction extends TextAnalyticsAction {\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 true, you opt-out of having your text input logged for troubleshooting. By default, Text Analytics\n * logs your input text for 48 hours, solely to allow for troubleshooting issues. Setting this parameter to true,\n * disables input logging and may limit our ability to remediate issues that occur.\n */\n disableServiceLogs?: boolean;\n}\n\n/**\n * Options for an analyze sentiment action.\n */\nexport interface AnalyzeSentimentAction extends TextAnalyticsAction {\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 true, you opt-out of having your text input logged for troubleshooting. By default, Text Analytics\n * logs your input text for 48 hours, solely to allow for troubleshooting issues. Setting this parameter to true,\n * disables input logging and may limit our ability to remediate issues that occur.\n */\n disableServiceLogs?: boolean;\n /**\n * Whether to mine the opinions of a sentence and conduct more granular\n * analysis around the aspects of a product or service (also known as\n * aspect-based sentiment analysis). If set to true, the returned\n * `SentenceSentiment` objects will have property `opinions` containing\n * the result of this analysis.\n * More information about the feature can be found here: {@link https://docs.microsoft.com/azure/cognitive-services/text-analytics/how-tos/text-analytics-how-to-sentiment-analysis?tabs=version-3-1#opinion-mining}\n */\n includeOpinionMining?: boolean;\n}\n\n/**\n * A type representing how to sort sentences for the summarization extraction action.\n */\nexport type KnownSummarySentencesSortBy = \"Offset\" | \"Rank\";\n\n/**\n * Options for an extract summary action.\n */\nexport interface ExtractSummaryAction extends TextAnalyticsAction {\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 true, you opt-out of having your text input logged for troubleshooting. By default, Text Analytics\n * logs your input text for 48 hours, solely to allow for troubleshooting issues. Setting this parameter to true,\n * disables input logging and may limit our ability to remediate issues that occur.\n */\n disableServiceLogs?: boolean;\n /**\n * Specifies the number of summary sentences to return. The default number of sentences is 3.\n */\n maxSentenceCount?: number;\n /**\n * Specifies how to sort the returned sentences. Please refer to {@link KnownSummarySentencesSortBy} for possible values.\n */\n orderBy?: string;\n}\n\n/**\n * Description of collection of actions for the analyze API to perform on input documents. However, currently, the service can accept up to one action only per action type.\n */\nexport interface TextAnalyticsActions {\n /**\n * A collection of descriptions of entities recognition actions. However, currently, the service can accept up to one action only for `recognizeEntities`.\n */\n recognizeEntitiesActions?: RecognizeCategorizedEntitiesAction[];\n /**\n * A collection of descriptions of Pii entities recognition actions. However, currently, the service can accept up to one action only for `recognizePiiEntities`.\n */\n recognizePiiEntitiesActions?: RecognizePiiEntitiesAction[];\n /**\n * A collection of descriptions of key phrases recognition actions. However, currently, the service can accept up to one action only for `extractKeyPhrases`.\n */\n extractKeyPhrasesActions?: ExtractKeyPhrasesAction[];\n /**\n * A collection of descriptions of entities linking actions. However, currently, the service can accept up to one action only for `recognizeLinkedEntities`.\n */\n recognizeLinkedEntitiesActions?: RecognizeLinkedEntitiesAction[];\n /**\n * A collection of descriptions of sentiment analysis actions. However, currently, the service can accept up to one action only for `analyzeSentiment`.\n */\n analyzeSentimentActions?: AnalyzeSentimentAction[];\n /**\n * A collection of descriptions of summarization extraction actions. However, currently, the service can accept up to one action only for `extractSummary`.\n */\n extractSummaryActions?: ExtractSummaryAction[];\n}\n/**\n * Client class for interacting with Azure Text Analytics.\n */\nexport class TextAnalyticsClient {\n /**\n * The URL to the TextAnalytics endpoint\n */\n public readonly endpointUrl: string;\n\n /**\n * The default country hint to use. Defaults to \"us\".\n */\n public defaultCountryHint: string;\n\n /**\n * The default language to use. Defaults to \"en\".\n */\n public defaultLanguage: string;\n\n /**\n * @internal\n * A reference to the auto-generated TextAnalytics HTTP client.\n */\n private readonly client: GeneratedClient;\n\n /**\n * Creates an instance of TextAnalyticsClient.\n *\n * Example usage:\n * ```ts\n * import { TextAnalyticsClient, AzureKeyCredential } from \"@azure/ai-text-analytics\";\n *\n * const client = new TextAnalyticsClient(\n * \"<service endpoint>\",\n * new AzureKeyCredential(\"<api key>\")\n * );\n * ```\n * @param endpointUrl - The URL to the TextAnalytics endpoint\n * @param credential - Used to authenticate requests to the service.\n * @param options - Used to configure the TextAnalytics client.\n */\n constructor(\n endpointUrl: string,\n credential: TokenCredential | KeyCredential,\n options: TextAnalyticsClientOptions = {}\n ) {\n this.endpointUrl = endpointUrl;\n const { defaultCountryHint = \"us\", defaultLanguage = \"en\", ...pipelineOptions } = options;\n this.defaultCountryHint = defaultCountryHint;\n this.defaultLanguage = defaultLanguage;\n\n const internalPipelineOptions: InternalPipelineOptions = {\n ...pipelineOptions,\n ...{\n loggingOptions: {\n logger: logger.info,\n additionalAllowedHeaderNames: [\"x-ms-correlation-request-id\", \"x-ms-request-id\"]\n }\n }\n };\n\n this.client = new GeneratedClient(this.endpointUrl, internalPipelineOptions);\n\n const authPolicy = isTokenCredential(credential)\n ? bearerTokenAuthenticationPolicy({ credential, scopes: DEFAULT_COGNITIVE_SCOPE })\n : textAnalyticsAzureKeyCredentialPolicy(credential);\n\n this.client.pipeline.addPolicy(authPolicy);\n }\n\n /**\n * Runs a predictive model to determine the language that the passed-in\n * input strings are written in, and returns, for each one, the detected\n * language as well as a score indicating the model's confidence that the\n * inferred language is correct. Scores close to 1 indicate high certainty in\n * the result. 120 languages are supported.\n * @param documents - A collection of input strings to analyze.\n * @param countryHint - Indicates the country of origin for all of\n * the input strings to assist the text analytics model in predicting\n * the language they are written in. If unspecified, this value will be\n * set to the default country hint in `TextAnalyticsClientOptions`.\n * If set to an empty string, or the string \"none\", the service will apply a\n * model where the country is explicitly unset.\n * The same country hint is applied to all strings in the input collection.\n * @param options - Optional parameters for the operation.\n */\n public async detectLanguage(\n documents: string[],\n countryHint?: string,\n options?: DetectLanguageOptions\n ): Promise<DetectLanguageResultArray>;\n /**\n * Runs a predictive model to determine the language that the passed-in\n * input document are written in, and returns, for each one, the detected\n * language as well as a score indicating the model's confidence that the\n * inferred language is correct. Scores close to 1 indicate high certainty in\n * the result. 120 languages are supported.\n * @param documents - A collection of input documents to analyze.\n * @param options - Optional parameters for the operation.\n */\n public async detectLanguage(\n documents: DetectLanguageInput[],\n options?: DetectLanguageOptions\n ): Promise<DetectLanguageResultArray>;\n public async detectLanguage(\n documents: string[] | DetectLanguageInput[],\n countryHintOrOptions?: string | DetectLanguageOptions,\n options?: DetectLanguageOptions\n ): Promise<DetectLanguageResultArray> {\n let realOptions: DetectLanguageOptions;\n let realInputs: DetectLanguageInput[];\n\n if (!Array.isArray(documents) || documents.length === 0) {\n throw new Error(\"'documents' must be a non-empty array\");\n }\n\n if (isStringArray(documents)) {\n const countryHint = (countryHintOrOptions as string) || this.defaultCountryHint;\n realInputs = convertToDetectLanguageInput(documents, countryHint);\n realOptions = options || {};\n } else {\n // Replace \"none\" hints with \"\"\n realInputs = documents.map((input) => ({\n ...input,\n countryHint: input.countryHint === \"none\" ? \"\" : input.countryHint\n }));\n realOptions = (countryHintOrOptions as DetectLanguageOptions) || {};\n }\n\n const { span, updatedOptions: finalOptions } = createSpan(\n \"TextAnalyticsClient-detectLanguages\",\n makeGeneratedDetectLanguageOptions(realOptions)\n );\n\n try {\n const result = await this.client.languages(\n {\n documents: realInputs\n },\n finalOptions\n );\n\n return makeDetectLanguageResultArray(realInputs, result);\n } catch (e) {\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: e.message\n });\n throw e;\n } finally {\n span.end();\n }\n }\n\n /**\n * Runs a predictive model to identify a collection of named entities\n * in the passed-in input strings, and categorize those entities into types\n * such as person, location, or organization. For more information on \n * available categories, @see\n * {@link https://docs.microsoft.com/azure/cognitive-services/Text-Analytics/named-entity-types}.\n * For a list of languages supported by this operation, @see\n * {@link https://docs.microsoft.com/azure/cognitive-services/text-analytics/language-support}.\n * @param documents - The input strings to analyze.\n * @param language - The language that all the input strings are\n written in. If unspecified, this value will be set to the default\n language in `TextAnalyticsClientOptions`. \n If set to an empty string, the service will apply a model\n where the language is explicitly set to \"None\".\n * @param options - Optional parameters for the operation.\n */\n public async recognizeEntities(\n documents: string[],\n language?: string,\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n options?: RecognizeCategorizedEntitiesOptions\n ): Promise<RecognizeCategorizedEntitiesResultArray>;\n /**\n * Runs a predictive model to identify a collection of named entities\n * in the passed-in input documents, and categorize those entities into types\n * such as person, location, or organization. For more information on\n * available categories, @see\n * {@link https://docs.microsoft.com/azure/cognitive-services/Text-Analytics/named-entity-types}.\n * For a list of languages supported by this operation, @see\n * {@link https://docs.microsoft.com/azure/cognitive-services/text-analytics/language-support}.\n * @param documents - The input documents to analyze.\n * @param options - Optional parameters for the operation.\n */\n public async recognizeEntities(\n documents: TextDocumentInput[],\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n options?: RecognizeCategorizedEntitiesOptions\n ): Promise<RecognizeCategorizedEntitiesResultArray>;\n public async recognizeEntities(\n documents: string[] | TextDocumentInput[],\n languageOrOptions?: string | RecognizeCategorizedEntitiesOptions,\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n options?: RecognizeCategorizedEntitiesOptions\n ): Promise<RecognizeCategorizedEntitiesResultArray> {\n let realOptions: RecognizeCategorizedEntitiesOptions;\n let realInputs: TextDocumentInput[];\n\n if (!Array.isArray(documents) || documents.length === 0) {\n throw new Error(\"'documents' must be a non-empty array\");\n }\n\n if (isStringArray(documents)) {\n const language = (languageOrOptions as string) || this.defaultLanguage;\n realInputs = convertToTextDocumentInput(documents, language);\n realOptions = options || {};\n } else {\n realInputs = documents;\n realOptions = (languageOrOptions as RecognizeCategorizedEntitiesOptions) || {};\n }\n\n const { span, updatedOptions: finalOptions } = createSpan(\n \"TextAnalyticsClient-recognizeEntities\",\n makeGeneratedRecognizeCategorizedEntitiesOptions(realOptions)\n );\n\n try {\n const result = await this.client.entitiesRecognitionGeneral(\n {\n documents: realInputs\n },\n finalOptions\n );\n\n return makeRecognizeCategorizedEntitiesResultArray(realInputs, result);\n } catch (e) {\n /**\n * This special logic handles REST exception with code\n * InvalidDocumentBatch and is needed to maintain backward compatability\n * with sdk v5.0.0 and earlier. In general, REST exceptions are thrown as\n * is and include both outer and inner exception codes. However, the\n * earlier versions were throwing an exception that included the inner\n * code only.\n */\n const backwardCompatibleException = handleInvalidDocumentBatch(e);\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: backwardCompatibleException.message\n });\n throw backwardCompatibleException;\n } finally {\n span.end();\n }\n }\n\n /**\n * Runs a predictive model to identify the positive, negative, neutral, or mixed\n * sentiment contained in the input strings, as well as scores indicating\n * the model's confidence in each of the predicted sentiments. Optionally it\n * can also identify targets in the text and assessments about it through\n * opinion mining. For a list of languages supported by this operation, @see\n * {@link https://docs.microsoft.com/azure/cognitive-services/text-analytics/language-support}.\n * @param documents - The input strings to analyze.\n * @param language - The language that all the input strings are\n written in. If unspecified, this value will be set to the default\n language in `TextAnalyticsClientOptions`. \n If set to an empty string, the service will apply a model\n where the lanuage is explicitly set to \"None\".\n * @param options - Optional parameters that includes enabling opinion mining.\n */\n public async analyzeSentiment(\n documents: string[],\n language?: string,\n options?: AnalyzeSentimentOptions\n ): Promise<AnalyzeSentimentResultArray>;\n /**\n * Runs a predictive model to identify the positive, negative or neutral, or mixed\n * sentiment contained in the input documents, as well as scores indicating\n * the model's confidence in each of the predicted sentiments.Optionally it\n * can also identify targets in the text and assessments about it through\n * opinion mining. For a list of languages supported by this operation, @see\n * {@link https://docs.microsoft.com/azure/cognitive-services/text-analytics/language-support}.\n * @param documents - The input documents to analyze.\n * @param options - Optional parameters that includes enabling opinion mining.\n */\n public async analyzeSentiment(\n documents: TextDocumentInput[],\n options?: AnalyzeSentimentOptions\n ): Promise<AnalyzeSentimentResultArray>;\n public async analyzeSentiment(\n documents: string[] | TextDocumentInput[],\n languageOrOptions?: string | AnalyzeSentimentOptions,\n options?: AnalyzeSentimentOptions\n ): Promise<AnalyzeSentimentResultArray> {\n let realOptions: AnalyzeSentimentOptions;\n let realInputs: TextDocumentInput[];\n\n if (!Array.isArray(documents) || documents.length === 0) {\n throw new Error(\"'documents' must be a non-empty array\");\n }\n\n if (isStringArray(documents)) {\n const language = (languageOrOptions as string) || this.defaultLanguage;\n realInputs = convertToTextDocumentInput(documents, language);\n realOptions = options || {};\n } else {\n realInputs = documents;\n realOptions = (languageOrOptions as AnalyzeSentimentOptions) || {};\n }\n\n const { span, updatedOptions: finalOptions } = createSpan(\n \"TextAnalyticsClient-analyzeSentiment\",\n makeGeneratedAnalyzeSentimentOptions(realOptions)\n );\n\n try {\n const result = await this.client.sentiment(\n {\n documents: realInputs\n },\n finalOptions\n );\n\n return makeAnalyzeSentimentResultArray(realInputs, result);\n } catch (e) {\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: e.message\n });\n throw e;\n } finally {\n span.end();\n }\n }\n\n /**\n * Runs a model to identify a collection of significant phrases\n * found in the passed-in input strings.\n * For a list of languages supported by this operation, @see\n * {@link https://docs.microsoft.com/azure/cognitive-services/text-analytics/language-support}.\n * @param documents - The input strings to analyze.\n * @param language - The language that all the input strings are\n written in. If unspecified, this value will be set to the default\n language in `TextAnalyticsClientOptions`. \n If set to an empty string, the service will apply a model\n where the language is explicitly set to \"None\".\n * @param options - Options for the operation.\n */\n public async extractKeyPhrases(\n documents: string[],\n language?: string,\n options?: ExtractKeyPhrasesOptions\n ): Promise<ExtractKeyPhrasesResultArray>;\n /**\n * Runs a model to identify a collection of significant phrases\n * found in the passed-in input documents.\n * For a list of languages supported by this operation, @see\n * {@link https://docs.microsoft.com/azure/cognitive-services/text-analytics/language-support}.\n * @param documents - The input documents to analyze.\n * @param options - Options for the operation.\n */\n public async extractKeyPhrases(\n documents: TextDocumentInput[],\n options?: ExtractKeyPhrasesOptions\n ): Promise<ExtractKeyPhrasesResultArray>;\n public async extractKeyPhrases(\n documents: string[] | TextDocumentInput[],\n languageOrOptions?: string | ExtractKeyPhrasesOptions,\n options?: ExtractKeyPhrasesOptions\n ): Promise<ExtractKeyPhrasesResultArray> {\n let realOptions: ExtractKeyPhrasesOptions;\n let realInputs: TextDocumentInput[];\n\n if (!Array.isArray(documents) || documents.length === 0) {\n throw new Error(\"'documents' must be a non-empty array\");\n }\n\n if (isStringArray(documents)) {\n const language = (languageOrOptions as string) || this.defaultLanguage;\n realInputs = convertToTextDocumentInput(documents, language);\n realOptions = options || {};\n } else {\n realInputs = documents;\n realOptions = (languageOrOptions as ExtractKeyPhrasesOptions) || {};\n }\n\n const { span, updatedOptions: finalOptions } = createSpan(\n \"TextAnalyticsClient-extractKeyPhrases\",\n makeGeneratedExtractKeyPhrasesOptions(realOptions)\n );\n\n try {\n const result = await this.client.keyPhrases(\n {\n documents: realInputs\n },\n finalOptions\n );\n\n return makeExtractKeyPhrasesResultArray(realInputs, result);\n } catch (e) {\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: e.message\n });\n throw e;\n } finally {\n span.end();\n }\n }\n\n /**\n * Runs a predictive model to identify a collection of entities containing\n * personally identifiable information found in the passed-in input strings,\n * and categorize those entities into types such as US social security\n * number, drivers license number, or credit card number.\n * For a list of languages supported by this operation, @see\n * {@link https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/language-support}.\n * @param inputs - The input strings to analyze.\n * @param language - The language that all the input strings are\n written in. If unspecified, this value will be set to the default\n language in `TextAnalyticsClientOptions`. \n If set to an empty string, the service will apply a model\n where the language is explicitly set to \"None\".\n * @param options - Options for the operation.\n */\n public async recognizePiiEntities(\n inputs: string[],\n language?: string,\n options?: RecognizePiiEntitiesOptions\n ): Promise<RecognizePiiEntitiesResultArray>;\n /**\n * Runs a predictive model to identify a collection of entities containing\n * personally identifiable information found in the passed-in input documents,\n * and categorize those entities into types such as US social security\n * number, drivers license number, or credit card number.\n * For a list of languages supported by this operation, @see\n * {@link https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/language-support}.\n * @param inputs - The input documents to analyze.\n * @param options - Optional parameters for the operation.\n */\n public async recognizePiiEntities(\n inputs: TextDocumentInput[],\n options?: RecognizePiiEntitiesOptions\n ): Promise<RecognizePiiEntitiesResultArray>;\n public async recognizePiiEntities(\n inputs: string[] | TextDocumentInput[],\n languageOrOptions?: string | RecognizePiiEntitiesOptions,\n options?: RecognizePiiEntitiesOptions\n ): Promise<RecognizePiiEntitiesResultArray> {\n let realOptions: RecognizePiiEntitiesOptions;\n let realInputs: TextDocumentInput[];\n\n if (isStringArray(inputs)) {\n const language = (languageOrOptions as string) || this.defaultLanguage;\n realInputs = convertToTextDocumentInput(inputs, language);\n realOptions = options || {};\n } else {\n realInputs = inputs;\n realOptions = (languageOrOptions as RecognizePiiEntitiesOptions) || {};\n }\n\n const { span, updatedOptions: finalOptions } = createSpan(\n \"TextAnalyticsClient-recognizePiiEntities\",\n makeGeneratedRecognizePiiEntitiesOptions(realOptions)\n );\n\n try {\n const result = await this.client.entitiesRecognitionPii(\n {\n documents: realInputs\n },\n finalOptions\n );\n\n return makeRecognizePiiEntitiesResultArray(realInputs, result);\n } catch (e) {\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: e.message\n });\n throw e;\n } finally {\n span.end();\n }\n }\n\n /**\n * Runs a predictive model to identify a collection of entities\n * found in the passed-in input strings, and include information linking the\n * entities to their corresponding entries in a well-known knowledge base.\n * For a list of languages supported by this operation, @see\n * {@link https://docs.microsoft.com/azure/cognitive-services/text-analytics/language-support}.\n * @param documents - The input strings to analyze.\n * @param language - The language that all the input strings are\n written in. If unspecified, this value will be set to the default\n language in `TextAnalyticsClientOptions`. \n If set to an empty string, the service will apply a model\n where the language is explicitly set to \"None\".\n * @param options - Options for the operation.\n */\n public async recognizeLinkedEntities(\n documents: string[],\n language?: string,\n options?: RecognizeLinkedEntitiesOptions\n ): Promise<RecognizeLinkedEntitiesResultArray>;\n /**\n * Runs a predictive model to identify a collection of entities\n * found in the passed-in input documents, and include information linking the\n * entities to their corresponding entries in a well-known knowledge base.\n * For a list of languages supported by this operation, @see\n * {@link https://docs.microsoft.com/azure/cognitive-services/text-analytics/language-support}.\n * @param documents - The input documents to analyze.\n * @param options - Options for the operation.\n */\n public async recognizeLinkedEntities(\n documents: TextDocumentInput[],\n options?: RecognizeLinkedEntitiesOptions\n ): Promise<RecognizeLinkedEntitiesResultArray>;\n public async recognizeLinkedEntities(\n documents: string[] | TextDocumentInput[],\n languageOrOptions?: string | RecognizeLinkedEntitiesOptions,\n options?: RecognizeLinkedEntitiesOptions\n ): Promise<RecognizeLinkedEntitiesResultArray> {\n let realOptions: RecognizeLinkedEntitiesOptions;\n let realInputs: TextDocumentInput[];\n\n if (!Array.isArray(documents) || documents.length === 0) {\n throw new Error(\"'documents' must be a non-empty array\");\n }\n\n if (isStringArray(documents)) {\n const language = (languageOrOptions as string) || this.defaultLanguage;\n realInputs = convertToTextDocumentInput(documents, language);\n realOptions = options || {};\n } else {\n realInputs = documents;\n realOptions = (languageOrOptions as RecognizeLinkedEntitiesOptions) || {};\n }\n\n const { span, updatedOptions: finalOptions } = createSpan(\n \"TextAnalyticsClient-recognizeLinkedEntities\",\n makeGeneratedRecognizeLinkingEntitiesOptions(realOptions)\n );\n\n try {\n const result = await this.client.entitiesLinking(\n {\n documents: realInputs\n },\n finalOptions\n );\n\n return makeRecognizeLinkedEntitiesResultArray(realInputs, result);\n } catch (e) {\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: e.message\n });\n throw e;\n } finally {\n span.end();\n }\n }\n\n /**\n * Start a healthcare analysis operation to recognize healthcare related entities (drugs, conditions,\n * symptoms, etc) and their relations.\n * @param documents - Collection of documents to analyze.\n * @param language - The language that all the input strings are\n written in. If unspecified, this value will be set to the default\n language in `TextAnalyticsClientOptions`.\n If set to an empty string, the service will apply a model\n where the language is explicitly set to \"None\".\n * @param options - Options for the operation.\n */\n async beginAnalyzeHealthcareEntities(\n documents: string[],\n language?: string,\n options?: BeginAnalyzeHealthcareEntitiesOptions\n ): Promise<AnalyzeHealthcareEntitiesPollerLike>;\n /**\n * Start a healthcare analysis operation to recognize healthcare related entities (drugs, conditions,\n * symptoms, etc) and their relations.\n * @param documents - Collection of documents to analyze.\n * @param options - Options for the operation.\n */\n async beginAnalyzeHealthcareEntities(\n documents: TextDocumentInput[],\n options?: BeginAnalyzeHealthcareEntitiesOptions\n ): Promise<AnalyzeHealthcareEntitiesPollerLike>;\n\n async beginAnalyzeHealthcareEntities(\n documents: string[] | TextDocumentInput[],\n languageOrOptions?: string | BeginAnalyzeHealthcareEntitiesOptions,\n options?: BeginAnalyzeHealthcareEntitiesOptions\n ): Promise<AnalyzeHealthcareEntitiesPollerLike> {\n let realOptions: BeginAnalyzeHealthcareEntitiesOptions;\n let realInputs: TextDocumentInput[];\n if (isStringArray(documents)) {\n const language = (languageOrOptions as string) || this.defaultLanguage;\n realInputs = convertToTextDocumentInput(documents, language);\n realOptions = options || {};\n } else {\n realInputs = documents;\n realOptions = (languageOrOptions as BeginAnalyzeHealthcareEntitiesOptions) || {};\n }\n\n const {\n updateIntervalInMs,\n resumeFrom,\n onResponse,\n disableServiceLogs,\n modelVersion,\n requestOptions,\n serializerOptions,\n abortSignal,\n stringIndexType,\n includeStatistics,\n tracingOptions\n } = realOptions;\n const lro = new HealthLro(\n this.client,\n {\n onResponse,\n requestOptions,\n serializerOptions,\n abortSignal,\n tracingOptions\n },\n { loggingOptOut: disableServiceLogs, stringIndexType, modelVersion },\n { includeStatistics },\n realInputs\n );\n\n const poller = new LroEngine<\n PagedAnalyzeHealthcareEntitiesResult,\n AnalyzeHealthcareOperationState\n >(lro, {\n intervalInMs: updateIntervalInMs,\n resumeFrom: resumeFrom,\n processResult: processHealthResult(this.client, realInputs, {\n onResponse,\n requestOptions,\n serializerOptions,\n abortSignal,\n tracingOptions,\n includeStatistics\n }),\n isDone: isHealthDone,\n updateState: updateHealthState\n });\n\n await poller.poll();\n return poller;\n }\n\n /**\n * Submit a collection of text documents for analysis. Specify one or more unique actions to be executed.\n * @param documents - Collection of documents to analyze\n * @param actions - TextAnalyticsActions to execute.\n * @param language - The language that all the input strings are\n written in. If unspecified, this value will be set to the default\n language in `TextAnalyticsClientOptions`.\n If set to an empty string, the service will apply a model\n where the language is explicitly set to \"None\".\n * @param options - Options for the operation.\n */\n public async beginAnalyzeActions(\n documents: string[],\n actions: TextAnalyticsActions,\n language?: string,\n options?: BeginAnalyzeActionsOptions\n ): Promise<AnalyzeActionsPollerLike>;\n /**\n * Submit a collection of text documents for analysis. Specify one or more unique actions to be executed.\n * @param documents - Collection of documents to analyze\n * @param actions - TextAnalyticsActions to execute.\n * @param options - Options for the operation.\n */\n public async beginAnalyzeActions(\n documents: TextDocumentInput[],\n actions: TextAnalyticsActions,\n options?: BeginAnalyzeActionsOptions\n ): Promise<AnalyzeActionsPollerLike>;\n public async beginAnalyzeActions(\n documents: string[] | TextDocumentInput[],\n actions: TextAnalyticsActions,\n languageOrOptions?: string | BeginAnalyzeActionsOptions,\n options?: BeginAnalyzeActionsOptions\n ): Promise<AnalyzeActionsPollerLike> {\n let realOptions: BeginAnalyzeActionsOptions;\n let realInputs: TextDocumentInput[];\n\n if (!Array.isArray(documents) || documents.length === 0) {\n throw new Error(\"'documents' must be a non-empty array\");\n }\n\n if (isStringArray(documents)) {\n const language = (languageOrOptions as string) || this.defaultLanguage;\n realInputs = convertToTextDocumentInput(documents, language);\n realOptions = options || {};\n } else {\n realInputs = documents;\n realOptions = (languageOrOptions as BeginAnalyzeActionsOptions) || {};\n }\n validateActions(actions);\n const compiledActions = compileAnalyzeInput(actions);\n const {\n updateIntervalInMs,\n resumeFrom,\n displayName,\n includeStatistics,\n onResponse,\n requestOptions,\n serializerOptions,\n abortSignal,\n tracingOptions\n } = realOptions;\n const lro = new AnalyzeLro(\n this.client,\n {\n onResponse,\n requestOptions,\n serializerOptions,\n abortSignal,\n tracingOptions\n },\n { displayName },\n { includeStatistics },\n realInputs,\n compiledActions\n );\n\n const poller = new LroEngine<PagedAnalyzeActionsResult, AnalyzeActionsOperationState>(lro, {\n intervalInMs: updateIntervalInMs,\n resumeFrom: resumeFrom,\n processResult: processAnalyzeResult(this.client, realInputs, {\n onResponse,\n requestOptions,\n serializerOptions,\n abortSignal,\n tracingOptions,\n includeStatistics\n }),\n isDone: isAnalyzeDone,\n updateState: updateAnalyzeState\n });\n\n await poller.poll();\n return poller;\n }\n}\n\nfunction validateActions(actions: TextAnalyticsActions): void {\n function validateActionType(actionList: unknown[] | undefined, actionType: string): void {\n if ((actionList?.length ?? 0) > 1) {\n throw new Error(\n `beginAnalyzeActions: Currently, the service can accept up to one action only for ${actionType} actions.`\n );\n }\n }\n validateActionType(actions.analyzeSentimentActions, `analyzeSentiment`);\n validateActionType(actions.extractKeyPhrasesActions, `extractKeyPhrases`);\n validateActionType(actions.recognizeEntitiesActions, `recognizeEntities`);\n validateActionType(actions.recognizeLinkedEntitiesActions, `recognizeLinkedEntities`);\n validateActionType(actions.recognizePiiEntitiesActions, `recognizePiiEntities`);\n validateActionType(actions.extractSummaryActions, `extractSummary`);\n}\n\n/**\n * @internal\n */\nfunction compileAnalyzeInput(actions: TextAnalyticsActions): GeneratedActions {\n return {\n entityRecognitionPiiTasks: actions.recognizePiiEntitiesActions?.map(\n compose(setStrEncodingParam, compose(setCategoriesFilter, addParamsToTask))\n ),\n entityRecognitionTasks: actions.recognizeEntitiesActions?.map(\n compose(setStrEncodingParam, addParamsToTask)\n ),\n keyPhraseExtractionTasks: actions.extractKeyPhrasesActions?.map(addParamsToTask),\n entityLinkingTasks: actions.recognizeLinkedEntitiesActions?.map(\n compose(setStrEncodingParam, addParamsToTask)\n ),\n sentimentAnalysisTasks: actions.analyzeSentimentActions?.map(\n compose(setStrEncodingParam, compose(setOpinionMining, addParamsToTask))\n ),\n extractiveSummarizationTasks: actions.extractSummaryActions?.map(\n compose(setStrEncodingParam, compose(setSentenceCount, compose(setOrderBy, addParamsToTask)))\n )\n };\n}\n\nfunction isStringArray(documents: any[]): documents is string[] {\n return typeof documents[0] === \"string\";\n}\n\n/**\n * @internal\n */\nfunction convertToDetectLanguageInput(\n inputs: string[],\n countryHint: string\n): DetectLanguageInput[] {\n if (countryHint === \"none\") {\n countryHint = \"\";\n }\n return inputs.map(\n (text: string, index): DetectLanguageInput => {\n return {\n id: String(index),\n countryHint,\n text\n };\n }\n );\n}\n\n/**\n * @internal\n */\nfunction convertToTextDocumentInput(inputs: string[], language: string): TextDocumentInput[] {\n return inputs.map(\n (text: string, index): TextDocumentInput => {\n return {\n id: String(index),\n language,\n text\n };\n }\n );\n}\n\n/**\n * Creates the options the service expects for the analyze sentiment API from the user friendly ones.\n * @param params - the user friendly parameters\n * @internal\n */\nfunction makeGeneratedAnalyzeSentimentOptions(\n params: AnalyzeSentimentOptions\n): GeneratedAnalyzeSentimentOptions {\n return {\n abortSignal: params.abortSignal,\n opinionMining: params.includeOpinionMining,\n includeStatistics: params.includeStatistics,\n modelVersion: params.modelVersion,\n requestOptions: params.requestOptions,\n stringIndexType: setStrEncodingParamValue(params.stringIndexType),\n tracingOptions: params.tracingOptions,\n onResponse: params.onResponse,\n serializerOptions: params.serializerOptions,\n loggingOptOut: params.disableServiceLogs\n };\n}\n\n/**\n * Creates the options the service expects for the recognize pii entities API from the user friendly ones.\n * @param params - the user friendly parameters\n * @internal\n */\nfunction makeGeneratedRecognizePiiEntitiesOptions(\n params: RecognizePiiEntitiesOptions\n): GeneratedRecognizePiiEntitiesOptions {\n return {\n abortSignal: params.abortSignal,\n domain: params.domainFilter,\n includeStatistics: params.includeStatistics,\n modelVersion: params.modelVersion,\n requestOptions: params.requestOptions,\n stringIndexType: setStrEncodingParamValue(params.stringIndexType),\n tracingOptions: params.tracingOptions,\n piiCategories: params.categoriesFilter,\n onResponse: params.onResponse,\n serializerOptions: params.serializerOptions,\n loggingOptOut: params.disableServiceLogs\n };\n}\n\n/**\n * Creates the options the service expects for the recognize entities API from the user friendly ones.\n * @param params - the user friendly parameters\n * @internal\n */\nfunction makeGeneratedRecognizeCategorizedEntitiesOptions(\n params: RecognizeCategorizedEntitiesOptions\n): GeneratedRecognizeCategorizedEntitiesOptions {\n return {\n abortSignal: params.abortSignal,\n includeStatistics: params.includeStatistics,\n modelVersion: params.modelVersion,\n requestOptions: params.requestOptions,\n stringIndexType: setStrEncodingParamValue(params.stringIndexType),\n tracingOptions: params.tracingOptions,\n onResponse: params.onResponse,\n serializerOptions: params.serializerOptions,\n loggingOptOut: params.disableServiceLogs\n };\n}\n\n/**\n * Creates the options the service expects for the detect language API from the user friendly ones.\n * @param params - the user friendly parameters\n * @internal\n */\nfunction makeGeneratedDetectLanguageOptions(\n params: DetectLanguageOptions\n): GeneratedDetectLanguageOptions {\n return {\n abortSignal: params.abortSignal,\n includeStatistics: params.includeStatistics,\n modelVersion: params.modelVersion,\n requestOptions: params.requestOptions,\n tracingOptions: params.tracingOptions,\n onResponse: params.onResponse,\n serializerOptions: params.serializerOptions,\n loggingOptOut: params.disableServiceLogs\n };\n}\n\n/**\n * Creates the options the service expects for the extract key phrases API from the user friendly ones.\n * @param params - the user friendly parameters\n * @internal\n */\nfunction makeGeneratedExtractKeyPhrasesOptions(\n params: ExtractKeyPhrasesOptions\n): GeneratedExtractKeyPhrasesOptions {\n return {\n abortSignal: params.abortSignal,\n includeStatistics: params.includeStatistics,\n modelVersion: params.modelVersion,\n requestOptions: params.requestOptions,\n tracingOptions: params.tracingOptions,\n onResponse: params.onResponse,\n serializerOptions: params.serializerOptions,\n loggingOptOut: params.disableServiceLogs\n };\n}\n\n/**\n * Creates the options the service expects for the recognize linked entities API from the user friendly ones.\n * @param params - the user friendly parameters\n * @internal\n */\nfunction makeGeneratedRecognizeLinkingEntitiesOptions(\n params: RecognizeLinkedEntitiesOptions\n): GeneratedRecognizeLinkedEntitiesOptions {\n return {\n abortSignal: params.abortSignal,\n includeStatistics: params.includeStatistics,\n modelVersion: params.modelVersion,\n requestOptions: params.requestOptions,\n tracingOptions: params.tracingOptions,\n onResponse: params.onResponse,\n serializerOptions: params.serializerOptions,\n loggingOptOut: params.disableServiceLogs,\n stringIndexType: setStrEncodingParamValue(params.stringIndexType)\n };\n}\n"]}
1
+ {"version":3,"file":"textAnalyticsClient.js","sourceRoot":"","sources":["../../src/textAnalyticsClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;AAGlC,OAAO,EAEL,+BAA+B,EAChC,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAkC,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrF,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAalC,OAAO,EAEL,6BAA6B,EAC9B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAEL,2CAA2C,EAC5C,MAAM,2CAA2C,CAAC;AACnD,OAAO,EAEL,+BAA+B,EAChC,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,gCAAgC,EAEjC,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAEL,mCAAmC,EACpC,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAEL,sCAAsC,EACvC,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MA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AACJ,CAAC;AAED;;;;GAIG;AACH,SAAS,qCAAqC,CAC5C,MAAgC;IAEhC,OAAO;QACL,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,iBAAiB,EAAE,MAAM,CAAC,iBAAiB;QAC3C,YAAY,EAAE,MAAM,CAAC,YAAY;QACjC,cAAc,EAAE,MAAM,CAAC,cAAc;QACrC,cAAc,EAAE,MAAM,CAAC,cAAc;QACrC,UAAU,EAAE,MAAM,CAAC,UAAU;QAC7B,iBAAiB,EAAE,MAAM,CAAC,iBAAiB;QAC3C,aAAa,EAAE,MAAM,CAAC,kBAAkB;KACzC,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,SAAS,4CAA4C,CACnD,MAAsC;IAEtC,OAAO;QACL,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,iBAAiB,EAAE,MAAM,CAAC,iBAAiB;QAC3C,YAAY,EAAE,MAAM,CAAC,YAAY;QACjC,cAAc,EAAE,MAAM,CAAC,cAAc;QACrC,cAAc,EAAE,MAAM,CAAC,cAAc;QACrC,UAAU,EAAE,MAAM,CAAC,UAAU;QAC7B,iBAAiB,EAAE,MAAM,CAAC,iBAAiB;QAC3C,aAAa,EAAE,MAAM,CAAC,kBAAkB;QACxC,eAAe,EAAE,wBAAwB,CAAC,MAAM,CAAC,eAAe,CAAC;KAClE,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { CommonClientOptions } from \"@azure/core-client\";\nimport {\n InternalPipelineOptions,\n bearerTokenAuthenticationPolicy\n} from \"@azure/core-rest-pipeline\";\nimport { TokenCredential, KeyCredential, isTokenCredential } from \"@azure/core-auth\";\nimport { GeneratedClient } from \"./generated/generatedClient\";\nimport { logger } from \"./logger\";\nimport {\n JobManifestTasks as GeneratedActions,\n DetectLanguageInput,\n GeneratedClientEntitiesRecognitionPiiOptionalParams as GeneratedRecognizePiiEntitiesOptions,\n GeneratedClientSentimentOptionalParams as GeneratedAnalyzeSentimentOptions,\n GeneratedClientEntitiesRecognitionGeneralOptionalParams as GeneratedRecognizeCategorizedEntitiesOptions,\n GeneratedClientEntitiesLinkingOptionalParams as GeneratedRecognizeLinkedEntitiesOptions,\n GeneratedClientKeyPhrasesOptionalParams as GeneratedExtractKeyPhrasesOptions,\n GeneratedClientLanguagesOptionalParams as GeneratedDetectLanguageOptions,\n TextDocumentInput,\n PiiCategory\n} from \"./generated/models\";\nimport {\n DetectLanguageResultArray,\n makeDetectLanguageResultArray\n} from \"./detectLanguageResultArray\";\nimport {\n RecognizeCategorizedEntitiesResultArray,\n makeRecognizeCategorizedEntitiesResultArray\n} from \"./recognizeCategorizedEntitiesResultArray\";\nimport {\n AnalyzeSentimentResultArray,\n makeAnalyzeSentimentResultArray\n} from \"./analyzeSentimentResultArray\";\nimport {\n makeExtractKeyPhrasesResultArray,\n ExtractKeyPhrasesResultArray\n} from \"./extractKeyPhrasesResultArray\";\nimport {\n RecognizePiiEntitiesResultArray,\n makeRecognizePiiEntitiesResultArray\n} from \"./recognizePiiEntitiesResultArray\";\nimport {\n RecognizeLinkedEntitiesResultArray,\n makeRecognizeLinkedEntitiesResultArray\n} from \"./recognizeLinkedEntitiesResultArray\";\nimport { createSpan } from \"./tracing\";\nimport { SpanStatusCode } from \"@azure/core-tracing\";\nimport { textAnalyticsAzureKeyCredentialPolicy } from \"./azureKeyCredentialPolicy\";\nimport {\n addParamsToTask,\n compose,\n compileError,\n setCategoriesFilter,\n setOpinionMining,\n setOrderBy,\n setSentenceCount,\n setStrEncodingParam,\n setStrEncodingParamValue,\n StringIndexType\n} from \"./util\";\nimport { TextAnalyticsOperationOptions } from \"./textAnalyticsOperationOptions\";\nimport { AnalysisPollOperationState, OperationMetadata } from \"./pollerModels\";\nimport { CustomTextAnalyticsAction, TextAnalyticsAction } from \"./textAnalyticsAction\";\nimport {\n AnalyzeHealthcareEntitiesPollerLike,\n AnalyzeHealthcareOperationState,\n BeginAnalyzeHealthcareEntitiesOptions,\n HealthLro,\n isHealthDone,\n processHealthResult,\n updateHealthState\n} from \"./healthLro\";\nimport { LroEngine } from \"@azure/core-lro\";\nimport { PagedAnalyzeHealthcareEntitiesResult } from \"./analyzeHealthcareEntitiesResult\";\nimport {\n AnalyzeActionsOperationMetadata,\n AnalyzeActionsOperationState,\n AnalyzeActionsPollerLike,\n AnalyzeLro,\n BeginAnalyzeActionsOptions,\n isAnalyzeDone,\n processAnalyzeResult,\n updateAnalyzeState\n} from \"./analyzeLro\";\nimport { PagedAnalyzeActionsResult } from \"./analyzeActionsResult\";\n\nexport {\n BeginAnalyzeActionsOptions,\n AnalyzeActionsPollerLike,\n AnalyzeActionsOperationState,\n BeginAnalyzeHealthcareEntitiesOptions,\n AnalyzeHealthcareEntitiesPollerLike,\n AnalyzeHealthcareOperationState,\n AnalysisPollOperationState,\n OperationMetadata,\n AnalyzeActionsOperationMetadata,\n StringIndexType\n};\n\nconst DEFAULT_COGNITIVE_SCOPE = \"https://cognitiveservices.azure.com/.default\";\n\n/**\n * Client options used to configure TextAnalytics API requests.\n */\nexport interface TextAnalyticsClientOptions extends CommonClientOptions {\n /**\n * The default country hint to use. Defaults to \"us\".\n */\n defaultCountryHint?: string;\n\n /**\n * The default language to use. Defaults to \"en\".\n */\n defaultLanguage?: string;\n}\n\n/**\n * Options for the detect languages operation.\n */\nexport interface DetectLanguageOptions extends TextAnalyticsOperationOptions {}\n\n/**\n * Options for the recognize entities operation.\n */\nexport interface RecognizeCategorizedEntitiesOptions extends TextAnalyticsOperationOptions {\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\n/**\n * Options for the analyze sentiment operation.\n */\nexport interface AnalyzeSentimentOptions extends TextAnalyticsOperationOptions {\n /**\n * Whether to mine the opinions of a sentence and conduct more granular\n * analysis around the aspects of a product or service (also known as\n * aspect-based sentiment analysis). If set to true, the returned\n * `SentenceSentiment` objects will have property `opinions` containing\n * the result of this analysis.\n * More information about the feature can be found here: {@link https://docs.microsoft.com/azure/cognitive-services/text-analytics/how-tos/text-analytics-how-to-sentiment-analysis?tabs=version-3-1#opinion-mining}\n */\n includeOpinionMining?: boolean;\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\n/**\n * The types of PII domains the user can choose from.\n */\nexport enum PiiEntityDomain {\n /**\n * @see {@link https://aka.ms/tanerpii} for more information.\n */\n PROTECTED_HEALTH_INFORMATION = \"PHI\"\n}\n\n/**\n * Options for the recognize PII entities operation.\n */\nexport interface RecognizePiiEntitiesOptions extends TextAnalyticsOperationOptions {\n /**\n * Filters entities to ones only included in the specified domain (e.g., if\n * set to 'PHI', entities in the Protected Healthcare Information domain will\n * only be returned). @see {@link https://aka.ms/tanerpii} for more information.\n */\n domainFilter?: PiiEntityDomain;\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 * Filters entities to ones only included in the specified array of categories\n */\n categoriesFilter?: PiiCategory[];\n}\n\n/**\n * Options for the extract key phrases operation.\n */\nexport interface ExtractKeyPhrasesOptions extends TextAnalyticsOperationOptions {}\n\n/**\n * Options for the recognize linked entities operation.\n */\nexport interface RecognizeLinkedEntitiesOptions extends TextAnalyticsOperationOptions {\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\n/**\n * Options for an entities recognition action.\n */\nexport interface RecognizeCategorizedEntitiesAction extends TextAnalyticsAction {\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 true, you opt-out of having your text input logged for troubleshooting. By default, Text Analytics\n * logs your input text for 48 hours, solely to allow for troubleshooting issues. Setting this parameter to true,\n * disables input logging and may limit our ability to remediate issues that occur.\n */\n disableServiceLogs?: boolean;\n}\n\n/**\n * Options for a Pii entities recognition action.\n */\nexport interface RecognizePiiEntitiesAction extends TextAnalyticsAction {\n /**\n * Filters entities to ones only included in the specified domain (e.g., if\n * set to 'PHI', entities in the Protected Healthcare Information domain will\n * only be returned). @see {@link https://aka.ms/tanerpii} for more information.\n */\n domainFilter?: PiiEntityDomain;\n /**\n * Filters entities to ones only included in the specified array of categories\n */\n categoriesFilter?: PiiCategory[];\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 pii entities recognition. Setting this parameter to false,\n * enables input logging.\n */\n disableServiceLogs?: boolean;\n}\n\n/**\n * Options for a key phrases recognition action.\n */\nexport interface ExtractKeyPhrasesAction extends TextAnalyticsAction {\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 pii entities recognition. Setting this parameter to false,\n * enables input logging.\n */\n disableServiceLogs?: boolean;\n}\n\n/**\n * Options for an entities linking action.\n */\nexport interface RecognizeLinkedEntitiesAction extends TextAnalyticsAction {\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 true, you opt-out of having your text input logged for troubleshooting. By default, Text Analytics\n * logs your input text for 48 hours, solely to allow for troubleshooting issues. Setting this parameter to true,\n * disables input logging and may limit our ability to remediate issues that occur.\n */\n disableServiceLogs?: boolean;\n}\n\n/**\n * Options for an analyze sentiment action.\n */\nexport interface AnalyzeSentimentAction extends TextAnalyticsAction {\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 true, you opt-out of having your text input logged for troubleshooting. By default, Text Analytics\n * logs your input text for 48 hours, solely to allow for troubleshooting issues. Setting this parameter to true,\n * disables input logging and may limit our ability to remediate issues that occur.\n */\n disableServiceLogs?: boolean;\n /**\n * Whether to mine the opinions of a sentence and conduct more granular\n * analysis around the aspects of a product or service (also known as\n * aspect-based sentiment analysis). If set to true, the returned\n * `SentenceSentiment` objects will have property `opinions` containing\n * the result of this analysis.\n * More information about the feature can be found here: {@link https://docs.microsoft.com/azure/cognitive-services/text-analytics/how-tos/text-analytics-how-to-sentiment-analysis?tabs=version-3-1#opinion-mining}\n */\n includeOpinionMining?: boolean;\n}\n\n/**\n * A type representing how to sort sentences for the summarization extraction action.\n */\nexport type KnownSummarySentencesSortBy = \"Offset\" | \"Rank\";\n\n/**\n * Options for an extract summary action.\n */\nexport interface ExtractSummaryAction extends TextAnalyticsAction {\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 true, you opt-out of having your text input logged for troubleshooting. By default, Text Analytics\n * logs your input text for 48 hours, solely to allow for troubleshooting issues. Setting this parameter to true,\n * disables input logging and may limit our ability to remediate issues that occur.\n */\n disableServiceLogs?: boolean;\n /**\n * Specifies the number of summary sentences to return. The default number of sentences is 3.\n */\n maxSentenceCount?: number;\n /**\n * Specifies how to sort the returned sentences. Please refer to {@link KnownSummarySentencesOrderBy} for possible values.\n */\n orderBy?: string;\n}\n\n/**\n * Options for a custom recognize entities action. For more information, please refer\n * to the service documentation: {@link https://aka.ms/azsdk/textanalytics/customentityrecognition}\n */\nexport interface RecognizeCustomEntitiesAction extends CustomTextAnalyticsAction {\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 true, you opt-out of having your text input logged for troubleshooting. By default, Text Analytics\n * logs your input text for 48 hours, solely to allow for troubleshooting issues. Setting this parameter to true,\n * disables input logging and may limit our ability to remediate issues that occur.\n */\n disableServiceLogs?: boolean;\n}\n\n/**\n * Options for an custom classify document single category action. For more information, please refer\n * to the service documentation: {@link https://aka.ms/azsdk/textanalytics/customfunctionalities}\n */\nexport interface SingleCategoryClassifyAction extends CustomTextAnalyticsAction {\n /**\n * If set to true, you opt-out of having your text input logged for troubleshooting. By default, Text Analytics\n * logs your input text for 48 hours, solely to allow for troubleshooting issues. Setting this parameter to true,\n * disables input logging and may limit our ability to remediate issues that occur.\n */\n disableServiceLogs?: boolean;\n}\n\n/**\n * Options for a custom classify document multi categories action. For more information, please refer\n * to the service documentation: {@link https://aka.ms/azsdk/textanalytics/customfunctionalities}\n */\nexport interface MultiCategoryClassifyAction extends CustomTextAnalyticsAction {\n /**\n * If set to true, you opt-out of having your text input logged for troubleshooting. By default, Text Analytics\n * logs your input text for 48 hours, solely to allow for troubleshooting issues. Setting this parameter to true,\n * disables input logging and may limit our ability to remediate issues that occur.\n */\n disableServiceLogs?: boolean;\n}\n\n/**\n * Description of collection of actions for the analyze API to perform on input documents.\n */\nexport interface TextAnalyticsActions {\n /**\n * A collection of descriptions of entities recognition actions.\n */\n recognizeEntitiesActions?: RecognizeCategorizedEntitiesAction[];\n /**\n * A collection of descriptions of Pii entities recognition actions.\n */\n recognizePiiEntitiesActions?: RecognizePiiEntitiesAction[];\n /**\n * A collection of descriptions of key phrases recognition actions.\n */\n extractKeyPhrasesActions?: ExtractKeyPhrasesAction[];\n /**\n * A collection of descriptions of entities linking actions.\n */\n recognizeLinkedEntitiesActions?: RecognizeLinkedEntitiesAction[];\n /**\n * A collection of descriptions of sentiment analysis actions.\n */\n analyzeSentimentActions?: AnalyzeSentimentAction[];\n /**\n * A collection of descriptions of summarization extraction actions.\n */\n extractSummaryActions?: ExtractSummaryAction[];\n /**\n * A collection of descriptions of custom entity recognition actions. For more information, please refer\n * to the service documentation: {@link https://aka.ms/azsdk/textanalytics/customentityrecognition}\n */\n recognizeCustomEntitiesActions?: RecognizeCustomEntitiesAction[];\n /**\n * A collection of descriptions of custom single classification actions. For more information, please refer\n * to the service documentation: {@link https://aka.ms/azsdk/textanalytics/customfunctionalities}\n */\n singleCategoryClassifyActions?: SingleCategoryClassifyAction[];\n /**\n * A collection of descriptions of custom multi classification actions. For more information, please refer\n * to the service documentation: {@link https://aka.ms/azsdk/textanalytics/customfunctionalities}\n */\n multiCategoryClassifyActions?: MultiCategoryClassifyAction[];\n}\n/**\n * Client class for interacting with Azure Text Analytics.\n */\nexport class TextAnalyticsClient {\n /**\n * The URL to the TextAnalytics endpoint\n */\n public readonly endpointUrl: string;\n\n /**\n * The default country hint to use. Defaults to \"us\".\n */\n public defaultCountryHint: string;\n\n /**\n * The default language to use. Defaults to \"en\".\n */\n public defaultLanguage: string;\n\n /**\n * @internal\n * A reference to the auto-generated TextAnalytics HTTP client.\n */\n private readonly client: GeneratedClient;\n\n /**\n * Creates an instance of TextAnalyticsClient.\n *\n * Example usage:\n * ```ts\n * import { TextAnalyticsClient, AzureKeyCredential } from \"@azure/ai-text-analytics\";\n *\n * const client = new TextAnalyticsClient(\n * \"<service endpoint>\",\n * new AzureKeyCredential(\"<api key>\")\n * );\n * ```\n * @param endpointUrl - The URL to the TextAnalytics endpoint\n * @param credential - Used to authenticate requests to the service.\n * @param options - Used to configure the TextAnalytics client.\n */\n constructor(\n endpointUrl: string,\n credential: TokenCredential | KeyCredential,\n options: TextAnalyticsClientOptions = {}\n ) {\n this.endpointUrl = endpointUrl;\n const { defaultCountryHint = \"us\", defaultLanguage = \"en\", ...pipelineOptions } = options;\n this.defaultCountryHint = defaultCountryHint;\n this.defaultLanguage = defaultLanguage;\n\n const internalPipelineOptions: InternalPipelineOptions = {\n ...pipelineOptions,\n ...{\n loggingOptions: {\n logger: logger.info,\n additionalAllowedHeaderNames: [\"x-ms-correlation-request-id\", \"x-ms-request-id\"]\n }\n }\n };\n\n this.client = new GeneratedClient(this.endpointUrl, internalPipelineOptions);\n\n const authPolicy = isTokenCredential(credential)\n ? bearerTokenAuthenticationPolicy({ credential, scopes: DEFAULT_COGNITIVE_SCOPE })\n : textAnalyticsAzureKeyCredentialPolicy(credential);\n\n this.client.pipeline.addPolicy(authPolicy);\n }\n\n /**\n * Runs a predictive model to determine the language that the passed-in\n * input strings are written in, and returns, for each one, the detected\n * language as well as a score indicating the model's confidence that the\n * inferred language is correct. Scores close to 1 indicate high certainty in\n * the result. 120 languages are supported.\n * @param documents - A collection of input strings to analyze.\n * @param countryHint - Indicates the country of origin for all of\n * the input strings to assist the text analytics model in predicting\n * the language they are written in. If unspecified, this value will be\n * set to the default country hint in `TextAnalyticsClientOptions`.\n * If set to an empty string, or the string \"none\", the service will apply a\n * model where the country is explicitly unset.\n * The same country hint is applied to all strings in the input collection.\n * @param options - Optional parameters for the operation.\n */\n public async detectLanguage(\n documents: string[],\n countryHint?: string,\n options?: DetectLanguageOptions\n ): Promise<DetectLanguageResultArray>;\n /**\n * Runs a predictive model to determine the language that the passed-in\n * input document are written in, and returns, for each one, the detected\n * language as well as a score indicating the model's confidence that the\n * inferred language is correct. Scores close to 1 indicate high certainty in\n * the result. 120 languages are supported.\n * @param documents - A collection of input documents to analyze.\n * @param options - Optional parameters for the operation.\n */\n public async detectLanguage(\n documents: DetectLanguageInput[],\n options?: DetectLanguageOptions\n ): Promise<DetectLanguageResultArray>;\n public async detectLanguage(\n documents: string[] | DetectLanguageInput[],\n countryHintOrOptions?: string | DetectLanguageOptions,\n options?: DetectLanguageOptions\n ): Promise<DetectLanguageResultArray> {\n let realOptions: DetectLanguageOptions;\n let realInputs: DetectLanguageInput[];\n\n if (!Array.isArray(documents) || documents.length === 0) {\n throw new Error(\"'documents' must be a non-empty array\");\n }\n\n if (isStringArray(documents)) {\n const countryHint = (countryHintOrOptions as string) || this.defaultCountryHint;\n realInputs = convertToDetectLanguageInput(documents, countryHint);\n realOptions = options || {};\n } else {\n // Replace \"none\" hints with \"\"\n realInputs = documents.map((input) => ({\n ...input,\n countryHint: input.countryHint === \"none\" ? \"\" : input.countryHint\n }));\n realOptions = (countryHintOrOptions as DetectLanguageOptions) || {};\n }\n\n const { span, updatedOptions: finalOptions } = createSpan(\n \"TextAnalyticsClient-detectLanguages\",\n makeGeneratedDetectLanguageOptions(realOptions)\n );\n\n try {\n const result = await this.client.languages(\n {\n documents: realInputs\n },\n finalOptions\n );\n\n return makeDetectLanguageResultArray(realInputs, result);\n } catch (e) {\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: e.message\n });\n throw e;\n } finally {\n span.end();\n }\n }\n\n /**\n * Runs a predictive model to identify a collection of named entities\n * in the passed-in input strings, and categorize those entities into types\n * such as person, location, or organization. For more information on \n * available categories, @see\n * {@link https://docs.microsoft.com/azure/cognitive-services/Text-Analytics/named-entity-types}.\n * For a list of languages supported by this operation, @see\n * {@link https://docs.microsoft.com/azure/cognitive-services/text-analytics/language-support}.\n * @param documents - The input strings to analyze.\n * @param language - The language that all the input strings are\n written in. If unspecified, this value will be set to the default\n language in `TextAnalyticsClientOptions`. \n If set to an empty string, the service will apply a model\n where the language is explicitly set to \"None\".\n * @param options - Optional parameters for the operation.\n */\n public async recognizeEntities(\n documents: string[],\n language?: string,\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n options?: RecognizeCategorizedEntitiesOptions\n ): Promise<RecognizeCategorizedEntitiesResultArray>;\n /**\n * Runs a predictive model to identify a collection of named entities\n * in the passed-in input documents, and categorize those entities into types\n * such as person, location, or organization. For more information on\n * available categories, @see\n * {@link https://docs.microsoft.com/azure/cognitive-services/Text-Analytics/named-entity-types}.\n * For a list of languages supported by this operation, @see\n * {@link https://docs.microsoft.com/azure/cognitive-services/text-analytics/language-support}.\n * @param documents - The input documents to analyze.\n * @param options - Optional parameters for the operation.\n */\n public async recognizeEntities(\n documents: TextDocumentInput[],\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n options?: RecognizeCategorizedEntitiesOptions\n ): Promise<RecognizeCategorizedEntitiesResultArray>;\n public async recognizeEntities(\n documents: string[] | TextDocumentInput[],\n languageOrOptions?: string | RecognizeCategorizedEntitiesOptions,\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n options?: RecognizeCategorizedEntitiesOptions\n ): Promise<RecognizeCategorizedEntitiesResultArray> {\n let realOptions: RecognizeCategorizedEntitiesOptions;\n let realInputs: TextDocumentInput[];\n\n if (!Array.isArray(documents) || documents.length === 0) {\n throw new Error(\"'documents' must be a non-empty array\");\n }\n\n if (isStringArray(documents)) {\n const language = (languageOrOptions as string) || this.defaultLanguage;\n realInputs = convertToTextDocumentInput(documents, language);\n realOptions = options || {};\n } else {\n realInputs = documents;\n realOptions = (languageOrOptions as RecognizeCategorizedEntitiesOptions) || {};\n }\n\n const { span, updatedOptions: finalOptions } = createSpan(\n \"TextAnalyticsClient-recognizeEntities\",\n makeGeneratedRecognizeCategorizedEntitiesOptions(realOptions)\n );\n\n try {\n const result = await this.client.entitiesRecognitionGeneral(\n {\n documents: realInputs\n },\n finalOptions\n );\n\n return makeRecognizeCategorizedEntitiesResultArray(realInputs, result);\n } catch (e) {\n /**\n * This special logic handles REST exception with code\n * InvalidDocumentBatch and is needed to maintain backward compatability\n * with sdk v5.0.0 and earlier. In general, REST exceptions are thrown as\n * is and include both outer and inner exception codes. However, the\n * earlier versions were throwing an exception that included the inner\n * code only.\n */\n const backwardCompatibleException = compileError(e);\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: backwardCompatibleException.message\n });\n throw backwardCompatibleException;\n } finally {\n span.end();\n }\n }\n\n /**\n * Runs a predictive model to identify the positive, negative, neutral, or mixed\n * sentiment contained in the input strings, as well as scores indicating\n * the model's confidence in each of the predicted sentiments. Optionally it\n * can also identify targets in the text and assessments about it through\n * opinion mining. For a list of languages supported by this operation, @see\n * {@link https://docs.microsoft.com/azure/cognitive-services/text-analytics/language-support}.\n * @param documents - The input strings to analyze.\n * @param language - The language that all the input strings are\n written in. If unspecified, this value will be set to the default\n language in `TextAnalyticsClientOptions`. \n If set to an empty string, the service will apply a model\n where the lanuage is explicitly set to \"None\".\n * @param options - Optional parameters that includes enabling opinion mining.\n */\n public async analyzeSentiment(\n documents: string[],\n language?: string,\n options?: AnalyzeSentimentOptions\n ): Promise<AnalyzeSentimentResultArray>;\n /**\n * Runs a predictive model to identify the positive, negative or neutral, or mixed\n * sentiment contained in the input documents, as well as scores indicating\n * the model's confidence in each of the predicted sentiments.Optionally it\n * can also identify targets in the text and assessments about it through\n * opinion mining. For a list of languages supported by this operation, @see\n * {@link https://docs.microsoft.com/azure/cognitive-services/text-analytics/language-support}.\n * @param documents - The input documents to analyze.\n * @param options - Optional parameters that includes enabling opinion mining.\n */\n public async analyzeSentiment(\n documents: TextDocumentInput[],\n options?: AnalyzeSentimentOptions\n ): Promise<AnalyzeSentimentResultArray>;\n public async analyzeSentiment(\n documents: string[] | TextDocumentInput[],\n languageOrOptions?: string | AnalyzeSentimentOptions,\n options?: AnalyzeSentimentOptions\n ): Promise<AnalyzeSentimentResultArray> {\n let realOptions: AnalyzeSentimentOptions;\n let realInputs: TextDocumentInput[];\n\n if (!Array.isArray(documents) || documents.length === 0) {\n throw new Error(\"'documents' must be a non-empty array\");\n }\n\n if (isStringArray(documents)) {\n const language = (languageOrOptions as string) || this.defaultLanguage;\n realInputs = convertToTextDocumentInput(documents, language);\n realOptions = options || {};\n } else {\n realInputs = documents;\n realOptions = (languageOrOptions as AnalyzeSentimentOptions) || {};\n }\n\n const { span, updatedOptions: finalOptions } = createSpan(\n \"TextAnalyticsClient-analyzeSentiment\",\n makeGeneratedAnalyzeSentimentOptions(realOptions)\n );\n\n try {\n const result = await this.client.sentiment(\n {\n documents: realInputs\n },\n finalOptions\n );\n\n return makeAnalyzeSentimentResultArray(realInputs, result);\n } catch (e) {\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: e.message\n });\n throw e;\n } finally {\n span.end();\n }\n }\n\n /**\n * Runs a model to identify a collection of significant phrases\n * found in the passed-in input strings.\n * For a list of languages supported by this operation, @see\n * {@link https://docs.microsoft.com/azure/cognitive-services/text-analytics/language-support}.\n * @param documents - The input strings to analyze.\n * @param language - The language that all the input strings are\n written in. If unspecified, this value will be set to the default\n language in `TextAnalyticsClientOptions`. \n If set to an empty string, the service will apply a model\n where the language is explicitly set to \"None\".\n * @param options - Options for the operation.\n */\n public async extractKeyPhrases(\n documents: string[],\n language?: string,\n options?: ExtractKeyPhrasesOptions\n ): Promise<ExtractKeyPhrasesResultArray>;\n /**\n * Runs a model to identify a collection of significant phrases\n * found in the passed-in input documents.\n * For a list of languages supported by this operation, @see\n * {@link https://docs.microsoft.com/azure/cognitive-services/text-analytics/language-support}.\n * @param documents - The input documents to analyze.\n * @param options - Options for the operation.\n */\n public async extractKeyPhrases(\n documents: TextDocumentInput[],\n options?: ExtractKeyPhrasesOptions\n ): Promise<ExtractKeyPhrasesResultArray>;\n public async extractKeyPhrases(\n documents: string[] | TextDocumentInput[],\n languageOrOptions?: string | ExtractKeyPhrasesOptions,\n options?: ExtractKeyPhrasesOptions\n ): Promise<ExtractKeyPhrasesResultArray> {\n let realOptions: ExtractKeyPhrasesOptions;\n let realInputs: TextDocumentInput[];\n\n if (!Array.isArray(documents) || documents.length === 0) {\n throw new Error(\"'documents' must be a non-empty array\");\n }\n\n if (isStringArray(documents)) {\n const language = (languageOrOptions as string) || this.defaultLanguage;\n realInputs = convertToTextDocumentInput(documents, language);\n realOptions = options || {};\n } else {\n realInputs = documents;\n realOptions = (languageOrOptions as ExtractKeyPhrasesOptions) || {};\n }\n\n const { span, updatedOptions: finalOptions } = createSpan(\n \"TextAnalyticsClient-extractKeyPhrases\",\n makeGeneratedExtractKeyPhrasesOptions(realOptions)\n );\n\n try {\n const result = await this.client.keyPhrases(\n {\n documents: realInputs\n },\n finalOptions\n );\n\n return makeExtractKeyPhrasesResultArray(realInputs, result);\n } catch (e) {\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: e.message\n });\n throw e;\n } finally {\n span.end();\n }\n }\n\n /**\n * Runs a predictive model to identify a collection of entities containing\n * personally identifiable information found in the passed-in input strings,\n * and categorize those entities into types such as US social security\n * number, drivers license number, or credit card number.\n * For a list of languages supported by this operation, @see\n * {@link https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/language-support}.\n * @param inputs - The input strings to analyze.\n * @param language - The language that all the input strings are\n written in. If unspecified, this value will be set to the default\n language in `TextAnalyticsClientOptions`. \n If set to an empty string, the service will apply a model\n where the language is explicitly set to \"None\".\n * @param options - Options for the operation.\n */\n public async recognizePiiEntities(\n inputs: string[],\n language?: string,\n options?: RecognizePiiEntitiesOptions\n ): Promise<RecognizePiiEntitiesResultArray>;\n /**\n * Runs a predictive model to identify a collection of entities containing\n * personally identifiable information found in the passed-in input documents,\n * and categorize those entities into types such as US social security\n * number, drivers license number, or credit card number.\n * For a list of languages supported by this operation, @see\n * {@link https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/language-support}.\n * @param inputs - The input documents to analyze.\n * @param options - Optional parameters for the operation.\n */\n public async recognizePiiEntities(\n inputs: TextDocumentInput[],\n options?: RecognizePiiEntitiesOptions\n ): Promise<RecognizePiiEntitiesResultArray>;\n public async recognizePiiEntities(\n inputs: string[] | TextDocumentInput[],\n languageOrOptions?: string | RecognizePiiEntitiesOptions,\n options?: RecognizePiiEntitiesOptions\n ): Promise<RecognizePiiEntitiesResultArray> {\n let realOptions: RecognizePiiEntitiesOptions;\n let realInputs: TextDocumentInput[];\n\n if (isStringArray(inputs)) {\n const language = (languageOrOptions as string) || this.defaultLanguage;\n realInputs = convertToTextDocumentInput(inputs, language);\n realOptions = options || {};\n } else {\n realInputs = inputs;\n realOptions = (languageOrOptions as RecognizePiiEntitiesOptions) || {};\n }\n\n const { span, updatedOptions: finalOptions } = createSpan(\n \"TextAnalyticsClient-recognizePiiEntities\",\n makeGeneratedRecognizePiiEntitiesOptions(realOptions)\n );\n\n try {\n const result = await this.client.entitiesRecognitionPii(\n {\n documents: realInputs\n },\n finalOptions\n );\n\n return makeRecognizePiiEntitiesResultArray(realInputs, result);\n } catch (e) {\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: e.message\n });\n throw e;\n } finally {\n span.end();\n }\n }\n\n /**\n * Runs a predictive model to identify a collection of entities\n * found in the passed-in input strings, and include information linking the\n * entities to their corresponding entries in a well-known knowledge base.\n * For a list of languages supported by this operation, @see\n * {@link https://docs.microsoft.com/azure/cognitive-services/text-analytics/language-support}.\n * @param documents - The input strings to analyze.\n * @param language - The language that all the input strings are\n written in. If unspecified, this value will be set to the default\n language in `TextAnalyticsClientOptions`. \n If set to an empty string, the service will apply a model\n where the language is explicitly set to \"None\".\n * @param options - Options for the operation.\n */\n public async recognizeLinkedEntities(\n documents: string[],\n language?: string,\n options?: RecognizeLinkedEntitiesOptions\n ): Promise<RecognizeLinkedEntitiesResultArray>;\n /**\n * Runs a predictive model to identify a collection of entities\n * found in the passed-in input documents, and include information linking the\n * entities to their corresponding entries in a well-known knowledge base.\n * For a list of languages supported by this operation, @see\n * {@link https://docs.microsoft.com/azure/cognitive-services/text-analytics/language-support}.\n * @param documents - The input documents to analyze.\n * @param options - Options for the operation.\n */\n public async recognizeLinkedEntities(\n documents: TextDocumentInput[],\n options?: RecognizeLinkedEntitiesOptions\n ): Promise<RecognizeLinkedEntitiesResultArray>;\n public async recognizeLinkedEntities(\n documents: string[] | TextDocumentInput[],\n languageOrOptions?: string | RecognizeLinkedEntitiesOptions,\n options?: RecognizeLinkedEntitiesOptions\n ): Promise<RecognizeLinkedEntitiesResultArray> {\n let realOptions: RecognizeLinkedEntitiesOptions;\n let realInputs: TextDocumentInput[];\n\n if (!Array.isArray(documents) || documents.length === 0) {\n throw new Error(\"'documents' must be a non-empty array\");\n }\n\n if (isStringArray(documents)) {\n const language = (languageOrOptions as string) || this.defaultLanguage;\n realInputs = convertToTextDocumentInput(documents, language);\n realOptions = options || {};\n } else {\n realInputs = documents;\n realOptions = (languageOrOptions as RecognizeLinkedEntitiesOptions) || {};\n }\n\n const { span, updatedOptions: finalOptions } = createSpan(\n \"TextAnalyticsClient-recognizeLinkedEntities\",\n makeGeneratedRecognizeLinkingEntitiesOptions(realOptions)\n );\n\n try {\n const result = await this.client.entitiesLinking(\n {\n documents: realInputs\n },\n finalOptions\n );\n\n return makeRecognizeLinkedEntitiesResultArray(realInputs, result);\n } catch (e) {\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: e.message\n });\n throw e;\n } finally {\n span.end();\n }\n }\n\n /**\n * Start a healthcare analysis operation to recognize healthcare related entities (drugs, conditions,\n * symptoms, etc) and their relations.\n * @param documents - Collection of documents to analyze.\n * @param language - The language that all the input strings are\n written in. If unspecified, this value will be set to the default\n language in `TextAnalyticsClientOptions`.\n If set to an empty string, the service will apply a model\n where the language is explicitly set to \"None\".\n * @param options - Options for the operation.\n */\n async beginAnalyzeHealthcareEntities(\n documents: string[],\n language?: string,\n options?: BeginAnalyzeHealthcareEntitiesOptions\n ): Promise<AnalyzeHealthcareEntitiesPollerLike>;\n /**\n * Start a healthcare analysis operation to recognize healthcare related entities (drugs, conditions,\n * symptoms, etc) and their relations.\n * @param documents - Collection of documents to analyze.\n * @param options - Options for the operation.\n */\n async beginAnalyzeHealthcareEntities(\n documents: TextDocumentInput[],\n options?: BeginAnalyzeHealthcareEntitiesOptions\n ): Promise<AnalyzeHealthcareEntitiesPollerLike>;\n\n async beginAnalyzeHealthcareEntities(\n documents: string[] | TextDocumentInput[],\n languageOrOptions?: string | BeginAnalyzeHealthcareEntitiesOptions,\n options?: BeginAnalyzeHealthcareEntitiesOptions\n ): Promise<AnalyzeHealthcareEntitiesPollerLike> {\n let realOptions: BeginAnalyzeHealthcareEntitiesOptions;\n let realInputs: TextDocumentInput[];\n if (isStringArray(documents)) {\n const language = (languageOrOptions as string) || this.defaultLanguage;\n realInputs = convertToTextDocumentInput(documents, language);\n realOptions = options || {};\n } else {\n realInputs = documents;\n realOptions = (languageOrOptions as BeginAnalyzeHealthcareEntitiesOptions) || {};\n }\n\n const {\n updateIntervalInMs,\n resumeFrom,\n onResponse,\n disableServiceLogs,\n modelVersion,\n requestOptions,\n serializerOptions,\n abortSignal,\n stringIndexType,\n includeStatistics,\n tracingOptions\n } = realOptions;\n const lro = new HealthLro(\n this.client,\n {\n onResponse,\n requestOptions,\n serializerOptions,\n abortSignal,\n tracingOptions\n },\n { loggingOptOut: disableServiceLogs, stringIndexType, modelVersion },\n { includeStatistics },\n realInputs\n );\n\n const poller = new LroEngine<\n PagedAnalyzeHealthcareEntitiesResult,\n AnalyzeHealthcareOperationState\n >(lro, {\n intervalInMs: updateIntervalInMs,\n resumeFrom: resumeFrom,\n processResult: processHealthResult(this.client, realInputs, {\n onResponse,\n requestOptions,\n serializerOptions,\n abortSignal,\n tracingOptions,\n includeStatistics\n }),\n isDone: isHealthDone,\n updateState: updateHealthState\n });\n\n await poller.poll();\n return poller;\n }\n\n /**\n * Submit a collection of text documents for analysis. Specify one or more unique actions to be executed.\n * @param documents - Collection of documents to analyze\n * @param actions - TextAnalyticsActions to execute.\n * @param language - The language that all the input strings are\n written in. If unspecified, this value will be set to the default\n language in `TextAnalyticsClientOptions`.\n If set to an empty string, the service will apply a model\n where the language is explicitly set to \"None\".\n * @param options - Options for the operation.\n */\n public async beginAnalyzeActions(\n documents: string[],\n actions: TextAnalyticsActions,\n language?: string,\n options?: BeginAnalyzeActionsOptions\n ): Promise<AnalyzeActionsPollerLike>;\n /**\n * Submit a collection of text documents for analysis. Specify one or more unique actions to be executed.\n * @param documents - Collection of documents to analyze\n * @param actions - TextAnalyticsActions to execute.\n * @param options - Options for the operation.\n */\n public async beginAnalyzeActions(\n documents: TextDocumentInput[],\n actions: TextAnalyticsActions,\n options?: BeginAnalyzeActionsOptions\n ): Promise<AnalyzeActionsPollerLike>;\n public async beginAnalyzeActions(\n documents: string[] | TextDocumentInput[],\n actions: TextAnalyticsActions,\n languageOrOptions?: string | BeginAnalyzeActionsOptions,\n options?: BeginAnalyzeActionsOptions\n ): Promise<AnalyzeActionsPollerLike> {\n let realOptions: BeginAnalyzeActionsOptions;\n let realInputs: TextDocumentInput[];\n\n if (!Array.isArray(documents) || documents.length === 0) {\n throw new Error(\"'documents' must be a non-empty array\");\n }\n\n if (isStringArray(documents)) {\n const language = (languageOrOptions as string) || this.defaultLanguage;\n realInputs = convertToTextDocumentInput(documents, language);\n realOptions = options || {};\n } else {\n realInputs = documents;\n realOptions = (languageOrOptions as BeginAnalyzeActionsOptions) || {};\n }\n const compiledActions = compileAnalyzeInput(actions);\n const {\n updateIntervalInMs,\n resumeFrom,\n displayName,\n includeStatistics,\n onResponse,\n requestOptions,\n serializerOptions,\n abortSignal,\n tracingOptions\n } = realOptions;\n const lro = new AnalyzeLro(\n this.client,\n {\n onResponse,\n requestOptions,\n serializerOptions,\n abortSignal,\n tracingOptions\n },\n { displayName },\n { includeStatistics },\n realInputs,\n compiledActions\n );\n\n const poller = new LroEngine<PagedAnalyzeActionsResult, AnalyzeActionsOperationState>(lro, {\n intervalInMs: updateIntervalInMs,\n resumeFrom: resumeFrom,\n processResult: processAnalyzeResult(this.client, realInputs, {\n onResponse,\n requestOptions,\n serializerOptions,\n abortSignal,\n tracingOptions,\n includeStatistics\n }),\n isDone: isAnalyzeDone,\n updateState: updateAnalyzeState\n });\n\n await poller.poll();\n return poller;\n }\n}\n\n/**\n * @internal\n */\nfunction compileAnalyzeInput(actions: TextAnalyticsActions): GeneratedActions {\n return {\n entityRecognitionPiiTasks: actions.recognizePiiEntitiesActions?.map(\n compose(setStrEncodingParam, compose(setCategoriesFilter, addParamsToTask))\n ),\n entityRecognitionTasks: actions.recognizeEntitiesActions?.map(\n compose(setStrEncodingParam, addParamsToTask)\n ),\n keyPhraseExtractionTasks: actions.extractKeyPhrasesActions?.map(addParamsToTask),\n entityLinkingTasks: actions.recognizeLinkedEntitiesActions?.map(\n compose(setStrEncodingParam, addParamsToTask)\n ),\n sentimentAnalysisTasks: actions.analyzeSentimentActions?.map(\n compose(setStrEncodingParam, compose(setOpinionMining, addParamsToTask))\n ),\n extractiveSummarizationTasks: actions.extractSummaryActions?.map(\n compose(setStrEncodingParam, compose(setSentenceCount, compose(setOrderBy, addParamsToTask)))\n ),\n customEntityRecognitionTasks: actions.recognizeCustomEntitiesActions?.map(\n compose(setStrEncodingParam, addParamsToTask)\n ),\n customSingleClassificationTasks: actions.singleCategoryClassifyActions?.map(addParamsToTask),\n customMultiClassificationTasks: actions.multiCategoryClassifyActions?.map(addParamsToTask)\n };\n}\n\nfunction isStringArray(documents: any[]): documents is string[] {\n return typeof documents[0] === \"string\";\n}\n\n/**\n * @internal\n */\nfunction convertToDetectLanguageInput(\n inputs: string[],\n countryHint: string\n): DetectLanguageInput[] {\n if (countryHint === \"none\") {\n countryHint = \"\";\n }\n return inputs.map(\n (text: string, index): DetectLanguageInput => {\n return {\n id: String(index),\n countryHint,\n text\n };\n }\n );\n}\n\n/**\n * @internal\n */\nfunction convertToTextDocumentInput(inputs: string[], language: string): TextDocumentInput[] {\n return inputs.map(\n (text: string, index): TextDocumentInput => {\n return {\n id: String(index),\n language,\n text\n };\n }\n );\n}\n\n/**\n * Creates the options the service expects for the analyze sentiment API from the user friendly ones.\n * @param params - the user friendly parameters\n * @internal\n */\nfunction makeGeneratedAnalyzeSentimentOptions(\n params: AnalyzeSentimentOptions\n): GeneratedAnalyzeSentimentOptions {\n return {\n abortSignal: params.abortSignal,\n opinionMining: params.includeOpinionMining,\n includeStatistics: params.includeStatistics,\n modelVersion: params.modelVersion,\n requestOptions: params.requestOptions,\n stringIndexType: setStrEncodingParamValue(params.stringIndexType),\n tracingOptions: params.tracingOptions,\n onResponse: params.onResponse,\n serializerOptions: params.serializerOptions,\n loggingOptOut: params.disableServiceLogs\n };\n}\n\n/**\n * Creates the options the service expects for the recognize pii entities API from the user friendly ones.\n * @param params - the user friendly parameters\n * @internal\n */\nfunction makeGeneratedRecognizePiiEntitiesOptions(\n params: RecognizePiiEntitiesOptions\n): GeneratedRecognizePiiEntitiesOptions {\n return {\n abortSignal: params.abortSignal,\n domain: params.domainFilter,\n includeStatistics: params.includeStatistics,\n modelVersion: params.modelVersion,\n requestOptions: params.requestOptions,\n stringIndexType: setStrEncodingParamValue(params.stringIndexType),\n tracingOptions: params.tracingOptions,\n piiCategories: params.categoriesFilter,\n onResponse: params.onResponse,\n serializerOptions: params.serializerOptions,\n loggingOptOut: params.disableServiceLogs\n };\n}\n\n/**\n * Creates the options the service expects for the recognize entities API from the user friendly ones.\n * @param params - the user friendly parameters\n * @internal\n */\nfunction makeGeneratedRecognizeCategorizedEntitiesOptions(\n params: RecognizeCategorizedEntitiesOptions\n): GeneratedRecognizeCategorizedEntitiesOptions {\n return {\n abortSignal: params.abortSignal,\n includeStatistics: params.includeStatistics,\n modelVersion: params.modelVersion,\n requestOptions: params.requestOptions,\n stringIndexType: setStrEncodingParamValue(params.stringIndexType),\n tracingOptions: params.tracingOptions,\n onResponse: params.onResponse,\n serializerOptions: params.serializerOptions,\n loggingOptOut: params.disableServiceLogs\n };\n}\n\n/**\n * Creates the options the service expects for the detect language API from the user friendly ones.\n * @param params - the user friendly parameters\n * @internal\n */\nfunction makeGeneratedDetectLanguageOptions(\n params: DetectLanguageOptions\n): GeneratedDetectLanguageOptions {\n return {\n abortSignal: params.abortSignal,\n includeStatistics: params.includeStatistics,\n modelVersion: params.modelVersion,\n requestOptions: params.requestOptions,\n tracingOptions: params.tracingOptions,\n onResponse: params.onResponse,\n serializerOptions: params.serializerOptions,\n loggingOptOut: params.disableServiceLogs\n };\n}\n\n/**\n * Creates the options the service expects for the extract key phrases API from the user friendly ones.\n * @param params - the user friendly parameters\n * @internal\n */\nfunction makeGeneratedExtractKeyPhrasesOptions(\n params: ExtractKeyPhrasesOptions\n): GeneratedExtractKeyPhrasesOptions {\n return {\n abortSignal: params.abortSignal,\n includeStatistics: params.includeStatistics,\n modelVersion: params.modelVersion,\n requestOptions: params.requestOptions,\n tracingOptions: params.tracingOptions,\n onResponse: params.onResponse,\n serializerOptions: params.serializerOptions,\n loggingOptOut: params.disableServiceLogs\n };\n}\n\n/**\n * Creates the options the service expects for the recognize linked entities API from the user friendly ones.\n * @param params - the user friendly parameters\n * @internal\n */\nfunction makeGeneratedRecognizeLinkingEntitiesOptions(\n params: RecognizeLinkedEntitiesOptions\n): GeneratedRecognizeLinkedEntitiesOptions {\n return {\n abortSignal: params.abortSignal,\n includeStatistics: params.includeStatistics,\n modelVersion: params.modelVersion,\n requestOptions: params.requestOptions,\n tracingOptions: params.tracingOptions,\n onResponse: params.onResponse,\n serializerOptions: params.serializerOptions,\n loggingOptOut: params.disableServiceLogs,\n stringIndexType: setStrEncodingParamValue(params.stringIndexType)\n };\n}\n"]}
@@ -75,4 +75,20 @@ export function combineSuccessfulAndErroneousDocumentsWithStatisticsAndModelVers
75
75
  modelVersion: response.modelVersion
76
76
  });
77
77
  }
78
+ /**
79
+ * @internal
80
+ * combines successful and erroneous results into a single array of results and
81
+ * sort them so that the IDs order match that of the input documents array. It
82
+ * also attaches statistics, projectName, and deploymentName to the returned array.
83
+ * @param input - the array of documents sent to the service for processing.
84
+ * @param response - the response received from the service.
85
+ */
86
+ export function combineSuccessfulAndErroneousDocumentsWithStatisticsAndCustomProjectInfo(input, response, processSuccess, processError) {
87
+ const sorted = processAndCombineSuccessfulAndErroneousDocuments(input, response, processSuccess, processError);
88
+ return Object.assign(sorted, {
89
+ statistics: response.statistics,
90
+ projectName: response.projectName,
91
+ deploymentName: response.deploymentName
92
+ });
93
+ }
78
94
  //# sourceMappingURL=textAnalyticsResult.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"textAnalyticsResult.js","sourceRoot":"","sources":["../../src/textAnalyticsResult.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAalC,OAAO,EAAE,qBAAqB,EAAE,MAAM,QAAQ,CAAC;AAwH/C;;;;GAIG;AACH,MAAM,UAAU,sBAAsB,CACpC,UAAyD;IAEzD,wDAAwD;IACxD,8BAA8B;IAC9B,IAAI,UAAU,CAAC,UAAU,KAAK,SAAS,EAAE;QACvC,OAAO,sBAAsB,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;KACtD;IAED,OAAO;QACL,IAAI,EAAE,UAAU,CAAC,IAAI;QACrB,OAAO,EAAE,UAAU,CAAC,OAAO;QAC3B,MAAM,EAAE,UAAU,CAAC,MAAM;KAC1B,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,8BAA8B,CAC5C,EAAU,EACV,QAAgC,EAChC,UAAmC;IAEnC,OAAO;QACL,EAAE;QACF,UAAU;QACV,QAAQ;KACT,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,4BAA4B,CAC1C,EAAU,EACV,KAAuC;IAEvC,OAAO;QACL,EAAE;QACF,KAAK,EAAE,sBAAsB,CAAC,KAAK,CAAC;KACrC,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,sCAAsC,CACpD,KAA0B,EAC1B,QAAyC;IAEzC,OAAO,gDAAgD,CACrD,KAAK,EACL,QAAQ,EACR,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EACR,4BAA4B,CAC7B,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,gDAAgD,CAK9D,KAA0B,EAC1B,QAAgD,EAChD,cAA+D,EAC/D,YAA6E;IAE7E,MAAM,cAAc,GAA+C,QAAQ,CAAC,SAAS,CAAC,GAAG,CACvF,cAAc,CACf,CAAC;IACF,MAAM,eAAe,GAAG,cAAc,CAAC,MAAM,CAC3C,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,CACpE,CAAC;IAEF,OAAO,qBAAqB,CAAC,KAAK,EAAE,eAAe,CAAC,CAAC;AACvD,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,mEAAmE,CAKjF,KAA0B,EAC1B,QAAgD,EAChD,cAAqD,EACrD,YAA6E;IAE7E,MAAM,MAAM,GAAG,gDAAgD,CAC7D,KAAK,EACL,QAAQ,EACR,cAAc,EACd,YAAY,CACb,CAAC;IACF,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE;QAC3B,UAAU,EAAE,QAAQ,CAAC,UAAU;QAC/B,YAAY,EAAE,QAAQ,CAAC,YAAY;KACpC,CAAC,CAAC;AACL,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n TextDocumentStatistics,\n TextAnalyticsError as GeneratedTextAnalyticsErrorModel,\n InnerError,\n ErrorCodeValue,\n InnerErrorCodeValue,\n TextAnalyticsWarning,\n DocumentError,\n TextDocumentBatchStatistics,\n TextDocumentInput\n} from \"./generated/models\";\nimport { sortResponseIdObjects } from \"./util\";\n\n/**\n * The result of a text analytics operation on a single input document.\n * @internal\n */\nexport type TextAnalyticsResult = TextAnalyticsSuccessResult | TextAnalyticsErrorResult;\n\n/**\n * An Error Code returned from the Text Analytics service. Possible\n * values include:\n *\n * For more information about the error, see the `message` property of the associated error.\n */\nexport type ErrorCode = ErrorCodeValue | InnerErrorCodeValue;\n\n/**\n * Type describing an error from the Text Analytics service.\n */\nexport interface TextAnalyticsError {\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 target of the particular error (for example, the name of an invalid parameter)\n */\n readonly target?: string;\n}\n\n/**\n * Base type for results of text analytics operations corresponding to a single\n * input document.\n */\nexport interface TextAnalyticsSuccessResult {\n /**\n * Unique, non-empty document identifier.\n */\n readonly id: string;\n\n /**\n * Statistics about the input document and how it was processed\n * by the service. This property will have a value when includeStatistics is set to true\n * in the client call.\n */\n readonly statistics?: TextDocumentStatistics;\n\n /**\n * An array of warning data corresponding to this document.\n *\n * If no warnings were returned, this array will be empty.\n */\n readonly warnings: TextAnalyticsWarning[];\n\n /**\n * Discriminant to determine if that this is an error result.\n */\n readonly error?: undefined;\n}\n\n/**\n * Base type for error results of text analytics operations corresponding to a\n * single document.\n */\nexport interface TextAnalyticsErrorResult {\n /**\n * Unique, non-empty document identifier.\n */\n readonly id: string;\n\n /**\n * The Error for this document result.\n */\n readonly error: TextAnalyticsError;\n}\n\n/**\n * @internal\n */\nexport interface TextAnalyticsResultArray<T1 extends TextAnalyticsSuccessResult>\n extends Array<T1 | TextAnalyticsErrorResult> {\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 interface TextAnalyticsResponse<T1 extends TextAnalyticsSuccessResult> {\n /**\n * Response by document\n */\n documents: T1[];\n /**\n * Errors by document id.\n */\n errors: DocumentError[];\n /**\n * if includeStatistics=true was specified in the request this field will contain information about the request payload.\n */\n statistics?: TextDocumentBatchStatistics;\n /**\n * This field indicates which model is used for scoring.\n */\n modelVersion: string;\n}\n\n/**\n * Helper function for converting nested service error into\n * the unified TextAnalyticsError\n * @internal\n */\nexport function intoTextAnalyticsError(\n errorModel: GeneratedTextAnalyticsErrorModel | InnerError\n): TextAnalyticsError {\n // Return the deepest error. This will always be at most\n // one level for TextAnalytics\n if (errorModel.innererror !== undefined) {\n return intoTextAnalyticsError(errorModel.innererror);\n }\n\n return {\n code: errorModel.code,\n message: errorModel.message,\n target: errorModel.target\n };\n}\n\n/**\n * @internal\n */\nexport function makeTextAnalyticsSuccessResult(\n id: string,\n warnings: TextAnalyticsWarning[],\n statistics?: TextDocumentStatistics\n): TextAnalyticsSuccessResult {\n return {\n id,\n statistics,\n warnings\n };\n}\n\n/**\n * @internal\n */\nexport function makeTextAnalyticsErrorResult(\n id: string,\n error: GeneratedTextAnalyticsErrorModel\n): TextAnalyticsErrorResult {\n return {\n id,\n error: intoTextAnalyticsError(error)\n };\n}\n\n/**\n * @internal\n * combines successful and erroneous results into a single array of results and\n * sort them so that the IDs order match that of the input documents array.\n * @param input - the array of documents sent to the service for processing.\n * @param response - the response received from the service.\n */\nexport function combineSuccessfulAndErroneousDocuments<TSuccess extends TextAnalyticsSuccessResult>(\n input: TextDocumentInput[],\n response: TextAnalyticsResponse<TSuccess>\n): (TSuccess | TextAnalyticsErrorResult)[] {\n return processAndCombineSuccessfulAndErroneousDocuments(\n input,\n response,\n (x) => x,\n makeTextAnalyticsErrorResult\n );\n}\n\n/**\n * @internal\n * combines successful and erroneous results into a single array of results and\n * sort them so that the IDs order match that of the input documents array.\n * @param input - the array of documents sent to the service for processing.\n * @param response - the response received from the service.\n * @param process - a function to convert the results from one type to another.\n */\nexport function processAndCombineSuccessfulAndErroneousDocuments<\n TSuccessService extends TextAnalyticsSuccessResult,\n TSuccessSDK extends TextAnalyticsSuccessResult,\n TError extends TextAnalyticsErrorResult\n>(\n input: TextDocumentInput[],\n response: TextAnalyticsResponse<TSuccessService>,\n processSuccess: (successResult: TSuccessService) => TSuccessSDK,\n processError: (id: string, error: GeneratedTextAnalyticsErrorModel) => TError\n): (TSuccessSDK | TextAnalyticsErrorResult)[] {\n const successResults: (TSuccessSDK | TextAnalyticsErrorResult)[] = response.documents.map(\n processSuccess\n );\n const unsortedResults = successResults.concat(\n response.errors.map((error) => processError(error.id, error.error))\n );\n\n return sortResponseIdObjects(input, unsortedResults);\n}\n\n/**\n * @internal\n * combines successful and erroneous results into a single array of results and\n * sort them so that the IDs order match that of the input documents array. It\n * also attaches statistics and modelVersion to the returned array.\n * @param input - the array of documents sent to the service for processing.\n * @param response - the response received from the service.\n */\nexport function combineSuccessfulAndErroneousDocumentsWithStatisticsAndModelVersion<\n TSuccessService extends TextAnalyticsSuccessResult,\n TSuccessSDK extends TextAnalyticsSuccessResult,\n TError extends TextAnalyticsErrorResult\n>(\n input: TextDocumentInput[],\n response: TextAnalyticsResponse<TSuccessService>,\n processSuccess: (doc: TSuccessService) => TSuccessSDK,\n processError: (id: string, error: GeneratedTextAnalyticsErrorModel) => TError\n): TextAnalyticsResultArray<TSuccessSDK> {\n const sorted = processAndCombineSuccessfulAndErroneousDocuments(\n input,\n response,\n processSuccess,\n processError\n );\n return Object.assign(sorted, {\n statistics: response.statistics,\n modelVersion: response.modelVersion\n });\n}\n"]}
1
+ {"version":3,"file":"textAnalyticsResult.js","sourceRoot":"","sources":["../../src/textAnalyticsResult.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAalC,OAAO,EAAE,qBAAqB,EAAE,MAAM,QAAQ,CAAC;AAuK/C;;;;GAIG;AACH,MAAM,UAAU,sBAAsB,CACpC,UAAyD;IAEzD,wDAAwD;IACxD,8BAA8B;IAC9B,IAAI,UAAU,CAAC,UAAU,KAAK,SAAS,EAAE;QACvC,OAAO,sBAAsB,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;KACtD;IAED,OAAO;QACL,IAAI,EAAE,UAAU,CAAC,IAAI;QACrB,OAAO,EAAE,UAAU,CAAC,OAAO;QAC3B,M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,UAAU,EAAE,QAAQ,CAAC,UAAU;QAC/B,YAAY,EAAE,QAAQ,CAAC,YAAY;KACpC,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,wEAAwE,CAKtF,KAA0B,EAC1B,QAAsD,EACtD,cAAqD,EACrD,YAA6E;IAE7E,MAAM,MAAM,GAAG,gDAAgD,CAC7D,KAAK,EACL,QAAQ,EACR,cAAc,EACd,YAAY,CACb,CAAC;IACF,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE;QAC3B,UAAU,EAAE,QAAQ,CAAC,UAAU;QAC/B,WAAW,EAAE,QAAQ,CAAC,WAAW;QACjC,cAAc,EAAE,QAAQ,CAAC,cAAc;KACxC,CAAC,CAAC;AACL,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n TextDocumentStatistics,\n TextAnalyticsError as GeneratedTextAnalyticsErrorModel,\n InnerError,\n ErrorCodeValue,\n InnerErrorCodeValue,\n TextAnalyticsWarning,\n DocumentError,\n TextDocumentBatchStatistics,\n TextDocumentInput\n} from \"./generated/models\";\nimport { sortResponseIdObjects } from \"./util\";\n\n/**\n * The result of a text analytics operation on a single input document.\n * @internal\n */\nexport type TextAnalyticsResult = TextAnalyticsSuccessResult | TextAnalyticsErrorResult;\n\n/**\n * An Error Code returned from the Text Analytics service. Possible\n * values include:\n *\n * For more information about the error, see the `message` property of the associated error.\n */\nexport type ErrorCode = ErrorCodeValue | InnerErrorCodeValue;\n\n/**\n * Type describing an error from the Text Analytics service.\n */\nexport interface TextAnalyticsError {\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 target of the particular error (for example, the name of an invalid parameter)\n */\n readonly target?: string;\n}\n\n/**\n * Base type for results of text analytics operations corresponding to a single\n * input document.\n */\nexport interface TextAnalyticsSuccessResult {\n /**\n * Unique, non-empty document identifier.\n */\n readonly id: string;\n\n /**\n * Statistics about the input document and how it was processed\n * by the service. This property will have a value when includeStatistics is set to true\n * in the client call.\n */\n readonly statistics?: TextDocumentStatistics;\n\n /**\n * An array of warning data corresponding to this document.\n *\n * If no warnings were returned, this array will be empty.\n */\n readonly warnings: TextAnalyticsWarning[];\n\n /**\n * Discriminant to determine if that this is an error result.\n */\n readonly error?: undefined;\n}\n\n/**\n * Base type for error results of text analytics operations corresponding to a\n * single document.\n */\nexport interface TextAnalyticsErrorResult {\n /**\n * Unique, non-empty document identifier.\n */\n readonly id: string;\n\n /**\n * The Error for this document result.\n */\n readonly error: TextAnalyticsError;\n}\n\n/**\n * @internal\n */\nexport interface StandardTextAnalyticsResultArray<T1 extends TextAnalyticsSuccessResult>\n extends Array<T1 | TextAnalyticsErrorResult> {\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 interface CustomTextAnalyticsResultArray<T1 extends TextAnalyticsSuccessResult>\n extends Array<T1 | TextAnalyticsErrorResult> {\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 * This field indicates the project name for the model.\n */\n projectName: string;\n /**\n * This field indicates the deployment name for the model.\n */\n deploymentName: string;\n}\n\n/**\n * @internal\n */\nexport interface StandardTextAnalyticsResponse<T1 extends TextAnalyticsSuccessResult> {\n /**\n * Response by document\n */\n documents: T1[];\n /**\n * Errors by document id.\n */\n errors: DocumentError[];\n /**\n * if includeStatistics=true was specified in the request this field will contain information about the request payload.\n */\n statistics?: TextDocumentBatchStatistics;\n /**\n * This field indicates which model is used for scoring.\n */\n modelVersion: string;\n}\n\n/**\n * @internal\n */\nexport interface CustomTextAnalyticsResponse<T1 extends TextAnalyticsSuccessResult> {\n /**\n * Response by document\n */\n documents: T1[];\n /**\n * Errors by document id.\n */\n errors: DocumentError[];\n /**\n * if includeStatistics=true was specified in the request this field will contain information about the request payload.\n */\n statistics?: TextDocumentBatchStatistics;\n /**\n * This field indicates the project name for the model.\n */\n projectName: string;\n /**\n * This field indicates the deployment name for the model.\n */\n deploymentName: string;\n}\n\n/**\n * Helper function for converting nested service error into\n * the unified TextAnalyticsError\n * @internal\n */\nexport function intoTextAnalyticsError(\n errorModel: GeneratedTextAnalyticsErrorModel | InnerError\n): TextAnalyticsError {\n // Return the deepest error. This will always be at most\n // one level for TextAnalytics\n if (errorModel.innererror !== undefined) {\n return intoTextAnalyticsError(errorModel.innererror);\n }\n\n return {\n code: errorModel.code,\n message: errorModel.message,\n target: errorModel.target\n };\n}\n\n/**\n * @internal\n */\nexport function makeTextAnalyticsSuccessResult(\n id: string,\n warnings: TextAnalyticsWarning[],\n statistics?: TextDocumentStatistics\n): TextAnalyticsSuccessResult {\n return {\n id,\n statistics,\n warnings\n };\n}\n\n/**\n * @internal\n */\nexport function makeTextAnalyticsErrorResult(\n id: string,\n error: GeneratedTextAnalyticsErrorModel\n): TextAnalyticsErrorResult {\n return {\n id,\n error: intoTextAnalyticsError(error)\n };\n}\n\n/**\n * @internal\n * combines successful and erroneous results into a single array of results and\n * sort them so that the IDs order match that of the input documents array.\n * @param input - the array of documents sent to the service for processing.\n * @param response - the response received from the service.\n */\nexport function combineSuccessfulAndErroneousDocuments<TSuccess extends TextAnalyticsSuccessResult>(\n input: TextDocumentInput[],\n response: StandardTextAnalyticsResponse<TSuccess>\n): (TSuccess | TextAnalyticsErrorResult)[] {\n return processAndCombineSuccessfulAndErroneousDocuments(\n input,\n response,\n (x) => x,\n makeTextAnalyticsErrorResult\n );\n}\n\n/**\n * @internal\n * combines successful and erroneous results into a single array of results and\n * sort them so that the IDs order match that of the input documents array.\n * @param input - the array of documents sent to the service for processing.\n * @param response - the response received from the service.\n * @param process - a function to convert the results from one type to another.\n */\nexport function processAndCombineSuccessfulAndErroneousDocuments<\n TSuccessService extends TextAnalyticsSuccessResult,\n TSuccessSDK extends TextAnalyticsSuccessResult,\n TError extends TextAnalyticsErrorResult\n>(\n input: TextDocumentInput[],\n response: {\n documents: TSuccessService[];\n errors: DocumentError[];\n },\n processSuccess: (successResult: TSuccessService) => TSuccessSDK,\n processError: (id: string, error: GeneratedTextAnalyticsErrorModel) => TError\n): (TSuccessSDK | TextAnalyticsErrorResult)[] {\n const successResults: (TSuccessSDK | TextAnalyticsErrorResult)[] = response.documents.map(\n processSuccess\n );\n const unsortedResults = successResults.concat(\n response.errors.map((error) => processError(error.id, error.error))\n );\n\n return sortResponseIdObjects(input, unsortedResults);\n}\n\n/**\n * @internal\n * combines successful and erroneous results into a single array of results and\n * sort them so that the IDs order match that of the input documents array. It\n * also attaches statistics and modelVersion to the returned array.\n * @param input - the array of documents sent to the service for processing.\n * @param response - the response received from the service.\n */\nexport function combineSuccessfulAndErroneousDocumentsWithStatisticsAndModelVersion<\n TSuccessService extends TextAnalyticsSuccessResult,\n TSuccessSDK extends TextAnalyticsSuccessResult,\n TError extends TextAnalyticsErrorResult\n>(\n input: TextDocumentInput[],\n response: StandardTextAnalyticsResponse<TSuccessService>,\n processSuccess: (doc: TSuccessService) => TSuccessSDK,\n processError: (id: string, error: GeneratedTextAnalyticsErrorModel) => TError\n): StandardTextAnalyticsResultArray<TSuccessSDK> {\n const sorted = processAndCombineSuccessfulAndErroneousDocuments(\n input,\n response,\n processSuccess,\n processError\n );\n return Object.assign(sorted, {\n statistics: response.statistics,\n modelVersion: response.modelVersion\n });\n}\n\n/**\n * @internal\n * combines successful and erroneous results into a single array of results and\n * sort them so that the IDs order match that of the input documents array. It\n * also attaches statistics, projectName, and deploymentName to the returned array.\n * @param input - the array of documents sent to the service for processing.\n * @param response - the response received from the service.\n */\nexport function combineSuccessfulAndErroneousDocumentsWithStatisticsAndCustomProjectInfo<\n TSuccessService extends TextAnalyticsSuccessResult,\n TSuccessSDK extends TextAnalyticsSuccessResult,\n TError extends TextAnalyticsErrorResult\n>(\n input: TextDocumentInput[],\n response: CustomTextAnalyticsResponse<TSuccessService>,\n processSuccess: (doc: TSuccessService) => TSuccessSDK,\n processError: (id: string, error: GeneratedTextAnalyticsErrorModel) => TError\n): CustomTextAnalyticsResultArray<TSuccessSDK> {\n const sorted = processAndCombineSuccessfulAndErroneousDocuments(\n input,\n response,\n processSuccess,\n processError\n );\n return Object.assign(sorted, {\n statistics: response.statistics,\n projectName: response.projectName,\n deploymentName: response.deploymentName\n });\n}\n"]}
@@ -3,7 +3,6 @@
3
3
  import { __rest } from "tslib";
4
4
  import { RestError } from "@azure/core-rest-pipeline";
5
5
  import { SpanStatusCode } from "@azure/core-tracing";
6
- import { URL, URLSearchParams } from "./utils/url";
7
6
  import { logger } from "./logger";
8
7
  import { createSpan } from "./tracing";
9
8
  /**
@@ -118,31 +117,6 @@ export function addParamsToTask(action) {
118
117
  export function setModelVersionParam(x) {
119
118
  return Object.assign(Object.assign({}, x), { modelVersion: x.modelVersion || "latest" });
120
119
  }
121
- /**
122
- * @internal
123
- */
124
- export function nextLinkToTopAndSkip(nextLink) {
125
- const url = new URL(nextLink);
126
- const searchParams = new URLSearchParams(url.searchParams);
127
- let top;
128
- if (searchParams.has("$top")) {
129
- top = parseInt(searchParams.get("$top"));
130
- }
131
- else {
132
- throw new Error(`nextLink URL does not have the $top param: ${nextLink}`);
133
- }
134
- let skip;
135
- if (searchParams.has("$skip")) {
136
- skip = parseInt(searchParams.get("$skip"));
137
- }
138
- else {
139
- throw new Error(`nextLink URL does not have the $skip param: ${nextLink}`);
140
- }
141
- return {
142
- skip: skip,
143
- top: top
144
- };
145
- }
146
120
  /**
147
121
  * @internal
148
122
  */
@@ -150,32 +124,42 @@ export function getOperationId(operationLocation) {
150
124
  const lastSlashIndex = operationLocation.lastIndexOf("/");
151
125
  return operationLocation.substring(lastSlashIndex + 1);
152
126
  }
127
+ function appendReadableErrorMessage(currentMessage, innerMessage) {
128
+ let message = currentMessage;
129
+ if (message.slice(-1) !== ".") {
130
+ message = message + ".";
131
+ }
132
+ return message + " " + innerMessage;
133
+ }
153
134
  /**
154
135
  * @internal
155
136
  * parses incoming errors from the service and if the inner error code is
156
137
  * InvalidDocumentBatch, it exposes that as the statusCode instead.
157
138
  * @param error - the incoming error
158
139
  */
159
- export function handleInvalidDocumentBatch(error) {
160
- var _a, _b, _c, _d, _e, _f, _g, _h;
161
- const castError = error;
162
- const innerCode = (_d = (_c = (_b = (_a = castError.response) === null || _a === void 0 ? void 0 : _a.parsedBody) === null || _b === void 0 ? void 0 : _b.error) === null || _c === void 0 ? void 0 : _c.innererror) === null || _d === void 0 ? void 0 : _d.code;
163
- const innerMessage = (_h = (_g = (_f = (_e = castError.response) === null || _e === void 0 ? void 0 : _e.parsedBody) === null || _f === void 0 ? void 0 : _f.error) === null || _g === void 0 ? void 0 : _g.innererror) === null || _h === void 0 ? void 0 : _h.message;
164
- if (innerMessage) {
165
- return innerCode === "InvalidDocumentBatch"
166
- ? new RestError(innerMessage, { code: innerCode, statusCode: castError.statusCode })
167
- : error;
168
- }
169
- else {
170
- // unfortunately, the service currently does not follow the swagger definition
171
- // for errors in some cases.
172
- // Issue: https://msazure.visualstudio.com/Cognitive%20Services/_workitems/edit/8775003/?workitem=8972164
173
- // throw new Error(
174
- // `The error coming from the service does not follow the expected structure: ${error}`
175
- // );
176
- logger.warning(`The error coming from the service does not follow the expected structure: ${error}`);
140
+ export function compileError(errorResponse) {
141
+ var _a;
142
+ const castErrorResponse = errorResponse;
143
+ const topLevelError = (_a = castErrorResponse.response.parsedBody) === null || _a === void 0 ? void 0 : _a.error;
144
+ if (!topLevelError)
145
+ return errorResponse;
146
+ let errorMessage = topLevelError.message || "";
147
+ let invalidDocumentBatchCode = false;
148
+ function unwrap(error) {
149
+ if ((error === null || error === void 0 ? void 0 : error.innererror) !== undefined && error.innererror.message !== undefined) {
150
+ if (error.innererror.code === "InvalidDocumentBatch") {
151
+ invalidDocumentBatchCode = true;
152
+ }
153
+ errorMessage = appendReadableErrorMessage(errorMessage, error.innererror.message);
154
+ return unwrap(error.innererror);
155
+ }
177
156
  return error;
178
157
  }
158
+ unwrap(topLevelError);
159
+ return new RestError(errorMessage, {
160
+ code: invalidDocumentBatchCode ? "InvalidDocumentBatch" : topLevelError.code,
161
+ statusCode: castErrorResponse.statusCode
162
+ });
179
163
  }
180
164
  /**
181
165
  * A wrapper for setTimeout that resolves a promise after t milliseconds.
@@ -1 +1 @@
1
- {"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/util.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;AAElC,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAEtD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAGlC,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAUvC;;;;;;;GAOG;AACH,MAAM,UAAU,qBAAqB,CACnC,WAAgB,EAChB,aAAkB;IAElB,MAAM,WAAW,GAAG,IAAI,GAAG,EAAa,CAAC;IACzC,KAAK,MAAM,IAAI,IAAI,aAAa,EAAE;QAChC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;KAChC;IAED,IAAI,aAAa,CAAC,MAAM,KAAK,WAAW,CAAC,MAAM,EAAE;QAC/C,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC;QAC7E,MAAM,CAAC,OAAO,CACZ,wBAAwB,OAAO,8DAA8D,CAC9F,CAAC;KACH;IAED,MAAM,MAAM,GAAQ,EAAE,CAAC;IACvB,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE;Q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AAE,WAAY,CAAC,OAAO,CAAC,MAAM,EAAE;YACtC,IAAI,EAAE,WAAY,CAAC,UAAU;SAC9B;KACF,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc;AAClC,wEAAwE;AACxE,MAAuB,EACvB,IAAmB,EACnB,OAAe,EACf,OAAiB,EACjB,IAAY;IAEZ,MAAM,EAAE,IAAI,EAAE,cAAc,EAAE,YAAY,EAAE,GAAG,UAAU,CACvD,uBAAuB,OAAO,EAAE,EAChC,OAAO,CACR,CAAC;IACF,IAAI;QACF,MAAM,EAAE,YAAY,EAAE,WAAW,EAAE,GAAG,MAAM,cAAc,CACxD,CAAC,YAAY,EAAE,EAAE,CACf,MAAM,CAAC,oBAAoB,CACzB,EAAE,OAAO,EAAE,YAAY,EAAE,kCAEpB,IAAI,KACP,IAAI,EACJ,UAAU,EAAE,KAAK,IAEpB,EACH,YAAY,CACb,CAAC;QACF,OAAO;YACL,YAAY,EAAE,YAAY;YAC1B,WAAW;SACZ,CAAC;KACH;IAAC,OAAO,CAAC,EAAE;QACV,IAAI,CAAC,SAAS,CAAC;YACb,IAAI,EAAE,cAAc,CAAC,KAAK;YAC1B,OAAO,EAAE,CAAC,CAAC,OAAO;SACnB,CAAC,CAAC;QACH,MAAM,CAAC,CAAC;KACT;YAAS;QACR,IAAI,CAAC,GAAG,EAAE,CAAC;KACZ;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { RestError } from \"@azure/core-rest-pipeline\";\nimport { FullOperationResponse, OperationOptions, OperationSpec } from \"@azure/core-client\";\nimport { SpanStatusCode } from \"@azure/core-tracing\";\nimport { URL, URLSearchParams } from \"./utils/url\";\nimport { logger } from \"./logger\";\nimport { GeneratedClient, StringIndexType as GeneratedStringIndexType } from \"./generated\";\nimport { TextAnalyticsAction } from \"./textAnalyticsAction\";\nimport { createSpan } from \"./tracing\";\nimport { LroResponse } from \"@azure/core-lro\";\n\n/**\n * @internal\n */\nexport interface IdObject {\n id: string;\n}\n\n/**\n * Given a sorted array of input objects (with a unique ID) and an unsorted array of results,\n * return a sorted array of results.\n *\n * @internal\n * @param sortedArray - An array of entries sorted by `id`\n * @param unsortedArray - An array of entries that contain `id` but are not sorted\n */\nexport function sortResponseIdObjects<T extends IdObject, U extends IdObject>(\n sortedArray: T[],\n unsortedArray: U[]\n): U[] {\n const unsortedMap = new Map<string, U>();\n for (const item of unsortedArray) {\n unsortedMap.set(item.id, item);\n }\n\n if (unsortedArray.length !== sortedArray.length) {\n const ordinal = unsortedArray.length > sortedArray.length ? \"more\" : \"fewer\";\n logger.warning(\n `The service returned ${ordinal} responses than inputs. Some errors may be treated as fatal.`\n );\n }\n\n const result: U[] = [];\n for (const sortedItem of sortedArray) {\n const item = unsortedMap.get(sortedItem.id);\n if (item) {\n result.push(item);\n }\n }\n return result;\n}\n\n/**\n * @internal\n */\nexport interface AssessmentIndex {\n document: number;\n sentence: number;\n assessment: number;\n}\n\n/**\n * @internal\n */\nexport function parseAssessmentIndex(pointer: string): AssessmentIndex {\n const regex = new RegExp(/#\\/documents\\/(\\d+)\\/sentences\\/(\\d+)\\/assessments\\/(\\d+)/);\n const res = regex.exec(pointer);\n if (res !== null) {\n const assessmentIndex: AssessmentIndex = {\n document: parseInt(res[1]),\n sentence: parseInt(res[2]),\n assessment: parseInt(res[3])\n };\n return assessmentIndex;\n } else {\n throw new Error(`Pointer \"${pointer}\" is not a valid Assessment pointer`);\n }\n}\n\n/**\n * Parses the index of the healthcare entity from a JSON pointer.\n * @param pointer - a JSON pointer representing an entity\n * @internal\n */\nexport function parseHealthcareEntityIndex(pointer: string): number {\n const regex = new RegExp(/#\\/results\\/documents\\/(\\d+)\\/entities\\/(\\d+)/);\n const res = regex.exec(pointer);\n if (res !== null) {\n return parseInt(res[2]);\n } else {\n throw new Error(`Pointer \"${pointer}\" is not a valid healthcare entity pointer`);\n }\n}\n\nconst jsEncodingUnit = \"Utf16CodeUnit\";\n\n/**\n * Measurement units that can used to calculate the offset and length properties.\n */\nexport type StringIndexType = \"TextElement_v8\" | \"UnicodeCodePoint\" | \"Utf16CodeUnit\";\n\n/**\n * @internal\n */\nexport function addStrEncodingParam<Options extends { stringIndexType?: StringIndexType }>(\n options: Options\n): Options & { stringIndexType: StringIndexType } {\n return { ...options, stringIndexType: options.stringIndexType || jsEncodingUnit };\n}\n\n/**\n * Set the stringIndexType property with default if it does not exist in x.\n * @param options - operation options bag that has a {@link StringIndexType}\n * @internal\n */\nexport function setStrEncodingParam<X extends { stringIndexType?: GeneratedStringIndexType }>(\n x: X\n): X & { stringIndexType: GeneratedStringIndexType } {\n return { ...x, stringIndexType: x.stringIndexType || jsEncodingUnit };\n}\n\nexport function setStrEncodingParamValue(\n stringIndexType?: GeneratedStringIndexType\n): GeneratedStringIndexType {\n return stringIndexType || jsEncodingUnit;\n}\n\n/**\n * Set the opinion mining property\n * @internal\n */\nexport function setOpinionMining<X extends { includeOpinionMining?: boolean }>(\n x: X\n): X & { opinionMining?: boolean } {\n return { ...x, opinionMining: x.includeOpinionMining };\n}\n\n/**\n * Set the pii categories property\n * @internal\n */\nexport function setCategoriesFilter<X extends { categoriesFilter?: string[] }>(\n x: X\n): X & { piiCategories?: string[] } {\n return { ...x, piiCategories: x.categoriesFilter };\n}\n\nexport function setSentenceCount<X extends { maxSentenceCount?: number }>(\n x: X\n): X & { sentenceCount?: number } {\n return { ...x, sentenceCount: x.maxSentenceCount };\n}\n\nexport function setOrderBy<X extends { orderBy?: string }>(x: X): X & { sortBy?: string } {\n return { ...x, sortBy: x.orderBy };\n}\n\n/**\n * @internal\n */\nexport function addParamsToTask<X extends TextAnalyticsAction>(\n action: X\n): { parameters?: Omit<X, \"actionName\">; taskName?: string } {\n const { actionName, ...params } = action;\n return { parameters: params, taskName: actionName };\n}\n\n/**\n * Set the modelVersion property with default if it does not exist in x.\n * @param options - operation options bag that has a {@link StringIndexType}\n * @internal\n */\nexport function setModelVersionParam<X extends { modelVersion?: string }>(\n x: X\n): X & { modelVersion: string } {\n return { ...x, modelVersion: x.modelVersion || \"latest\" };\n}\n\n/**\n * @internal\n */\nexport interface PageParam {\n top: number;\n skip: number;\n}\n\n/**\n * @internal\n */\nexport function nextLinkToTopAndSkip(nextLink: string): PageParam {\n const url = new URL(nextLink);\n const searchParams = new URLSearchParams(url.searchParams);\n let top: number;\n if (searchParams.has(\"$top\")) {\n top = parseInt(searchParams.get(\"$top\")!);\n } else {\n throw new Error(`nextLink URL does not have the $top param: ${nextLink}`);\n }\n let skip: number;\n if (searchParams.has(\"$skip\")) {\n skip = parseInt(searchParams.get(\"$skip\")!);\n } else {\n throw new Error(`nextLink URL does not have the $skip param: ${nextLink}`);\n }\n return {\n skip: skip,\n top: top\n };\n}\n\n/**\n * @internal\n */\nexport function getOperationId(operationLocation: string): string {\n const lastSlashIndex = operationLocation.lastIndexOf(\"/\");\n return operationLocation.substring(lastSlashIndex + 1);\n}\n\n/**\n * @internal\n * parses incoming errors from the service and if the inner error code is\n * InvalidDocumentBatch, it exposes that as the statusCode instead.\n * @param error - the incoming error\n */\nexport function handleInvalidDocumentBatch(error: unknown): any {\n const castError = error as {\n response: {\n parsedBody?: {\n error?: {\n innererror?: {\n code: string;\n message: string;\n };\n };\n };\n };\n statusCode: number;\n };\n const innerCode = castError.response?.parsedBody?.error?.innererror?.code;\n const innerMessage = castError.response?.parsedBody?.error?.innererror?.message;\n if (innerMessage) {\n return innerCode === \"InvalidDocumentBatch\"\n ? new RestError(innerMessage, { code: innerCode, statusCode: castError.statusCode })\n : error;\n } else {\n // unfortunately, the service currently does not follow the swagger definition\n // for errors in some cases.\n // Issue: https://msazure.visualstudio.com/Cognitive%20Services/_workitems/edit/8775003/?workitem=8972164\n // throw new Error(\n // `The error coming from the service does not follow the expected structure: ${error}`\n // );\n logger.warning(\n `The error coming from the service does not follow the expected structure: ${error}`\n );\n return error;\n }\n}\n\n/**\n * A wrapper for setTimeout that resolves a promise after t milliseconds.\n * @internal\n * @param timeInMs - The number of milliseconds to be delayed.\n * @returns Resolved promise\n */\nexport function delay(timeInMs: number): Promise<void> {\n return new Promise((resolve) => setTimeout(() => resolve(), timeInMs));\n}\n\n/**\n * @internal\n */\nexport function compose<T1, T2, T3>(fn1: (x: T1) => T2, fn2: (y: T2) => T3): (x: T1) => T3 {\n return (value: T1) => fn2(fn1(value));\n}\n\n/**\n * @internal\n */\nexport async function getRawResponse<TOptions extends OperationOptions, TResult>(\n f: (options: TOptions) => Promise<TResult>,\n options: TOptions\n): Promise<LroResponse<TResult>> {\n const { onResponse } = options || {};\n let rawResponse: FullOperationResponse | undefined = undefined;\n const flatResponse = await f({\n ...options,\n onResponse: (response: FullOperationResponse, flatResponseParam: unknown) => {\n rawResponse = response;\n onResponse?.(response, flatResponseParam);\n }\n });\n return {\n flatResponse,\n rawResponse: {\n statusCode: rawResponse!.status,\n headers: rawResponse!.headers.toJSON(),\n body: rawResponse!.parsedBody\n }\n };\n}\n\n/**\n * @internal\n */\nexport async function sendGetRequest<TOptions extends OperationOptions>(\n // eslint-disable-next-line @azure/azure-sdk/ts-use-interface-parameters\n client: GeneratedClient,\n spec: OperationSpec,\n spanStr: string,\n options: TOptions,\n path: string\n): Promise<LroResponse<unknown>> {\n const { span, updatedOptions: finalOptions } = createSpan(\n `TextAnalyticsClient-${spanStr}`,\n options\n );\n try {\n const { flatResponse, rawResponse } = await getRawResponse(\n (paramOptions) =>\n client.sendOperationRequest(\n { options: paramOptions },\n {\n ...spec,\n path,\n httpMethod: \"GET\"\n }\n ),\n finalOptions\n );\n return {\n flatResponse: flatResponse,\n rawResponse\n };\n } catch (e) {\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: e.message\n });\n throw e;\n } finally {\n span.end();\n }\n}\n"]}
1
+ {"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/util.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;AAElC,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAA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YAC1B,OAAO,EAAE,CAAC,CAAC,OAAO;SACnB,CAAC,CAAC;QACH,MAAM,CAAC,CAAC;KACT;YAAS;QACR,IAAI,CAAC,GAAG,EAAE,CAAC;KACZ;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { RestError } from \"@azure/core-rest-pipeline\";\nimport { FullOperationResponse, OperationOptions, OperationSpec } from \"@azure/core-client\";\nimport { SpanStatusCode } from \"@azure/core-tracing\";\nimport { logger } from \"./logger\";\nimport {\n ErrorResponse,\n GeneratedClient,\n InnerError,\n StringIndexType as GeneratedStringIndexType,\n TextAnalyticsError\n} from \"./generated\";\nimport { TextAnalyticsAction } from \"./textAnalyticsAction\";\nimport { createSpan } from \"./tracing\";\nimport { LroResponse } from \"@azure/core-lro\";\n\n/**\n * @internal\n */\nexport interface IdObject {\n id: string;\n}\n\n/**\n * Given a sorted array of input objects (with a unique ID) and an unsorted array of results,\n * return a sorted array of results.\n *\n * @internal\n * @param sortedArray - An array of entries sorted by `id`\n * @param unsortedArray - An array of entries that contain `id` but are not sorted\n */\nexport function sortResponseIdObjects<T extends IdObject, U extends IdObject>(\n sortedArray: T[],\n unsortedArray: U[]\n): U[] {\n const unsortedMap = new Map<string, U>();\n for (const item of unsortedArray) {\n unsortedMap.set(item.id, item);\n }\n\n if (unsortedArray.length !== sortedArray.length) {\n const ordinal = unsortedArray.length > sortedArray.length ? \"more\" : \"fewer\";\n logger.warning(\n `The service returned ${ordinal} responses than inputs. Some errors may be treated as fatal.`\n );\n }\n\n const result: U[] = [];\n for (const sortedItem of sortedArray) {\n const item = unsortedMap.get(sortedItem.id);\n if (item) {\n result.push(item);\n }\n }\n return result;\n}\n\n/**\n * @internal\n */\nexport interface AssessmentIndex {\n document: number;\n sentence: number;\n assessment: number;\n}\n\n/**\n * @internal\n */\nexport function parseAssessmentIndex(pointer: string): AssessmentIndex {\n const regex = new RegExp(/#\\/documents\\/(\\d+)\\/sentences\\/(\\d+)\\/assessments\\/(\\d+)/);\n const res = regex.exec(pointer);\n if (res !== null) {\n const assessmentIndex: AssessmentIndex = {\n document: parseInt(res[1]),\n sentence: parseInt(res[2]),\n assessment: parseInt(res[3])\n };\n return assessmentIndex;\n } else {\n throw new Error(`Pointer \"${pointer}\" is not a valid Assessment pointer`);\n }\n}\n\n/**\n * Parses the index of the healthcare entity from a JSON pointer.\n * @param pointer - a JSON pointer representing an entity\n * @internal\n */\nexport function parseHealthcareEntityIndex(pointer: string): number {\n const regex = new RegExp(/#\\/results\\/documents\\/(\\d+)\\/entities\\/(\\d+)/);\n const res = regex.exec(pointer);\n if (res !== null) {\n return parseInt(res[2]);\n } else {\n throw new Error(`Pointer \"${pointer}\" is not a valid healthcare entity pointer`);\n }\n}\n\nconst jsEncodingUnit = \"Utf16CodeUnit\";\n\n/**\n * Measurement units that can used to calculate the offset and length properties.\n */\nexport type StringIndexType = \"TextElement_v8\" | \"UnicodeCodePoint\" | \"Utf16CodeUnit\";\n\n/**\n * @internal\n */\nexport function addStrEncodingParam<Options extends { stringIndexType?: StringIndexType }>(\n options: Options\n): Options & { stringIndexType: StringIndexType } {\n return { ...options, stringIndexType: options.stringIndexType || jsEncodingUnit };\n}\n\n/**\n * Set the stringIndexType property with default if it does not exist in x.\n * @param options - operation options bag that has a {@link StringIndexType}\n * @internal\n */\nexport function setStrEncodingParam<X extends { stringIndexType?: GeneratedStringIndexType }>(\n x: X\n): X & { stringIndexType: GeneratedStringIndexType } {\n return { ...x, stringIndexType: x.stringIndexType || jsEncodingUnit };\n}\n\nexport function setStrEncodingParamValue(\n stringIndexType?: GeneratedStringIndexType\n): GeneratedStringIndexType {\n return stringIndexType || jsEncodingUnit;\n}\n\n/**\n * Set the opinion mining property\n * @internal\n */\nexport function setOpinionMining<X extends { includeOpinionMining?: boolean }>(\n x: X\n): X & { opinionMining?: boolean } {\n return { ...x, opinionMining: x.includeOpinionMining };\n}\n\n/**\n * Set the pii categories property\n * @internal\n */\nexport function setCategoriesFilter<X extends { categoriesFilter?: string[] }>(\n x: X\n): X & { piiCategories?: string[] } {\n return { ...x, piiCategories: x.categoriesFilter };\n}\n\nexport function setSentenceCount<X extends { maxSentenceCount?: number }>(\n x: X\n): X & { sentenceCount?: number } {\n return { ...x, sentenceCount: x.maxSentenceCount };\n}\n\nexport function setOrderBy<X extends { orderBy?: string }>(x: X): X & { sortBy?: string } {\n return { ...x, sortBy: x.orderBy };\n}\n\n/**\n * @internal\n */\nexport function addParamsToTask<X extends TextAnalyticsAction>(\n action: X\n): { parameters?: Omit<X, \"actionName\">; taskName?: string } {\n const { actionName, ...params } = action;\n return { parameters: params, taskName: actionName };\n}\n\n/**\n * Set the modelVersion property with default if it does not exist in x.\n * @param options - operation options bag that has a {@link StringIndexType}\n * @internal\n */\nexport function setModelVersionParam<X extends { modelVersion?: string }>(\n x: X\n): X & { modelVersion: string } {\n return { ...x, modelVersion: x.modelVersion || \"latest\" };\n}\n\n/**\n * @internal\n */\nexport interface PageParam {\n top: number;\n skip: number;\n}\n\n/**\n * @internal\n */\nexport function getOperationId(operationLocation: string): string {\n const lastSlashIndex = operationLocation.lastIndexOf(\"/\");\n return operationLocation.substring(lastSlashIndex + 1);\n}\n\nfunction appendReadableErrorMessage(currentMessage: string, innerMessage: string): string {\n let message = currentMessage;\n if (message.slice(-1) !== \".\") {\n message = message + \".\";\n }\n return message + \" \" + innerMessage;\n}\n\n/**\n * @internal\n * parses incoming errors from the service and if the inner error code is\n * InvalidDocumentBatch, it exposes that as the statusCode instead.\n * @param error - the incoming error\n */\nexport function compileError(errorResponse: unknown): any {\n const castErrorResponse = errorResponse as {\n response: {\n parsedBody?: ErrorResponse;\n };\n statusCode: number;\n };\n const topLevelError = castErrorResponse.response.parsedBody?.error;\n if (!topLevelError) return errorResponse;\n let errorMessage = topLevelError.message || \"\";\n let invalidDocumentBatchCode = false;\n function unwrap(error: TextAnalyticsError | InnerError): TextAnalyticsError {\n if (error?.innererror !== undefined && error.innererror.message !== undefined) {\n if (error.innererror.code === \"InvalidDocumentBatch\") {\n invalidDocumentBatchCode = true;\n }\n errorMessage = appendReadableErrorMessage(errorMessage, error.innererror.message);\n return unwrap(error.innererror);\n }\n return error as TextAnalyticsError;\n }\n unwrap(topLevelError);\n return new RestError(errorMessage, {\n code: invalidDocumentBatchCode ? \"InvalidDocumentBatch\" : topLevelError.code,\n statusCode: castErrorResponse.statusCode\n });\n}\n\n/**\n * A wrapper for setTimeout that resolves a promise after t milliseconds.\n * @internal\n * @param timeInMs - The number of milliseconds to be delayed.\n * @returns Resolved promise\n */\nexport function delay(timeInMs: number): Promise<void> {\n return new Promise((resolve) => setTimeout(() => resolve(), timeInMs));\n}\n\n/**\n * @internal\n */\nexport function compose<T1, T2, T3>(fn1: (x: T1) => T2, fn2: (y: T2) => T3): (x: T1) => T3 {\n return (value: T1) => fn2(fn1(value));\n}\n\n/**\n * @internal\n */\nexport async function getRawResponse<TOptions extends OperationOptions, TResult>(\n f: (options: TOptions) => Promise<TResult>,\n options: TOptions\n): Promise<LroResponse<TResult>> {\n const { onResponse } = options || {};\n let rawResponse: FullOperationResponse | undefined = undefined;\n const flatResponse = await f({\n ...options,\n onResponse: (response: FullOperationResponse, flatResponseParam: unknown) => {\n rawResponse = response;\n onResponse?.(response, flatResponseParam);\n }\n });\n return {\n flatResponse,\n rawResponse: {\n statusCode: rawResponse!.status,\n headers: rawResponse!.headers.toJSON(),\n body: rawResponse!.parsedBody\n }\n };\n}\n\n/**\n * @internal\n */\nexport async function sendGetRequest<TOptions extends OperationOptions>(\n // eslint-disable-next-line @azure/azure-sdk/ts-use-interface-parameters\n client: GeneratedClient,\n spec: OperationSpec,\n spanStr: string,\n options: TOptions,\n path: string\n): Promise<LroResponse<unknown>> {\n const { span, updatedOptions: finalOptions } = createSpan(\n `TextAnalyticsClient-${spanStr}`,\n options\n );\n try {\n const { flatResponse, rawResponse } = await getRawResponse(\n (paramOptions) =>\n client.sendOperationRequest(\n { options: paramOptions },\n {\n ...spec,\n path,\n httpMethod: \"GET\"\n }\n ),\n finalOptions\n );\n return {\n flatResponse: flatResponse,\n rawResponse\n };\n } catch (e) {\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: e.message\n });\n throw e;\n } finally {\n span.end();\n }\n}\n"]}