@azure/ai-text-analytics 5.2.0-alpha.20211029.2 → 5.2.0-alpha.20211214.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.
@@ -4,7 +4,7 @@ const API_KEY_HEADER_NAME = "Ocp-Apim-Subscription-Key";
4
4
  /**
5
5
  * The programmatic identifier of the textAnalyticsAzureKeyCredentialPolicy.
6
6
  */
7
- export const textAnalyticsAzureKeyCredentialPolicyName = "textAnalyticsAzureKeyCredentialPolicy";
7
+ const textAnalyticsAzureKeyCredentialPolicyName = "textAnalyticsAzureKeyCredentialPolicy";
8
8
  /**
9
9
  * Create an HTTP pipeline policy to authenticate a request
10
10
  * using an `AzureKeyCredential` for Text Analytics
@@ -1 +1 @@
1
- {"version":3,"file":"azureKeyCredentialPolicy.js","sourceRoot":"","sources":["../../src/azureKeyCredentialPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAUlC,MAAM,mBAAmB,GAAG,2BAA2B,CAAC;AAExD;;GAEG;AACH,MAAM,CAAC,MAAM,yCAAyC,GAAG,uCAAuC,CAAC;AAEjG;;;;GAIG;AACH,MAAM,UAAU,qCAAqC,CAAC,UAAyB;IAC7E,OAAO;QACL,IAAI,EAAE,yCAAyC;QAC/C,WAAW,CAAC,OAAwB,EAAE,IAAiB;YACrD,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC;YACzD,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;QACvB,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { KeyCredential } from \"@azure/core-auth\";\nimport {\n PipelineResponse,\n PipelineRequest,\n SendRequest,\n PipelinePolicy\n} from \"@azure/core-rest-pipeline\";\n\nconst API_KEY_HEADER_NAME = \"Ocp-Apim-Subscription-Key\";\n\n/**\n * The programmatic identifier of the textAnalyticsAzureKeyCredentialPolicy.\n */\nexport const textAnalyticsAzureKeyCredentialPolicyName = \"textAnalyticsAzureKeyCredentialPolicy\";\n\n/**\n * Create an HTTP pipeline policy to authenticate a request\n * using an `AzureKeyCredential` for Text Analytics\n * @internal\n */\nexport function textAnalyticsAzureKeyCredentialPolicy(credential: KeyCredential): PipelinePolicy {\n return {\n name: textAnalyticsAzureKeyCredentialPolicyName,\n sendRequest(request: PipelineRequest, next: SendRequest): Promise<PipelineResponse> {\n request.headers.set(API_KEY_HEADER_NAME, credential.key);\n return next(request);\n }\n };\n}\n"]}
1
+ {"version":3,"file":"azureKeyCredentialPolicy.js","sourceRoot":"","sources":["../../src/azureKeyCredentialPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAUlC,MAAM,mBAAmB,GAAG,2BAA2B,CAAC;AAExD;;GAEG;AACH,MAAM,yCAAyC,GAAG,uCAAuC,CAAC;AAE1F;;;;GAIG;AACH,MAAM,UAAU,qCAAqC,CAAC,UAAyB;IAC7E,OAAO;QACL,IAAI,EAAE,yCAAyC;QAC/C,WAAW,CAAC,OAAwB,EAAE,IAAiB;YACrD,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC;YACzD,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;QACvB,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { KeyCredential } from \"@azure/core-auth\";\nimport {\n PipelineResponse,\n PipelineRequest,\n SendRequest,\n PipelinePolicy\n} from \"@azure/core-rest-pipeline\";\n\nconst API_KEY_HEADER_NAME = \"Ocp-Apim-Subscription-Key\";\n\n/**\n * The programmatic identifier of the textAnalyticsAzureKeyCredentialPolicy.\n */\nconst textAnalyticsAzureKeyCredentialPolicyName = \"textAnalyticsAzureKeyCredentialPolicy\";\n\n/**\n * Create an HTTP pipeline policy to authenticate a request\n * using an `AzureKeyCredential` for Text Analytics\n * @internal\n */\nexport function textAnalyticsAzureKeyCredentialPolicy(credential: KeyCredential): PipelinePolicy {\n return {\n name: textAnalyticsAzureKeyCredentialPolicyName,\n sendRequest(request: PipelineRequest, next: SendRequest): Promise<PipelineResponse> {\n request.headers.set(API_KEY_HEADER_NAME, credential.key);\n return next(request);\n }\n };\n}\n"]}
@@ -25,7 +25,7 @@ export class GeneratedClientContext extends coreClient.ServiceClient {
25
25
  const defaults = {
26
26
  requestContentType: "application/json; charset=utf-8"
27
27
  };
28
- const packageDetails = `azsdk-js-ai-text-analytics/5.2.0-beta.2`;
28
+ const packageDetails = `azsdk-js-ai-text-analytics/5.2.0-beta.3`;
29
29
  const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
30
30
  ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`
31
31
  : `${packageDetails}`;
@@ -1 +1 @@
1
- {"version":3,"file":"generatedClientContext.js","sourceRoot":"","sources":["../../../src/generated/generatedClientContext.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,UAAU,MAAM,oBAAoB,CAAC;AAGjD,gBAAgB;AAChB,MAAM,OAAO,sBAAuB,SAAQ,UAAU,CAAC,aAAa;IAIlE;;;;;OAKG;IACH,YAAY,QAAgB,EAAE,OAAuC;QACnE,IAAI,QAAQ,KAAK,SAAS,EAAE;YAC1B,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;SAC9C;QAED,0CAA0C;QAC1C,IAAI,CAAC,OAAO,EAAE;YACZ,OAAO,GAAG,EAAE,CAAC;SACd;QACD,MAAM,QAAQ,GAAkC;YAC9C,kBAAkB,EAAE,iCAAiC;SACtD,CAAC;QAEF,MAAM,cAAc,GAAG,yCAAyC,CAAC;QACjE,MAAM,eAAe,GACnB,OAAO,CAAC,gBAAgB,IAAI,OAAO,CAAC,gBAAgB,CAAC,eAAe;YAClE,CAAC,CAAC,GAAG,OAAO,CAAC,gBAAgB,CAAC,eAAe,IAAI,cAAc,EAAE;YACjE,CAAC,CAAC,GAAG,cAAc,EAAE,CAAC;QAE1B,MAAM,mBAAmB,iDACpB,QAAQ,GACR,OAAO,KACV,gBAAgB,EAAE;gBAChB,eAAe;aAChB,EACD,OAAO,EAAE,OAAO,CAAC,QAAQ,IAAI,wCAAwC,GACtE,CAAC;QACF,KAAK,CAAC,mBAAmB,CAAC,CAAC;QAC3B,wBAAwB;QACxB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QAEzB,0CAA0C;QAC1C,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,gBAAgB,CAAC;IAC3D,CAAC;CACF","sourcesContent":["/*\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n *\n * Code generated by Microsoft (R) AutoRest Code Generator.\n * Changes may cause incorrect behavior and will be lost if the code is regenerated.\n */\n\nimport * as coreClient from \"@azure/core-client\";\nimport { GeneratedClientOptionalParams } from \"./models\";\n\n/** @internal */\nexport class GeneratedClientContext extends coreClient.ServiceClient {\n endpoint: string;\n apiVersion: string;\n\n /**\n * Initializes a new instance of the GeneratedClientContext class.\n * @param endpoint Supported Cognitive Services endpoints (protocol and hostname, for example:\n * https://westus.api.cognitive.microsoft.com).\n * @param options The parameter options\n */\n constructor(endpoint: string, options?: GeneratedClientOptionalParams) {\n if (endpoint === undefined) {\n throw new Error(\"'endpoint' cannot be null\");\n }\n\n // Initializing default values for options\n if (!options) {\n options = {};\n }\n const defaults: GeneratedClientOptionalParams = {\n requestContentType: \"application/json; charset=utf-8\"\n };\n\n const packageDetails = `azsdk-js-ai-text-analytics/5.2.0-beta.2`;\n const userAgentPrefix =\n options.userAgentOptions && options.userAgentOptions.userAgentPrefix\n ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`\n : `${packageDetails}`;\n\n const optionsWithDefaults = {\n ...defaults,\n ...options,\n userAgentOptions: {\n userAgentPrefix\n },\n baseUri: options.endpoint || \"{Endpoint}/text/analytics/{ApiVersion}\"\n };\n super(optionsWithDefaults);\n // Parameter assignments\n this.endpoint = endpoint;\n\n // Assigning values to Constant parameters\n this.apiVersion = options.apiVersion || \"v3.2-preview.2\";\n }\n}\n"]}
1
+ {"version":3,"file":"generatedClientContext.js","sourceRoot":"","sources":["../../../src/generated/generatedClientContext.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,UAAU,MAAM,oBAAoB,CAAC;AAGjD,gBAAgB;AAChB,MAAM,OAAO,sBAAuB,SAAQ,UAAU,CAAC,aAAa;IAIlE;;;;;OAKG;IACH,YAAY,QAAgB,EAAE,OAAuC;QACnE,IAAI,QAAQ,KAAK,SAAS,EAAE;YAC1B,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;SAC9C;QAED,0CAA0C;QAC1C,IAAI,CAAC,OAAO,EAAE;YACZ,OAAO,GAAG,EAAE,CAAC;SACd;QACD,MAAM,QAAQ,GAAkC;YAC9C,kBAAkB,EAAE,iCAAiC;SACtD,CAAC;QAEF,MAAM,cAAc,GAAG,yCAAyC,CAAC;QACjE,MAAM,eAAe,GACnB,OAAO,CAAC,gBAAgB,IAAI,OAAO,CAAC,gBAAgB,CAAC,eAAe;YAClE,CAAC,CAAC,GAAG,OAAO,CAAC,gBAAgB,CAAC,eAAe,IAAI,cAAc,EAAE;YACjE,CAAC,CAAC,GAAG,cAAc,EAAE,CAAC;QAE1B,MAAM,mBAAmB,iDACpB,QAAQ,GACR,OAAO,KACV,gBAAgB,EAAE;gBAChB,eAAe;aAChB,EACD,OAAO,EAAE,OAAO,CAAC,QAAQ,IAAI,wCAAwC,GACtE,CAAC;QACF,KAAK,CAAC,mBAAmB,CAAC,CAAC;QAC3B,wBAAwB;QACxB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QAEzB,0CAA0C;QAC1C,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,gBAAgB,CAAC;IAC3D,CAAC;CACF","sourcesContent":["/*\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n *\n * Code generated by Microsoft (R) AutoRest Code Generator.\n * Changes may cause incorrect behavior and will be lost if the code is regenerated.\n */\n\nimport * as coreClient from \"@azure/core-client\";\nimport { GeneratedClientOptionalParams } from \"./models\";\n\n/** @internal */\nexport class GeneratedClientContext extends coreClient.ServiceClient {\n endpoint: string;\n apiVersion: string;\n\n /**\n * Initializes a new instance of the GeneratedClientContext class.\n * @param endpoint Supported Cognitive Services endpoints (protocol and hostname, for example:\n * https://westus.api.cognitive.microsoft.com).\n * @param options The parameter options\n */\n constructor(endpoint: string, options?: GeneratedClientOptionalParams) {\n if (endpoint === undefined) {\n throw new Error(\"'endpoint' cannot be null\");\n }\n\n // Initializing default values for options\n if (!options) {\n options = {};\n }\n const defaults: GeneratedClientOptionalParams = {\n requestContentType: \"application/json; charset=utf-8\"\n };\n\n const packageDetails = `azsdk-js-ai-text-analytics/5.2.0-beta.3`;\n const userAgentPrefix =\n options.userAgentOptions && options.userAgentOptions.userAgentPrefix\n ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`\n : `${packageDetails}`;\n\n const optionsWithDefaults = {\n ...defaults,\n ...options,\n userAgentOptions: {\n userAgentPrefix\n },\n baseUri: options.endpoint || \"{Endpoint}/text/analytics/{ApiVersion}\"\n };\n super(optionsWithDefaults);\n // Parameter assignments\n this.endpoint = endpoint;\n\n // Assigning values to Constant parameters\n this.apiVersion = options.apiVersion || \"v3.2-preview.2\";\n }\n}\n"]}
@@ -37,16 +37,6 @@ export function makeTextAnalyticsErrorResult(id, error) {
37
37
  error: intoTextAnalyticsError(error)
38
38
  };
39
39
  }
