@azure/ai-text-analytics 5.2.0-alpha.20211214.2 → 5.2.0-alpha.20220131.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/dist/index.js +133 -103
  2. package/dist/index.js.map +1 -1
  3. package/dist-esm/src/analyzeActionsResult.js +15 -15
  4. package/dist-esm/src/analyzeActionsResult.js.map +1 -1
  5. package/dist-esm/src/analyzeHealthcareEntitiesResult.js +4 -4
  6. package/dist-esm/src/analyzeHealthcareEntitiesResult.js.map +1 -1
  7. package/dist-esm/src/analyzeLro.js +11 -11
  8. package/dist-esm/src/analyzeLro.js.map +1 -1
  9. package/dist-esm/src/analyzeSentimentResult.js +5 -5
  10. package/dist-esm/src/analyzeSentimentResult.js.map +1 -1
  11. package/dist-esm/src/analyzeSentimentResultArray.js +1 -1
  12. package/dist-esm/src/analyzeSentimentResultArray.js.map +1 -1
  13. package/dist-esm/src/azureKeyCredentialPolicy.js +1 -1
  14. package/dist-esm/src/azureKeyCredentialPolicy.js.map +1 -1
  15. package/dist-esm/src/detectLanguageResult.js +1 -1
  16. package/dist-esm/src/detectLanguageResult.js.map +1 -1
  17. package/dist-esm/src/detectLanguageResultArray.js +1 -1
  18. package/dist-esm/src/detectLanguageResultArray.js.map +1 -1
  19. package/dist-esm/src/extractKeyPhrasesResult.js +1 -1
  20. package/dist-esm/src/extractKeyPhrasesResult.js.map +1 -1
  21. package/dist-esm/src/extractKeyPhrasesResultArray.js +1 -1
  22. package/dist-esm/src/extractKeyPhrasesResultArray.js.map +1 -1
  23. package/dist-esm/src/extractSummaryResult.js +1 -1
  24. package/dist-esm/src/extractSummaryResult.js.map +1 -1
  25. package/dist-esm/src/extractSummaryResultArray.js +1 -1
  26. package/dist-esm/src/extractSummaryResultArray.js.map +1 -1
  27. package/dist-esm/src/healthLro.js +12 -12
  28. package/dist-esm/src/healthLro.js.map +1 -1
  29. package/dist-esm/src/index.js +2 -4
  30. package/dist-esm/src/index.js.map +1 -1
  31. package/dist-esm/src/multiCategoryClassifyResult.js +1 -1
  32. package/dist-esm/src/multiCategoryClassifyResult.js.map +1 -1
  33. package/dist-esm/src/multiCategoryClassifyResultArray.js +1 -1
  34. package/dist-esm/src/multiCategoryClassifyResultArray.js.map +1 -1
  35. package/dist-esm/src/recognizeCategorizedEntitiesResult.js +1 -1
  36. package/dist-esm/src/recognizeCategorizedEntitiesResult.js.map +1 -1
  37. package/dist-esm/src/recognizeCategorizedEntitiesResultArray.js +1 -1
  38. package/dist-esm/src/recognizeCategorizedEntitiesResultArray.js.map +1 -1
  39. package/dist-esm/src/recognizeCustomEntitiesResult.js +1 -1
  40. package/dist-esm/src/recognizeCustomEntitiesResult.js.map +1 -1
  41. package/dist-esm/src/recognizeCustomEntitiesResultArray.js +1 -1
  42. package/dist-esm/src/recognizeCustomEntitiesResultArray.js.map +1 -1
  43. package/dist-esm/src/recognizeLinkedEntitiesResult.js +1 -1
  44. package/dist-esm/src/recognizeLinkedEntitiesResult.js.map +1 -1
  45. package/dist-esm/src/recognizeLinkedEntitiesResultArray.js +1 -1
  46. package/dist-esm/src/recognizeLinkedEntitiesResultArray.js.map +1 -1
  47. package/dist-esm/src/recognizePiiEntitiesResult.js +1 -1
  48. package/dist-esm/src/recognizePiiEntitiesResult.js.map +1 -1
  49. package/dist-esm/src/recognizePiiEntitiesResultArray.js +1 -1
  50. package/dist-esm/src/recognizePiiEntitiesResultArray.js.map +1 -1
  51. package/dist-esm/src/singleCategoryClassifyResult.js +1 -1
  52. package/dist-esm/src/singleCategoryClassifyResult.js.map +1 -1
  53. package/dist-esm/src/singleCategoryClassifyResultArray.js +1 -1
  54. package/dist-esm/src/singleCategoryClassifyResultArray.js.map +1 -1
  55. package/dist-esm/src/textAnalyticsClient.js +41 -41
  56. package/dist-esm/src/textAnalyticsClient.js.map +1 -1
  57. package/dist-esm/src/textAnalyticsResult.js +5 -5
  58. package/dist-esm/src/textAnalyticsResult.js.map +1 -1
  59. package/dist-esm/src/tracing.js +1 -1
  60. package/dist-esm/src/tracing.js.map +1 -1
  61. package/dist-esm/src/util.js +9 -6
  62. package/dist-esm/src/util.js.map +1 -1
  63. package/package.json +8 -10