40
- /**
41
- * @internal
42
- * combines successful and erroneous results into a single array of results and
43
- * sort them so that the IDs order match that of the input documents array.
44
- * @param input - the array of documents sent to the service for processing.
45
- * @param response - the response received from the service.
46
- */
47
- export function combineSuccessfulAndErroneousDocuments(input, response) {
48
- return processAndCombineSuccessfulAndErroneousDocuments(input, response, (x) => x, makeTextAnalyticsErrorResult);
49
- }
50
40
  /**
51
41
  * @internal
52
42
  * combines successful and erroneous results into a single array of results and
@@ -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;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,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,QAAiD;IAEjD,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,QAGC,EACD,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,QAAwD,EACxD,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;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"]}
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;AAqJ/C;;;;GAIG;AACH,MAAM,UAAU,sBAAsB,CACpC,UAAyD;IAEzD,wDAAwD;IACxD,8BAA8B;IAC9B,IAAI,UAAU,CAAC,UAAU,KAAK,SAAS,EAAE;QACvC,OAAO,sBAA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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 * 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\ninterface 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\ninterface 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\ninterface 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\ninterface 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 * @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"]}
@@ -109,21 +109,6 @@ export function addParamsToTask(action) {
109
109
  const { actionName } = action, params = __rest(action, ["actionName"]);
110
110
  return { parameters: params, taskName: actionName };
111
111
  }
112
- /**
113
- * Set the modelVersion property with default if it does not exist in x.
114
- * @param options - operation options bag that has a {@link StringIndexType}
115
- * @internal
116
- */
117
- export function setModelVersionParam(x) {
118
- return Object.assign(Object.assign({}, x), { modelVersion: x.modelVersion || "latest" });
119
- }
120
- /**
121
- * @internal
122
- */
123
- export function getOperationId(operationLocation) {
124
- const lastSlashIndex = operationLocation.lastIndexOf("/");
125
- return operationLocation.substring(lastSlashIndex + 1);
126
- }
127
112
  function appendReadableErrorMessage(currentMessage, innerMessage) {
128
113
  let message = currentMessage;
129
114
  if (message.slice(-1) !== ".") {
@@ -161,15 +146,6 @@ export function compileError(errorResponse) {
161
146
  statusCode: castErrorResponse.statusCode
162
147
  });
163
148
  }
164
- /**
165
- * A wrapper for setTimeout that resolves a promise after t milliseconds.
166
- * @internal
167
- * @param timeInMs - The number of milliseconds to be delayed.
168
- * @returns Resolved promise
169
- */
170
- export function delay(timeInMs) {
171
- return new Promise((resolve) => setTimeout(() => resolve(), timeInMs));
172
- }
173
149
  /**
174
150
  * @internal
175
151
  */
@@ -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,MAAM,EAAE,MAAM,UAAU,CAAC;AASlC,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,C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AC,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 { 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"]}
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,MAAM,EAAE,MAAM,UAAU,CAAC;AASlC,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAOvC;;;;;;;GAOG;AACH,MAAM,UAAU,qBAAqB,CACnC,WAAgB,EAChB,aAA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Ac,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 { 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\ninterface 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\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 * @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"]}
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "sdk-type": "client",
4
4
  "author": "Microsoft Corporation",
5
5
  "description": "An isomorphic client library for the Azure Text Analytics service.",
6
- "version": "5.2.0-alpha.20211029.2",
6
+ "version": "5.2.0-alpha.20211214.2",
7
7
  "keywords": [
8
8
  "node",
9
9
  "azure",
@@ -81,8 +81,7 @@
81
81
  "test": "npm run clean && npm run build:test && npm run unit-test",
82
82
  "unit-test:browser": "karma start --single-run",
83
83
  "unit-test:node": "mocha -r esm --require ts-node/register --reporter ../../../common/tools/mocha-multi-reporter.js --timeout 1200000 --full-trace \"test/{,!(browser)/**/}*.spec.ts\"",
84
- "unit-test": "npm run unit-test:node && npm run unit-test:browser",
85
- "docs": "typedoc --excludePrivate --excludeNotExported --excludeExternals --stripInternal --mode file --out ./dist/docs ./src"
84
+ "unit-test": "npm run unit-test:node && npm run unit-test:browser"
86
85
  },
87
86
  "sideEffects": false,
88
87
  "autoPublish": false,
@@ -100,7 +99,7 @@
100
99
  "devDependencies": {
101
100
  "@azure/dev-tool": ">=1.0.0-alpha <1.0.0-alphb",
102
101
  "@azure/eslint-plugin-azure-sdk": ">=3.0.0-alpha <3.0.0-alphb",
103
- "@azure/identity": "2.0.0-beta.6",
102
+ "@azure/identity": "^2.0.1",
104
103
  "@azure/test-utils": ">=1.0.0-alpha <1.0.0-alphb",
105
104
  "@azure-tools/test-recorder": "^1.0.0",
106
105
  "@microsoft/api-extractor": "^7.18.11",
@@ -129,15 +128,14 @@
129
128
  "karma-sourcemap-loader": "^0.3.8",
130
129
  "karma-source-map-support": "~1.4.0",
131
130
  "mocha": "^7.1.1",
132
- "mocha-junit-reporter": "^1.18.0",
133
- "nyc": "^14.0.0",
131
+ "mocha-junit-reporter": "^2.0.0",
132
+ "nyc": "^15.0.0",
134
133
  "prettier": "^1.16.4",
135
134
  "rimraf": "^3.0.0",
136
135
  "rollup": "^1.16.3",
137
136
  "sinon": "^9.0.2",
138
137
  "source-map-support": "^0.5.9",
139
138
  "ts-node": "^10.0.0",
140
- "typescript": "~4.2.0",
141
- "typedoc": "0.15.2"
139
+ "typescript": "~4.2.0"
142
140
  }
143
141
  }