@@ -15,7 +15,7 @@ export function intoTextAnalyticsError(errorModel) {
15
15
  return {
16
16
  code: errorModel.code,
17
17
  message: errorModel.message,
18
- target: errorModel.target
18
+ target: errorModel.target,
19
19
  };
20
20
  }
21
21
  /**
@@ -25,7 +25,7 @@ export function makeTextAnalyticsSuccessResult(id, warnings, statistics) {
25
25
  return {
26
26
  id,
27
27
  statistics,
28
- warnings
28
+ warnings,
29
29
  };
30
30
  }
31
31
  /**
@@ -34,7 +34,7 @@ export function makeTextAnalyticsSuccessResult(id, warnings, statistics) {
34
34
  export function makeTextAnalyticsErrorResult(id, error) {
35
35
  return {
36
36
  id,
37
- error: intoTextAnalyticsError(error)
37
+ error: intoTextAnalyticsError(error),
38
38
  };
39
39
  }
40
40
  /**
@@ -62,7 +62,7 @@ export function combineSuccessfulAndErroneousDocumentsWithStatisticsAndModelVers
62
62
  const sorted = processAndCombineSuccessfulAndErroneousDocuments(input, response, processSuccess, processError);
63
63
  return Object.assign(sorted, {
64
64
  statistics: response.statistics,
65
- modelVersion: response.modelVersion
65
+ modelVersion: response.modelVersion,
66
66
  });
67
67
  }
68
68
  /**
@@ -78,7 +78,7 @@ export function combineSuccessfulAndErroneousDocumentsWithStatisticsAndCustomPro
78
78
  return Object.assign(sorted, {
79
79
  statistics: response.statistics,
80
80
  projectName: response.projectName,
81
- deploymentName: response.deploymentName
81
+ deploymentName: response.deploymentName,
82
82
  });
83
83
  }
84
84
  //# 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;AAqJ/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,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 * 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"]}
1
+ {"version":3,"file":"textAnalyticsResult.js","sourceRoot":"","sources":["../../src/text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AAmE,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 * 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)[] =\n response.documents.map(processSuccess);\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"]}
@@ -7,6 +7,6 @@ import { createSpanFunction } from "@azure/core-tracing";
7
7
  */
8
8
  export const createSpan = createSpanFunction({
9
9
  packagePrefix: "Azure.CognitiveServices.TextAnalytics",
10
- namespace: "Microsoft.CognitiveServices"
10
+ namespace: "Microsoft.CognitiveServices",
11
11
  });
12
12
  //# sourceMappingURL=tracing.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"tracing.js","sourceRoot":"","sources":["../../src/tracing.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEzD;;;GAGG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,kBAAkB,CAAC;IAC3C,aAAa,EAAE,uCAAuC;IACtD,SAAS,EAAE,6BAA6B;CACzC,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { createSpanFunction } from \"@azure/core-tracing\";\n\n/**\n * Creates a span using the global tracer.\n * @internal\n */\nexport const createSpan = createSpanFunction({\n packagePrefix: \"Azure.CognitiveServices.TextAnalytics\",\n namespace: \"Microsoft.CognitiveServices\"\n});\n"]}
1
+ {"version":3,"file":"tracing.js","sourceRoot":"","sources":["../../src/tracing.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEzD;;;GAGG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,kBAAkB,CAAC;IAC3C,aAAa,EAAE,uCAAuC;IACtD,SAAS,EAAE,6BAA6B;CACzC,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { createSpanFunction } from \"@azure/core-tracing\";\n\n/**\n * Creates a span using the global tracer.\n * @internal\n */\nexport const createSpan = createSpanFunction({\n packagePrefix: \"Azure.CognitiveServices.TextAnalytics\",\n namespace: \"Microsoft.CognitiveServices\",\n});\n"]}
@@ -41,7 +41,7 @@ export function parseAssessmentIndex(pointer) {
41
41
  const assessmentIndex = {
42
42
  document: parseInt(res[1]),
43
43
  sentence: parseInt(res[2]),
44
- assessment: parseInt(res[3])
44
+ assessment: parseInt(res[3]),
45
45
  };
46
46
  return assessmentIndex;
47
47
  }
@@ -125,6 +125,9 @@ function appendReadableErrorMessage(currentMessage, innerMessage) {
125
125
  export function compileError(errorResponse) {
126
126
  var _a;
127
127
  const castErrorResponse = errorResponse;
128
+ if (!castErrorResponse.response) {
129
+ throw errorResponse;
130
+ }
128
131
  const topLevelError = (_a = castErrorResponse.response.parsedBody) === null || _a === void 0 ? void 0 : _a.error;
129
132
  if (!topLevelError)
130
133
  return errorResponse;
@@ -143,7 +146,7 @@ export function compileError(errorResponse) {
143
146
  unwrap(topLevelError);
144
147
  return new RestError(errorMessage, {
145
148
  code: invalidDocumentBatchCode ? "InvalidDocumentBatch" : topLevelError.code,
146
- statusCode: castErrorResponse.statusCode
149
+ statusCode: castErrorResponse.statusCode,
147
150
  });
148
151
  }
149
152
  /**
@@ -167,8 +170,8 @@ export async function getRawResponse(f, options) {
167
170
  rawResponse: {
168
171
  statusCode: rawResponse.status,
169
172
  headers: rawResponse.headers.toJSON(),
170
- body: rawResponse.parsedBody
171
- }
173
+ body: rawResponse.parsedBody,
174
+ },
172
175
  };
173
176
  }
174
177
  /**
@@ -182,13 +185,13 @@ client, spec, spanStr, options, path) {
182
185
  const { flatResponse, rawResponse } = await getRawResponse((paramOptions) => client.sendOperationRequest({ options: paramOptions }, Object.assign(Object.assign({}, spec), { path, httpMethod: "GET" })), finalOptions);
183
186
  return {
184
187
  flatResponse: flatResponse,
185
- rawResponse
188
+ rawResponse,
186
189
  };
187
190
  }
188
191
  catch (e) {
189
192
  span.setStatus({
190
193
  code: SpanStatusCode.ERROR,
191
- message: e.message
194
+ message: e.message,
192
195
  });
193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B,CAAC,CAAC;QAC5C,CAAC,IACD,CAAC;IACH,OAAO;QACL,YAAY;QACZ,WAAW,EAAE;YACX,UAAU,EAAE,WAAY,CAAC,MAAM;YAC/B,OAAO,EAAE,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 { 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"]}
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,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,CA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,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 if (!castErrorResponse.response) {\n throw errorResponse;\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.20211214.2",
6
+ "version": "5.2.0-alpha.20220131.1",
7
7
  "keywords": [
8
8
  "node",
9
9
  "azure",
@@ -59,12 +59,12 @@
59
59
  },
60
60
  "scripts": {
61
61
  "audit": "node ../../../common/scripts/rush-audit.js && rimraf node_modules package-lock.json && npm i --package-lock-only 2>&1 && npm audit",
62
- "build:browser": "tsc -p . && cross-env ONLY_BROWSER=true rollup -c 2>&1",
63
- "build:node": "tsc -p . && cross-env ONLY_NODE=true rollup -c 2>&1",
62
+ "build:browser": "tsc -p . && dev-tool run bundle",
63
+ "build:node": "tsc -p . && dev-tool run bundle",
64
64
  "build:samples": "echo Obsolete.",
65
- "build:test": "tsc -p . && rollup -c 2>&1",
66
- "build": "npm run clean && tsc -p . && rollup -c 2>&1 && api-extractor run --local",
67
- "build:debug": "tsc -p . && rollup -c 2>&1 && api-extractor run --local",
65
+ "build:test": "tsc -p . && dev-tool run bundle",
66
+ "build": "npm run clean && tsc -p . && dev-tool run bundle && api-extractor run --local",
67
+ "build:debug": "tsc -p . && dev-tool run bundle && api-extractor run --local",
68
68
  "check-format": "prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"",
69
69
  "clean": "rimraf dist dist-* temp types *.tgz *.log",
70
70
  "execute:samples": "dev-tool samples run samples-dev",
@@ -86,12 +86,11 @@
86
86
  "sideEffects": false,
87
87
  "autoPublish": false,
88
88
  "dependencies": {
89
- "@azure/core-asynciterator-polyfill": "^1.0.0",
90
89
  "@azure/core-auth": "^1.3.0",
91
90
  "@azure/core-client": "^1.0.0",
92
91
  "@azure/core-rest-pipeline": "^1.1.0",
93
92
  "@azure/core-lro": "^2.2.0",
94
- "@azure/core-paging": ">=1.2.0-alpha <1.2.0-alphb",
93
+ "@azure/core-paging": "^1.2.0",
95
94
  "@azure/core-tracing": "1.0.0-preview.13",
96
95
  "@azure/logger": "^1.0.0",
97
96
  "tslib": "^2.2.0"
@@ -130,9 +129,8 @@
130
129
  "mocha": "^7.1.1",
131
130
  "mocha-junit-reporter": "^2.0.0",
132
131
  "nyc": "^15.0.0",
133
- "prettier": "^1.16.4",
132
+ "prettier": "^2.5.1",
134
133
  "rimraf": "^3.0.0",
135
- "rollup": "^1.16.3",
136
134
  "sinon": "^9.0.2",
137
135
  "source-map-support": "^0.5.9",
138
136
  "ts-node": "^10.0.0",