[Text Analytics] Allow multiple actions of the same type (#18382)

* [Text Analytics] Allow multiple actions of the same type

* address feedback

* remove onlys
This commit is contained in:
Deyaaeldeen Almahallawi 2021-10-27 22:20:57 -04:00 коммит произвёл GitHub
Родитель 8fcdbfec40
Коммит bd0bca6837
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
17 изменённых файлов: 701 добавлений и 83 удалений

Просмотреть файл

@ -13,6 +13,16 @@
### Other Changes
- `beginAnalyzeActions` supports multiple actions of the same type so you can pass a list of any particular action type, e.g.
```typescript
await client.beginAnalyzeActions(docs, { recognizePiiEntitiesActions: [
{ modelVersion: "latest", actionName: "action1" },
{ modelVersion: "2021-01-15", actionName: "action2" }]
});
```
## 5.2.0-beta.1 (2021-08-09)
### Features Added

Просмотреть файл

@ -0,0 +1,49 @@
{
"recordings": [
{
"method": "POST",
"url": "https://login.microsoftonline.com/88888888-8888-8888-8888-888888888888/oauth2/v2.0/token",
"query": {},
"requestBody": "response_type=token&grant_type=client_credentials&client_id=azure_client_id&client_secret=azure_client_secret&scope=https%3A%2F%2Fsanitized%2F",
"status": 200,
"response": "{\"token_type\":\"Bearer\",\"expires_in\":86399,\"ext_expires_in\":86399,\"access_token\":\"access_token\"}",
"responseHeaders": {
"cache-control": "no-store, no-cache",
"content-length": "1331",
"content-type": "application/json; charset=utf-8",
"date": "Thu, 28 Oct 2021 02:06:37 GMT",
"expires": "-1",
"nel": "{\"report_to\":\"network-errors\",\"max_age\":86400,\"success_fraction\":0.001,\"failure_fraction\":1.0}",
"p3p": "CP=\"DSP CUR OTPi IND OTRi ONL FIN\"",
"pragma": "no-cache",
"referrer-policy": "strict-origin-when-cross-origin",
"report-to": "{\"group\":\"network-errors\",\"max_age\":86400,\"endpoints\":[{\"url\":\"https://identity.nel.measure.office.net/api/report?catId=GW+estsfd+est\"}]}",
"strict-transport-security": "max-age=31536000; includeSubDomains",
"x-content-type-options": "nosniff",
"x-ms-ests-server": "2.1.12171.14 - WUS2 ProdSlices",
"x-ms-request-id": "c0f3fa49-0c82-448c-b6c6-8c1f8d4bad00"
}
},
{
"method": "POST",
"url": "https://endpoint/text/analytics/v3.2-preview.2/analyze",
"query": {},
"requestBody": "{\"analysisInput\":{\"documents\":[{\"id\":\"1\",\"text\":\"I will go to the park.\"}]},\"tasks\":{\"entityRecognitionPiiTasks\":[{\"parameters\":{\"model-version\":\"latest\",\"stringIndexType\":\"Utf16CodeUnit\"}},{\"parameters\":{\"model-version\":\"latest\",\"stringIndexType\":\"Utf16CodeUnit\"}}]}}",
"status": 400,
"response": "{\"error\":{\"code\":\"InvalidRequest\",\"message\":\"InvalidTask in AnalyzeInput\",\"innererror\":{\"code\":\"InvalidRequestBodyFormat\",\"message\":\"Duplicate task name for task type PersonallyIdentifiableInformation. Make sure each task under a task type has a unique name\"}}}",
"responseHeaders": {
"apim-request-id": "18fc4c1b-49f4-4dff-81e3-470df2fd2056",
"content-type": "application/json; charset=utf-8",
"date": "Thu, 28 Oct 2021 02:06:36 GMT",
"strict-transport-security": "max-age=31536000; includeSubDomains; preload",
"x-content-type-options": "nosniff",
"x-envoy-upstream-service-time": "4"
}
}
],
"uniqueTestInfo": {
"uniqueName": {},
"newDate": {}
},
"hash": "b622bb90bc1506f299109d6581856a55"
}

Просмотреть файл

@ -0,0 +1,68 @@
{
"recordings": [
{
"method": "POST",
"url": "https://login.microsoftonline.com/88888888-8888-8888-8888-888888888888/oauth2/v2.0/token",
"query": {},
"requestBody": "response_type=token&grant_type=client_credentials&client_id=azure_client_id&client_secret=azure_client_secret&scope=https%3A%2F%2Fsanitized%2F",
"status": 200,
"response": "{\"token_type\":\"Bearer\",\"expires_in\":86399,\"ext_expires_in\":86399,\"access_token\":\"access_token\"}",
"responseHeaders": {
"cache-control": "no-store, no-cache",
"content-length": "1331",
"content-type": "application/json; charset=utf-8",
"date": "Wed, 27 Oct 2021 23:28:15 GMT",
"expires": "-1",
"nel": "{\"report_to\":\"network-errors\",\"max_age\":86400,\"success_fraction\":0.001,\"failure_fraction\":1.0}",
"p3p": "CP=\"DSP CUR OTPi IND OTRi ONL FIN\"",
"pragma": "no-cache",
"referrer-policy": "strict-origin-when-cross-origin",
"report-to": "{\"group\":\"network-errors\",\"max_age\":86400,\"endpoints\":[{\"url\":\"https://identity.nel.measure.office.net/api/report?catId=GW+estsfd+est\"}]}",
"strict-transport-security": "max-age=31536000; includeSubDomains",
"x-content-type-options": "nosniff",
"x-ms-ests-server": "2.1.12171.14 - EUS ProdSlices",
"x-ms-request-id": "dbfd1a6e-a5c3-4fe3-bc9b-2a0f454deb00"
}
},
{
"method": "POST",
"url": "https://endpoint/text/analytics/v3.2-preview.2/analyze",
"query": {},
"requestBody": "{\"analysisInput\":{\"documents\":[{\"id\":\"1\",\"text\":\"I will go to the park.\"}]},\"tasks\":{\"entityRecognitionPiiTasks\":[{\"parameters\":{\"model-version\":\"latest\",\"stringIndexType\":\"Utf16CodeUnit\"},\"taskName\":\"action1\"},{\"parameters\":{\"model-version\":\"latest\",\"stringIndexType\":\"Utf16CodeUnit\"},\"taskName\":\"action2\"}]}}",
"status": 202,
"response": "",
"responseHeaders": {
"apim-request-id": "3f03e6c5-1184-4205-8ae8-cd697d836b9c",
"date": "Wed, 27 Oct 2021 23:28:16 GMT",
"operation-location": "https://endpoint/text/analytics/v3.2-preview.2/analyze/jobs/178d99d2-488d-461f-8ca3-3838069a017a",
"strict-transport-security": "max-age=31536000; includeSubDomains; preload",
"x-content-type-options": "nosniff",
"x-envoy-upstream-service-time": "194"
}
},
{
"method": "GET",
"url": "https://endpoint/text/analytics/v3.2-preview.2/analyze/jobs/178d99d2-488d-461f-8ca3-3838069a017a",
"query": {
"$top": "20",
"$skip": "0"
},
"requestBody": null,
"status": 200,
"response": "{\"jobId\":\"178d99d2-488d-461f-8ca3-3838069a017a\",\"lastUpdateDateTime\":\"2021-10-27T23:28:16Z\",\"createdDateTime\":\"2021-10-27T23:28:16Z\",\"expirationDateTime\":\"2021-10-28T23:28:16Z\",\"status\":\"running\",\"errors\":[],\"tasks\":{\"completed\":0,\"failed\":0,\"inProgress\":2,\"total\":2}}",
"responseHeaders": {
"apim-request-id": "dc4f39eb-5f52-45dd-9fd8-64ec6f798654",
"content-type": "application/json; charset=utf-8",
"date": "Wed, 27 Oct 2021 23:28:16 GMT",
"strict-transport-security": "max-age=31536000; includeSubDomains; preload",
"x-content-type-options": "nosniff",
"x-envoy-upstream-service-time": "7"
}
}
],
"uniqueTestInfo": {
"uniqueName": {},
"newDate": {}
},
"hash": "6bad4f4da1994b915fcafc6adde1f18e"
}

Просмотреть файл

@ -0,0 +1,25 @@
{
"recordings": [
{
"method": "POST",
"url": "https://endpoint/text/analytics/v3.2-preview.2/analyze",
"query": {},
"requestBody": "{\"analysisInput\":{\"documents\":[{\"id\":\"1\",\"text\":\"I will go to the park.\"}]},\"tasks\":{\"entityRecognitionPiiTasks\":[{\"parameters\":{\"model-version\":\"latest\",\"stringIndexType\":\"Utf16CodeUnit\"}},{\"parameters\":{\"model-version\":\"latest\",\"stringIndexType\":\"Utf16CodeUnit\"}}]}}",
"status": 400,
"response": "{\"error\":{\"code\":\"InvalidRequest\",\"message\":\"InvalidTask in AnalyzeInput\",\"innererror\":{\"code\":\"InvalidRequestBodyFormat\",\"message\":\"Duplicate task name for task type PersonallyIdentifiableInformation. Make sure each task under a task type has a unique name\"}}}",
"responseHeaders": {
"apim-request-id": "745c4a58-ca4a-443a-bacc-e1d5c0cc7463",
"content-type": "application/json; charset=utf-8",
"date": "Thu, 28 Oct 2021 02:06:36 GMT",
"strict-transport-security": "max-age=31536000; includeSubDomains; preload",
"x-content-type-options": "nosniff",
"x-envoy-upstream-service-time": "7"
}
}
],
"uniqueTestInfo": {
"uniqueName": {},
"newDate": {}
},
"hash": "b622bb90bc1506f299109d6581856a55"
}

Просмотреть файл

@ -0,0 +1,44 @@
{
"recordings": [
{
"method": "POST",
"url": "https://endpoint/text/analytics/v3.2-preview.2/analyze",
"query": {},
"requestBody": "{\"analysisInput\":{\"documents\":[{\"id\":\"1\",\"text\":\"I will go to the park.\"}]},\"tasks\":{\"entityRecognitionPiiTasks\":[{\"parameters\":{\"model-version\":\"latest\",\"stringIndexType\":\"Utf16CodeUnit\"},\"taskName\":\"action1\"},{\"parameters\":{\"model-version\":\"latest\",\"stringIndexType\":\"Utf16CodeUnit\"},\"taskName\":\"action2\"}]}}",
"status": 202,
"response": "",
"responseHeaders": {
"apim-request-id": "b7b61454-ef18-48c3-bc22-877bc22b2228",
"date": "Wed, 27 Oct 2021 23:28:15 GMT",
"operation-location": "https://endpoint/text/analytics/v3.2-preview.2/analyze/jobs/e3fe9900-61bc-4291-86d1-6c039aa2919a",
"strict-transport-security": "max-age=31536000; includeSubDomains; preload",
"x-content-type-options": "nosniff",
"x-envoy-upstream-service-time": "408"
}
},
{
"method": "GET",
"url": "https://endpoint/text/analytics/v3.2-preview.2/analyze/jobs/e3fe9900-61bc-4291-86d1-6c039aa2919a",
"query": {
"$top": "20",
"$skip": "0"
},
"requestBody": null,
"status": 200,
"response": "{\"jobId\":\"e3fe9900-61bc-4291-86d1-6c039aa2919a\",\"lastUpdateDateTime\":\"2021-10-27T23:28:15Z\",\"createdDateTime\":\"2021-10-27T23:28:15Z\",\"expirationDateTime\":\"2021-10-28T23:28:15Z\",\"status\":\"running\",\"errors\":[],\"tasks\":{\"completed\":0,\"failed\":0,\"inProgress\":2,\"total\":2}}",
"responseHeaders": {
"apim-request-id": "b7f62acc-a900-4fdc-89dd-74a31076e514",
"content-type": "application/json; charset=utf-8",
"date": "Wed, 27 Oct 2021 23:28:15 GMT",
"strict-transport-security": "max-age=31536000; includeSubDomains; preload",
"x-content-type-options": "nosniff",
"x-envoy-upstream-service-time": "7"
}
}
],
"uniqueTestInfo": {
"uniqueName": {},
"newDate": {}
},
"hash": "6bad4f4da1994b915fcafc6adde1f18e"
}

Просмотреть файл

@ -0,0 +1,130 @@
let nock = require('nock');
module.exports.hash = "24c8a2a5a8e45f8e91b3a40ae590296d";
module.exports.testInfo = {"uniqueName":{},"newDate":{}}
nock('https://login.microsoftonline.com:443', {"encodedQueryParams":true})
.get('/common/discovery/instance')
.query(true)
.reply(200, {"tenant_discovery_endpoint":"https://login.microsoftonline.com/88888888-8888-8888-8888-888888888888/v2.0/.well-known/openid-configuration","api-version":"1.1","metadata":[{"preferred_network":"login.microsoftonline.com","preferred_cache":"login.windows.net","aliases":["login.microsoftonline.com","login.windows.net","login.microsoft.com","sts.windows.net"]},{"preferred_network":"login.partner.microsoftonline.cn","preferred_cache":"login.partner.microsoftonline.cn","aliases":["login.partner.microsoftonline.cn","login.chinacloudapi.cn"]},{"preferred_network":"login.microsoftonline.de","preferred_cache":"login.microsoftonline.de","aliases":["login.microsoftonline.de"]},{"preferred_network":"login.microsoftonline.us","preferred_cache":"login.microsoftonline.us","aliases":["login.microsoftonline.us","login.usgovcloudapi.net"]},{"preferred_network":"login-us.microsoftonline.com","preferred_cache":"login-us.microsoftonline.com","aliases":["login-us.microsoftonline.com"]}]}, [
'Cache-Control',
'max-age=86400, private',
'Content-Type',
'application/json; charset=utf-8',
'Strict-Transport-Security',
'max-age=31536000; includeSubDomains',
'X-Content-Type-Options',
'nosniff',
'Access-Control-Allow-Origin',
'*',
'Access-Control-Allow-Methods',
'GET, OPTIONS',
'P3P',
'CP="DSP CUR OTPi IND OTRi ONL FIN"',
'x-ms-request-id',
'228d2d39-427c-4fd6-99ce-9e8f0fea5a00',
'x-ms-ests-server',
'2.1.12158.6 - EUS ProdSlices',
'Set-Cookie',
'fpc=AhBa8vkkhidGkicFZbgKW7w; expires=Sat, 27-Nov-2021 02:06:31 GMT; path=/; secure; HttpOnly; SameSite=None',
'Set-Cookie',
'esctx=AQABAAAAAAD--DLA3VO7QrddgJg7WevrNSM-CDAzeeuNPBVaFJFif9KbprDthZiR5c5rQRPuJrkX4KMI6zwPHV_Wmu4RgtRZa33qzisVXdzFlaqkY8RVsOCata6g2TifgaF8SA2HsOPVCeOSVAsVV_eybMoB_i2Dp_pdmAU2LSI4E6MwNTpfaJVA9em_ph9RPLOWODGCbWUgAA; domain=.login.microsoftonline.com; path=/; secure; HttpOnly; SameSite=None',
'Set-Cookie',
'x-ms-gateway-slice=estsfd; path=/; secure; samesite=none; httponly',
'Set-Cookie',
'stsservicecookie=estsfd; path=/; secure; samesite=none; httponly',
'Date',
'Thu, 28 Oct 2021 02:06:30 GMT',
'Content-Length',
'980'
]);
nock('https://login.microsoftonline.com:443', {"encodedQueryParams":true})
.get('/88888888-8888-8888-8888-888888888888/v2.0/.well-known/openid-configuration')
.reply(200, {"token_endpoint":"https://login.microsoftonline.com/88888888-8888-8888-8888-888888888888/oauth2/v2.0/token","token_endpoint_auth_methods_supported":["client_secret_post","private_key_jwt","client_secret_basic"],"jwks_uri":"https://login.microsoftonline.com/88888888-8888-8888-8888-888888888888/discovery/v2.0/keys","response_modes_supported":["query","fragment","form_post"],"subject_types_supported":["pairwise"],"id_token_signing_alg_values_supported":["RS256"],"response_types_supported":["code","id_token","code id_token","id_token token"],"scopes_supported":["openid","profile","email","offline_access"],"issuer":"https://login.microsoftonline.com/88888888-8888-8888-8888-888888888888/v2.0","request_uri_parameter_supported":false,"userinfo_endpoint":"https://graph.microsoft.com/oidc/userinfo","authorization_endpoint":"https://login.microsoftonline.com/88888888-8888-8888-8888-888888888888/oauth2/v2.0/authorize","device_authorization_endpoint":"https://login.microsoftonline.com/88888888-8888-8888-8888-888888888888/oauth2/v2.0/devicecode","http_logout_supported":true,"frontchannel_logout_supported":true,"end_session_endpoint":"https://login.microsoftonline.com/88888888-8888-8888-8888-888888888888/oauth2/v2.0/logout","claims_supported":["sub","iss","cloud_instance_name","cloud_instance_host_name","cloud_graph_host_name","msgraph_host","aud","exp","iat","auth_time","acr","nonce","preferred_username","name","tid","ver","at_hash","c_hash","email"],"kerberos_endpoint":"https://login.microsoftonline.com/88888888-8888-8888-8888-888888888888/kerberos","tenant_region_scope":"WW","cloud_instance_name":"microsoftonline.com","cloud_graph_host_name":"graph.windows.net","msgraph_host":"graph.microsoft.com","rbac_url":"https://pas.windows.net"}, [
'Cache-Control',
'max-age=86400, private',
'Content-Type',
'application/json; charset=utf-8',
'Strict-Transport-Security',
'max-age=31536000; includeSubDomains',
'X-Content-Type-Options',
'nosniff',
'Access-Control-Allow-Origin',
'*',
'Access-Control-Allow-Methods',
'GET, OPTIONS',
'P3P',
'CP="DSP CUR OTPi IND OTRi ONL FIN"',
'x-ms-request-id',
'c9037c69-39c1-4e16-a0d3-40866a6dbe00',
'x-ms-ests-server',
'2.1.12171.14 - WUS2 ProdSlices',
'Set-Cookie',
'fpc=AhpMMOkbpDNGrwkvgsKLvDA; expires=Sat, 27-Nov-2021 02:06:31 GMT; path=/; secure; HttpOnly; SameSite=None',
'Set-Cookie',
'esctx=AQABAAAAAAD--DLA3VO7QrddgJg7Wevr9TpAqfUvgZPpohoryGMB78rU95ZHWwYbT3Mu9qmJKiBbOx1wO2NLhWJgxO2HlW6HTVWCXJzsRV7vdK8Cdtrbstcus5LmzRMAATTc4iRoeHwAwtQC-m6dBjA1amAMI1P7LZ_qB2zzFxiUKL_ntzBMtKzCZ-2BITdpkGwoOypd9wIgAA; domain=.login.microsoftonline.com; path=/; secure; HttpOnly; SameSite=None',
'Set-Cookie',
'x-ms-gateway-slice=estsfd; path=/; secure; samesite=none; httponly',
'Set-Cookie',
'stsservicecookie=estsfd; path=/; secure; samesite=none; httponly',
'Date',
'Thu, 28 Oct 2021 02:06:31 GMT',
'Content-Length',
'1753'
]);
nock('https://login.microsoftonline.com:443', {"encodedQueryParams":true})
.post('/88888888-8888-8888-8888-888888888888/oauth2/v2.0/token', "client_id=azure_client_id&scope=https%3A%2F%2Fsanitized%2F&grant_type=client_credentials&x-client-SKU=msal.js.node&x-client-VER=1.3.2&x-client-OS=linux&x-client-CPU=x64&x-ms-lib-capability=retry-after, h429&x-client-current-telemetry=5|771,2,,,|,&x-client-last-telemetry=5|0|||0,0&client-request-id=05ea1a3b-3148-4d3b-8027-13b02b412393&client_secret=azure_client_secret&claims=%7B%22access_token%22%3A%7B%22xms_cc%22%3A%7B%22values%22%3A%5B%22CP1%22%5D%7D%7D%7D")
.reply(200, {"token_type":"Bearer","expires_in":86399,"ext_expires_in":86399,"access_token":"access_token"}, [
'Cache-Control',
'no-store, no-cache',
'Pragma',
'no-cache',
'Content-Type',
'application/json; charset=utf-8',
'Expires',
'-1',
'Strict-Transport-Security',
'max-age=31536000; includeSubDomains',
'X-Content-Type-Options',
'nosniff',
'P3P',
'CP="DSP CUR OTPi IND OTRi ONL FIN"',
'x-ms-request-id',
'c9037c69-39c1-4e16-a0d3-4086726dbe00',
'x-ms-ests-server',
'2.1.12171.14 - WUS2 ProdSlices',
'x-ms-clitelem',
'1,0,0,,',
'Set-Cookie',
'fpc=AqDtKzvu_CZFhLGm9XAxeplz_bg1AQAAAKb8C9kOAAAA; expires=Sat, 27-Nov-2021 02:06:31 GMT; path=/; secure; HttpOnly; SameSite=None',
'Set-Cookie',
'x-ms-gateway-slice=estsfd; path=/; secure; samesite=none; httponly',
'Set-Cookie',
'stsservicecookie=estsfd; path=/; secure; samesite=none; httponly',
'Date',
'Thu, 28 Oct 2021 02:06:31 GMT',
'Content-Length',
'1331'
]);
nock('https://endpoint', {"encodedQueryParams":true})
.post('/text/analytics/v3.2-preview.2/analyze', {"analysisInput":{"documents":[{"id":"1","text":"I will go to the park."}]},"tasks":{"entityRecognitionPiiTasks":[{"parameters":{"model-version":"latest","stringIndexType":"Utf16CodeUnit"}},{"parameters":{"model-version":"latest","stringIndexType":"Utf16CodeUnit"}}]}})
.reply(400, {"error":{"code":"InvalidRequest","message":"InvalidTask in AnalyzeInput","innererror":{"code":"InvalidRequestBodyFormat","message":"Duplicate task name for task type PersonallyIdentifiableInformation. Make sure each task under a task type has a unique name"}}}, [
'Transfer-Encoding',
'chunked',
'Content-Type',
'application/json; charset=utf-8',
'x-envoy-upstream-service-time',
'6',
'apim-request-id',
'd8587d67-d911-4803-bf6c-65fe8dcdbd1a',
'Strict-Transport-Security',
'max-age=31536000; includeSubDomains; preload',
'x-content-type-options',
'nosniff',
'Date',
'Thu, 28 Oct 2021 02:06:31 GMT'
]);

Просмотреть файл

@ -0,0 +1,150 @@
let nock = require('nock');
module.exports.hash = "86edab6950b9f06ea6a638ea3c018c6c";
module.exports.testInfo = {"uniqueName":{},"newDate":{}}
nock('https://login.microsoftonline.com:443', {"encodedQueryParams":true})
.get('/common/discovery/instance')
.query(true)
.reply(200, {"tenant_discovery_endpoint":"https://login.microsoftonline.com/88888888-8888-8888-8888-888888888888/v2.0/.well-known/openid-configuration","api-version":"1.1","metadata":[{"preferred_network":"login.microsoftonline.com","preferred_cache":"login.windows.net","aliases":["login.microsoftonline.com","login.windows.net","login.microsoft.com","sts.windows.net"]},{"preferred_network":"login.partner.microsoftonline.cn","preferred_cache":"login.partner.microsoftonline.cn","aliases":["login.partner.microsoftonline.cn","login.chinacloudapi.cn"]},{"preferred_network":"login.microsoftonline.de","preferred_cache":"login.microsoftonline.de","aliases":["login.microsoftonline.de"]},{"preferred_network":"login.microsoftonline.us","preferred_cache":"login.microsoftonline.us","aliases":["login.microsoftonline.us","login.usgovcloudapi.net"]},{"preferred_network":"login-us.microsoftonline.com","preferred_cache":"login-us.microsoftonline.com","aliases":["login-us.microsoftonline.com"]}]}, [
'Cache-Control',
'max-age=86400, private',
'Content-Type',
'application/json; charset=utf-8',
'Strict-Transport-Security',
'max-age=31536000; includeSubDomains',
'X-Content-Type-Options',
'nosniff',
'Access-Control-Allow-Origin',
'*',
'Access-Control-Allow-Methods',
'GET, OPTIONS',
'P3P',
'CP="DSP CUR OTPi IND OTRi ONL FIN"',
'x-ms-request-id',
'8a93ae76-0c98-4f73-837e-867fb9141300',
'x-ms-ests-server',
'2.1.12171.14 - WUS2 ProdSlices',
'Set-Cookie',
'fpc=AprhMWLRc11AsNXdyvN5Kak; expires=Fri, 26-Nov-2021 23:28:01 GMT; path=/; secure; HttpOnly; SameSite=None',
'Set-Cookie',
'esctx=AQABAAAAAAD--DLA3VO7QrddgJg7WevrzOH2YlXbSCPoSJbp6hc-5Xmm_25qadQhYOgYzfuYSNpO7tuGLayQl3T0_jHycd04k4bMpWitBOcec6ZyoSHOBxzm52Uhzow70wkL_zpTj1I3XUf3zNBMrQTV8x43M5V67uG207fON9YigIUjB7uqC5YFh6cXI2N1jS5LqQbD7CogAA; domain=.login.microsoftonline.com; path=/; secure; HttpOnly; SameSite=None',
'Set-Cookie',
'x-ms-gateway-slice=estsfd; path=/; secure; samesite=none; httponly',
'Set-Cookie',
'stsservicecookie=estsfd; path=/; secure; samesite=none; httponly',
'Date',
'Wed, 27 Oct 2021 23:28:01 GMT',
'Content-Length',
'980'
]);
nock('https://login.microsoftonline.com:443', {"encodedQueryParams":true})
.get('/88888888-8888-8888-8888-888888888888/v2.0/.well-known/openid-configuration')
.reply(200, {"token_endpoint":"https://login.microsoftonline.com/88888888-8888-8888-8888-888888888888/oauth2/v2.0/token","token_endpoint_auth_methods_supported":["client_secret_post","private_key_jwt","client_secret_basic"],"jwks_uri":"https://login.microsoftonline.com/88888888-8888-8888-8888-888888888888/discovery/v2.0/keys","response_modes_supported":["query","fragment","form_post"],"subject_types_supported":["pairwise"],"id_token_signing_alg_values_supported":["RS256"],"response_types_supported":["code","id_token","code id_token","id_token token"],"scopes_supported":["openid","profile","email","offline_access"],"issuer":"https://login.microsoftonline.com/88888888-8888-8888-8888-888888888888/v2.0","request_uri_parameter_supported":false,"userinfo_endpoint":"https://graph.microsoft.com/oidc/userinfo","authorization_endpoint":"https://login.microsoftonline.com/88888888-8888-8888-8888-888888888888/oauth2/v2.0/authorize","device_authorization_endpoint":"https://login.microsoftonline.com/88888888-8888-8888-8888-888888888888/oauth2/v2.0/devicecode","http_logout_supported":true,"frontchannel_logout_supported":true,"end_session_endpoint":"https://login.microsoftonline.com/88888888-8888-8888-8888-888888888888/oauth2/v2.0/logout","claims_supported":["sub","iss","cloud_instance_name","cloud_instance_host_name","cloud_graph_host_name","msgraph_host","aud","exp","iat","auth_time","acr","nonce","preferred_username","name","tid","ver","at_hash","c_hash","email"],"kerberos_endpoint":"https://login.microsoftonline.com/88888888-8888-8888-8888-888888888888/kerberos","tenant_region_scope":"WW","cloud_instance_name":"microsoftonline.com","cloud_graph_host_name":"graph.windows.net","msgraph_host":"graph.microsoft.com","rbac_url":"https://pas.windows.net"}, [
'Cache-Control',
'max-age=86400, private',
'Content-Type',
'application/json; charset=utf-8',
'Strict-Transport-Security',
'max-age=31536000; includeSubDomains',
'X-Content-Type-Options',
'nosniff',
'Access-Control-Allow-Origin',
'*',
'Access-Control-Allow-Methods',
'GET, OPTIONS',
'P3P',
'CP="DSP CUR OTPi IND OTRi ONL FIN"',
'x-ms-request-id',
'0360338e-ebd1-4285-861f-7a71a089c600',
'x-ms-ests-server',
'2.1.12171.14 - WUS2 ProdSlices',
'Set-Cookie',
'fpc=AvmxiLHp6mdEqvJIQmKYn6c; expires=Fri, 26-Nov-2021 23:28:02 GMT; path=/; secure; HttpOnly; SameSite=None',
'Set-Cookie',
'esctx=AQABAAAAAAD--DLA3VO7QrddgJg7Wevr7Z1q1YBFhI48Ha7OQb3fB1hOnRADHo8G4ZT7j7PA1UfqWG8cpiERasUnkIeUa-qh6bG8iLZoG-emni8IhDvg8qieJDiSTiAjR21DPwTSlR0VD89X7jZSp6niw3dWBb8IR1f6JgehS5cJdLiQe_amxjfGTcEKrHUyMwdWqz2gP7IgAA; domain=.login.microsoftonline.com; path=/; secure; HttpOnly; SameSite=None',
'Set-Cookie',
'x-ms-gateway-slice=estsfd; path=/; secure; samesite=none; httponly',
'Set-Cookie',
'stsservicecookie=estsfd; path=/; secure; samesite=none; httponly',
'Date',
'Wed, 27 Oct 2021 23:28:01 GMT',
'Content-Length',
'1753'
]);
nock('https://login.microsoftonline.com:443', {"encodedQueryParams":true})
.post('/88888888-8888-8888-8888-888888888888/oauth2/v2.0/token', "client_id=azure_client_id&scope=https%3A%2F%2Fsanitized%2F&grant_type=client_credentials&x-client-SKU=msal.js.node&x-client-VER=1.3.2&x-client-OS=linux&x-client-CPU=x64&x-ms-lib-capability=retry-after, h429&x-client-current-telemetry=5|771,2,,,|,&x-client-last-telemetry=5|0|||0,0&client-request-id=e25e05c2-223b-4d1e-902d-a12a5446916f&client_secret=azure_client_secret&claims=%7B%22access_token%22%3A%7B%22xms_cc%22%3A%7B%22values%22%3A%5B%22CP1%22%5D%7D%7D%7D")
.reply(200, {"token_type":"Bearer","expires_in":86399,"ext_expires_in":86399,"access_token":"access_token"}, [
'Cache-Control',
'no-store, no-cache',
'Pragma',
'no-cache',
'Content-Type',
'application/json; charset=utf-8',
'Expires',
'-1',
'Strict-Transport-Security',
'max-age=31536000; includeSubDomains',
'X-Content-Type-Options',
'nosniff',
'P3P',
'CP="DSP CUR OTPi IND OTRi ONL FIN"',
'x-ms-request-id',
'1a5fbdea-5bea-478e-ad5e-32e71b29c700',
'x-ms-ests-server',
'2.1.12171.14 - WUS2 ProdSlices',
'x-ms-clitelem',
'1,0,0,,',
'Set-Cookie',
'fpc=AiZerX-sM6BGv5Rm2515lJdz_bg1AQAAAILXC9kOAAAA; expires=Fri, 26-Nov-2021 23:28:02 GMT; path=/; secure; HttpOnly; SameSite=None',
'Set-Cookie',
'x-ms-gateway-slice=estsfd; path=/; secure; samesite=none; httponly',
'Set-Cookie',
'stsservicecookie=estsfd; path=/; secure; samesite=none; httponly',
'Date',
'Wed, 27 Oct 2021 23:28:01 GMT',
'Content-Length',
'1331'
]);
nock('https://endpoint', {"encodedQueryParams":true})
.post('/text/analytics/v3.2-preview.2/analyze', {"analysisInput":{"documents":[{"id":"1","text":"I will go to the park."}]},"tasks":{"entityRecognitionPiiTasks":[{"parameters":{"model-version":"latest","stringIndexType":"Utf16CodeUnit"},"taskName":"action1"},{"parameters":{"model-version":"latest","stringIndexType":"Utf16CodeUnit"},"taskName":"action2"}]}})
.reply(202, "", [
'Transfer-Encoding',
'chunked',
'operation-location',
'https://endpoint/text/analytics/v3.2-preview.2/analyze/jobs/112f94b5-516d-4703-b23c-f326427e01b1',
'x-envoy-upstream-service-time',
'185',
'apim-request-id',
'97b5744a-3b61-41a0-8b67-a27822a24387',
'Strict-Transport-Security',
'max-age=31536000; includeSubDomains; preload',
'x-content-type-options',
'nosniff',
'Date',
'Wed, 27 Oct 2021 23:28:02 GMT'
]);
nock('https://endpoint', {"encodedQueryParams":true})
.get('/text/analytics/v3.2-preview.2/analyze/jobs/112f94b5-516d-4703-b23c-f326427e01b1')
.query(true)
.reply(200, {"jobId":"112f94b5-516d-4703-b23c-f326427e01b1","lastUpdateDateTime":"2021-10-27T23:28:02Z","createdDateTime":"2021-10-27T23:28:02Z","expirationDateTime":"2021-10-28T23:28:02Z","status":"notStarted","errors":[],"tasks":{"completed":0,"failed":0,"inProgress":2,"total":2}}, [
'Transfer-Encoding',
'chunked',
'Content-Type',
'application/json; charset=utf-8',
'x-envoy-upstream-service-time',
'7',
'apim-request-id',
'fe4737c3-395b-40ca-9ed9-a37a1323f0dd',
'Strict-Transport-Security',
'max-age=31536000; includeSubDomains; preload',
'x-content-type-options',
'nosniff',
'Date',
'Wed, 27 Oct 2021 23:28:02 GMT'
]);

Просмотреть файл

@ -0,0 +1,24 @@
let nock = require('nock');
module.exports.hash = "24c8a2a5a8e45f8e91b3a40ae590296d";
module.exports.testInfo = {"uniqueName":{},"newDate":{}}
nock('https://endpoint', {"encodedQueryParams":true})
.post('/text/analytics/v3.2-preview.2/analyze', {"analysisInput":{"documents":[{"id":"1","text":"I will go to the park."}]},"tasks":{"entityRecognitionPiiTasks":[{"parameters":{"model-version":"latest","stringIndexType":"Utf16CodeUnit"}},{"parameters":{"model-version":"latest","stringIndexType":"Utf16CodeUnit"}}]}})
.reply(400, {"error":{"code":"InvalidRequest","message":"InvalidTask in AnalyzeInput","innererror":{"code":"InvalidRequestBodyFormat","message":"Duplicate task name for task type PersonallyIdentifiableInformation. Make sure each task under a task type has a unique name"}}}, [
'Transfer-Encoding',
'chunked',
'Content-Type',
'application/json; charset=utf-8',
'x-envoy-upstream-service-time',
'5',
'apim-request-id',
'f891be93-93ed-472f-a1ae-c3182e5d1c3e',
'Strict-Transport-Security',
'max-age=31536000; includeSubDomains; preload',
'x-content-type-options',
'nosniff',
'Date',
'Thu, 28 Oct 2021 02:06:30 GMT'
]);

Просмотреть файл

@ -0,0 +1,44 @@
let nock = require('nock');
module.exports.hash = "86edab6950b9f06ea6a638ea3c018c6c";
module.exports.testInfo = {"uniqueName":{},"newDate":{}}
nock('https://endpoint', {"encodedQueryParams":true})
.post('/text/analytics/v3.2-preview.2/analyze', {"analysisInput":{"documents":[{"id":"1","text":"I will go to the park."}]},"tasks":{"entityRecognitionPiiTasks":[{"parameters":{"model-version":"latest","stringIndexType":"Utf16CodeUnit"},"taskName":"action1"},{"parameters":{"model-version":"latest","stringIndexType":"Utf16CodeUnit"},"taskName":"action2"}]}})
.reply(202, "", [
'Transfer-Encoding',
'chunked',
'operation-location',
'https://endpoint/text/analytics/v3.2-preview.2/analyze/jobs/14bbe87d-1434-42ef-8d10-413a4254da04',
'x-envoy-upstream-service-time',
'285',
'apim-request-id',
'c6df8ecf-9880-470e-943b-746838aaef22',
'Strict-Transport-Security',
'max-age=31536000; includeSubDomains; preload',
'x-content-type-options',
'nosniff',
'Date',
'Wed, 27 Oct 2021 23:28:00 GMT'
]);
nock('https://endpoint', {"encodedQueryParams":true})
.get('/text/analytics/v3.2-preview.2/analyze/jobs/14bbe87d-1434-42ef-8d10-413a4254da04')
.query(true)
.reply(200, {"jobId":"14bbe87d-1434-42ef-8d10-413a4254da04","lastUpdateDateTime":"2021-10-27T23:28:00Z","createdDateTime":"2021-10-27T23:28:00Z","expirationDateTime":"2021-10-28T23:28:00Z","status":"notStarted","errors":[],"tasks":{"completed":0,"failed":0,"inProgress":2,"total":2}}, [
'Transfer-Encoding',
'chunked',
'Content-Type',
'application/json; charset=utf-8',
'x-envoy-upstream-service-time',
'11',
'apim-request-id',
'57635805-ec22-4c9f-af50-aa95175f7238',
'Strict-Transport-Security',
'max-age=31536000; includeSubDomains; preload',
'x-content-type-options',
'nosniff',
'Date',
'Wed, 27 Oct 2021 23:28:00 GMT'
]);

Просмотреть файл

@ -12,7 +12,7 @@ import {
TextDocumentInput
} from "./generated";
import { createSpan } from "./tracing";
import { getRawResponse, handleInvalidDocumentBatch, sendGetRequest } from "./util";
import { compileError, getRawResponse, sendGetRequest } from "./util";
import * as Mappers from "./generated/models/mappers";
import {
accept,
@ -150,7 +150,7 @@ export class AnalyzeLro implements LongRunningOperation<PagedAnalyzeActionsResul
rawResponse
};
} catch (e) {
const exception = handleInvalidDocumentBatch(e);
const exception = compileError(e);
span.setStatus({
code: SpanStatusCode.ERROR,
message: exception.message

Просмотреть файл

@ -54,6 +54,7 @@ export interface JobManifestTasks {
export interface EntitiesTask {
parameters?: EntitiesTaskParameters;
taskName?: string;
}
export interface EntitiesTaskParameters {
@ -64,6 +65,7 @@ export interface EntitiesTaskParameters {
export interface PiiTask {
parameters?: PiiTaskParameters;
taskName?: string;
}
export interface PiiTaskParameters {
@ -77,6 +79,7 @@ export interface PiiTaskParameters {
export interface KeyPhrasesTask {
parameters?: KeyPhrasesTaskParameters;
taskName?: string;
}
export interface KeyPhrasesTaskParameters {
@ -86,6 +89,7 @@ export interface KeyPhrasesTaskParameters {
export interface EntityLinkingTask {
parameters?: EntityLinkingTaskParameters;
taskName?: string;
}
export interface EntityLinkingTaskParameters {
@ -96,6 +100,7 @@ export interface EntityLinkingTaskParameters {
export interface SentimentAnalysisTask {
parameters?: SentimentAnalysisTaskParameters;
taskName?: string;
}
export interface SentimentAnalysisTaskParameters {
@ -107,6 +112,7 @@ export interface SentimentAnalysisTaskParameters {
export interface ExtractiveSummarizationTask {
parameters?: ExtractiveSummarizationTaskParameters;
taskName?: string;
}
export interface ExtractiveSummarizationTaskParameters {
@ -119,6 +125,7 @@ export interface ExtractiveSummarizationTaskParameters {
export interface CustomEntitiesTask {
parameters?: CustomEntitiesTaskParameters;
taskName?: string;
}
export interface CustomEntitiesTaskParameters {
@ -130,6 +137,7 @@ export interface CustomEntitiesTaskParameters {
export interface CustomSingleClassificationTask {
parameters?: CustomSingleClassificationTaskParameters;
taskName?: string;
}
export interface CustomSingleClassificationTaskParameters {
@ -140,6 +148,7 @@ export interface CustomSingleClassificationTaskParameters {
export interface CustomMultiClassificationTask {
parameters?: CustomMultiClassificationTaskParameters;
taskName?: string;
}
export interface CustomMultiClassificationTaskParameters {
@ -213,6 +222,7 @@ export interface TasksStateTasks {
export interface TaskState {
lastUpdateDateTime: Date;
taskName: string;
status: State;
}

Просмотреть файл

@ -234,6 +234,12 @@ export const EntitiesTask: coreClient.CompositeMapper = {
name: "Composite",
className: "EntitiesTaskParameters"
}
},
taskName: {
serializedName: "taskName",
type: {
name: "String"
}
}
}
}
@ -279,6 +285,12 @@ export const PiiTask: coreClient.CompositeMapper = {
name: "Composite",
className: "PiiTaskParameters"
}
},
taskName: {
serializedName: "taskName",
type: {
name: "String"
}
}
}
}
@ -345,6 +357,12 @@ export const KeyPhrasesTask: coreClient.CompositeMapper = {
name: "Composite",
className: "KeyPhrasesTaskParameters"
}
},
taskName: {
serializedName: "taskName",
type: {
name: "String"
}
}
}
}
@ -384,6 +402,12 @@ export const EntityLinkingTask: coreClient.CompositeMapper = {
name: "Composite",
className: "EntityLinkingTaskParameters"
}
},
taskName: {
serializedName: "taskName",
type: {
name: "String"
}
}
}
}
@ -429,6 +453,12 @@ export const SentimentAnalysisTask: coreClient.CompositeMapper = {
name: "Composite",
className: "SentimentAnalysisTaskParameters"
}
},
taskName: {
serializedName: "taskName",
type: {
name: "String"
}
}
}
}
@ -481,6 +511,12 @@ export const ExtractiveSummarizationTask: coreClient.CompositeMapper = {
name: "Composite",
className: "ExtractiveSummarizationTaskParameters"
}
},
taskName: {
serializedName: "taskName",
type: {
name: "String"
}
}
}
}
@ -540,6 +576,12 @@ export const CustomEntitiesTask: coreClient.CompositeMapper = {
name: "Composite",
className: "CustomEntitiesTaskParameters"
}
},
taskName: {
serializedName: "taskName",
type: {
name: "String"
}
}
}
}
@ -592,6 +634,12 @@ export const CustomSingleClassificationTask: coreClient.CompositeMapper = {
name: "Composite",
className: "CustomSingleClassificationTaskParameters"
}
},
taskName: {
serializedName: "taskName",
type: {
name: "String"
}
}
}
}
@ -638,6 +686,12 @@ export const CustomMultiClassificationTask: coreClient.CompositeMapper = {
name: "Composite",
className: "CustomMultiClassificationTaskParameters"
}
},
taskName: {
serializedName: "taskName",
type: {
name: "String"
}
}
}
}
@ -1020,6 +1074,13 @@ export const TaskState: coreClient.CompositeMapper = {
name: "DateTime"
}
},
taskName: {
serializedName: "taskName",
required: true,
type: {
name: "String"
}
},
status: {
serializedName: "status",
required: true,

Просмотреть файл

@ -21,7 +21,7 @@ import { createSpan } from "./tracing";
import {
addStrEncodingParam,
getRawResponse,
handleInvalidDocumentBatch,
compileError,
sendGetRequest,
StringIndexType
} from "./util";
@ -129,7 +129,7 @@ export class HealthLro implements LongRunningOperation<PagedAnalyzeHealthcareEnt
rawResponse
};
} catch (e) {
const exception = handleInvalidDocumentBatch(e);
const exception = compileError(e);
span.setStatus({
code: SpanStatusCode.ERROR,
message: exception.message

Просмотреть файл

@ -51,7 +51,7 @@ import { textAnalyticsAzureKeyCredentialPolicy } from "./azureKeyCredentialPolic
import {
addParamsToTask,
compose,
handleInvalidDocumentBatch,
compileError,
setCategoriesFilter,
setOpinionMining,
setOrderBy,
@ -380,43 +380,43 @@ export interface MultiCategoryClassifyAction extends CustomTextAnalyticsAction {
}
/**
* Description of collection of actions for the analyze API to perform on input documents. However, currently, the service can accept up to one action only per action type.
* Description of collection of actions for the analyze API to perform on input documents.
*/
export interface TextAnalyticsActions {
/**
* A collection of descriptions of entities recognition actions. However, currently, the service can accept up to one action only for `recognizeEntities`.
* A collection of descriptions of entities recognition actions.
*/
recognizeEntitiesActions?: RecognizeCategorizedEntitiesAction[];
/**
* A collection of descriptions of Pii entities recognition actions. However, currently, the service can accept up to one action only for `recognizePiiEntities`.
* A collection of descriptions of Pii entities recognition actions.
*/
recognizePiiEntitiesActions?: RecognizePiiEntitiesAction[];
/**
* A collection of descriptions of key phrases recognition actions. However, currently, the service can accept up to one action only for `extractKeyPhrases`.
* A collection of descriptions of key phrases recognition actions.
*/
extractKeyPhrasesActions?: ExtractKeyPhrasesAction[];
/**
* A collection of descriptions of entities linking actions. However, currently, the service can accept up to one action only for `recognizeLinkedEntities`.
* A collection of descriptions of entities linking actions.
*/
recognizeLinkedEntitiesActions?: RecognizeLinkedEntitiesAction[];
/**
* A collection of descriptions of sentiment analysis actions. However, currently, the service can accept up to one action only for `analyzeSentiment`.
* A collection of descriptions of sentiment analysis actions.
*/
analyzeSentimentActions?: AnalyzeSentimentAction[];
/**
* A collection of descriptions of summarization extraction actions. However, currently, the service can accept up to one action only for `extractSummary`.
* A collection of descriptions of summarization extraction actions.
*/
extractSummaryActions?: ExtractSummaryAction[];
/**
* A collection of descriptions of custom entity recognition actions. However, currently, the service can accept up to one action only for `customRecognizeEntities`.
* A collection of descriptions of custom entity recognition actions.
*/
recognizeCustomEntitiesActions?: RecognizeCustomEntitiesAction[];
/**
* A collection of descriptions of custom single classification actions. However, currently, the service can accept up to one action only for `singleCategoryClassifyActions`.
* A collection of descriptions of custom single classification actions.
*/
singleCategoryClassifyActions?: SingleCategoryClassifyAction[];
/**
* A collection of descriptions of custom multi classification actions. However, currently, the service can accept up to one action only for `multiCategoryClassifyActions`.
* A collection of descriptions of custom multi classification actions.
*/
multiCategoryClassifyActions?: MultiCategoryClassifyAction[];
}
@ -657,7 +657,7 @@ export class TextAnalyticsClient {
* earlier versions were throwing an exception that included the inner
* code only.
*/
const backwardCompatibleException = handleInvalidDocumentBatch(e);
const backwardCompatibleException = compileError(e);
span.setStatus({
code: SpanStatusCode.ERROR,
message: backwardCompatibleException.message
@ -1119,7 +1119,6 @@ export class TextAnalyticsClient {
realInputs = documents;
realOptions = (languageOrOptions as BeginAnalyzeActionsOptions) || {};
}
validateActions(actions);
const compiledActions = compileAnalyzeInput(actions);
const {
updateIntervalInMs,
@ -1167,22 +1166,6 @@ export class TextAnalyticsClient {
}
}
function validateActions(actions: TextAnalyticsActions): void {
function validateActionType(actionList: unknown[] | undefined, actionType: string): void {
if ((actionList?.length ?? 0) > 1) {
throw new Error(
`beginAnalyzeActions: Currently, the service can accept up to one action only for ${actionType} actions.`
);
}
}
validateActionType(actions.analyzeSentimentActions, `analyzeSentiment`);
validateActionType(actions.extractKeyPhrasesActions, `extractKeyPhrases`);
validateActionType(actions.recognizeEntitiesActions, `recognizeEntities`);
validateActionType(actions.recognizeLinkedEntitiesActions, `recognizeLinkedEntities`);
validateActionType(actions.recognizePiiEntitiesActions, `recognizePiiEntities`);
validateActionType(actions.extractSummaryActions, `extractSummary`);
}
/**
* @internal
*/

Просмотреть файл

@ -5,7 +5,13 @@ import { RestError } from "@azure/core-rest-pipeline";
import { FullOperationResponse, OperationOptions, OperationSpec } from "@azure/core-client";
import { SpanStatusCode } from "@azure/core-tracing";
import { logger } from "./logger";
import { GeneratedClient, StringIndexType as GeneratedStringIndexType } from "./generated";
import {
ErrorResponse,
GeneratedClient,
InnerError,
StringIndexType as GeneratedStringIndexType,
TextAnalyticsError
} from "./generated";
import { TextAnalyticsAction } from "./textAnalyticsAction";
import { createSpan } from "./tracing";
import { LroResponse } from "@azure/core-lro";
@ -193,44 +199,46 @@ export function getOperationId(operationLocation: string): string {
return operationLocation.substring(lastSlashIndex + 1);
}
function appendReadableErrorMessage(currentMessage: string, innerMessage: string): string {
let message = currentMessage;
if (message.slice(-1) !== ".") {
message = message + ".";
}
return message + " " + innerMessage;
}
/**
* @internal
* parses incoming errors from the service and if the inner error code is
* InvalidDocumentBatch, it exposes that as the statusCode instead.
* @param error - the incoming error
*/
export function handleInvalidDocumentBatch(error: unknown): any {
const castError = error as {
export function compileError(errorResponse: unknown): any {
const castErrorResponse = errorResponse as {
response: {
parsedBody?: {
error?: {
innererror?: {
code: string;
message: string;
};
};
};
parsedBody?: ErrorResponse;
};
statusCode: number;
};
const innerCode = castError.response?.parsedBody?.error?.innererror?.code;
const innerMessage = castError.response?.parsedBody?.error?.innererror?.message;
if (innerMessage) {
return innerCode === "InvalidDocumentBatch"
? new RestError(innerMessage, { code: innerCode, statusCode: castError.statusCode })
: error;
} else {
// unfortunately, the service currently does not follow the swagger definition
// for errors in some cases.
// Issue: https://msazure.visualstudio.com/Cognitive%20Services/_workitems/edit/8775003/?workitem=8972164
// throw new Error(
// `The error coming from the service does not follow the expected structure: ${error}`
// );
logger.warning(
`The error coming from the service does not follow the expected structure: ${error}`
);
return error;
const topLevelError = castErrorResponse.response.parsedBody?.error;
if (!topLevelError) return errorResponse;
let errorMessage = topLevelError.message || "";
let invalidDocumentBatchCode = false;
function unwrap(error: TextAnalyticsError | InnerError): TextAnalyticsError {
if (error?.innererror !== undefined && error.innererror.message !== undefined) {
if (error.innererror.code === "InvalidDocumentBatch") {
invalidDocumentBatchCode = true;
}
errorMessage = appendReadableErrorMessage(errorMessage, error.innererror.message);
return unwrap(error.innererror);
}
return error as TextAnalyticsError;
}
unwrap(topLevelError);
return new RestError(errorMessage, {
code: invalidDocumentBatchCode ? "InvalidDocumentBatch" : topLevelError.code,
statusCode: castErrorResponse.statusCode
});
}
/**

Просмотреть файл

@ -195,16 +195,6 @@ directive:
delete $["targetRef"];
```
### Remove taskName
```yaml
directive:
- from: swagger-document
where: $.definitions..properties
transform: >
delete $["taskName"];
```
### Rename text input objects to avoid "export as"
```yaml

Просмотреть файл

@ -447,7 +447,7 @@ matrix([["APIKey", "AAD"]] as const, async (authMethod: AuthMethod) => {
assert.equal(e.code, "InvalidDocumentBatch");
assert.equal(
e.message,
"Batch request contains too many records. Max 5 records are permitted."
"Invalid document in request. Batch request contains too many records. Max 5 records are permitted."
);
}
});
@ -723,7 +723,7 @@ matrix([["APIKey", "AAD"]] as const, async (authMethod: AuthMethod) => {
assert.equal(e.code, "InvalidDocumentBatch");
assert.equal(
e.message,
"Batch request contains too many records. Max 5 records are permitted."
"Invalid document in request. Batch request contains too many records. Max 5 records are permitted."
);
}
});
@ -2222,30 +2222,52 @@ matrix([["APIKey", "AAD"]] as const, async (authMethod: AuthMethod) => {
}
});
it("multiple actions per type are disallowed", async function() {
it("duplicate actions of the same type are disallowed", async function() {
const docs = [{ id: "1", text: "I will go to the park." }];
try {
await client.beginAnalyzeActions(
const response = await client.beginAnalyzeActions(
docs,
{
recognizePiiEntitiesActions: [
{ modelVersion: "latest" },
{ modelVersion: "latest", stringIndexType: "TextElement_v8" }
{ modelVersion: "latest" }
]
},
{
updateIntervalInMs: pollingInterval
}
);
throw new Error("Expected an error to occur");
} catch (e) {
assert.equal(
e.message,
"beginAnalyzeActions: Currently, the service can accept up to one action only for recognizePiiEntities actions."
assert.fail(
`expected a failure but received the following intead: ${JSON.stringify(
response,
null,
2
)}`
);
} catch (e) {
assert.equal(e.code, "InvalidRequest");
assert.include(e.message, "Duplicate task name");
}
});
it("unique multiple actions per type are allowed", async function() {
const docs = [{ id: "1", text: "I will go to the park." }];
const response = await client.beginAnalyzeActions(
docs,
{
recognizePiiEntitiesActions: [
{ modelVersion: "latest", actionName: "action1" },
{ modelVersion: "latest", actionName: "action2" }
]
},
{
updateIntervalInMs: pollingInterval
}
);
assert.isDefined(response);
});
});
describe("#health", function() {
@ -2458,7 +2480,7 @@ matrix([["APIKey", "AAD"]] as const, async (authMethod: AuthMethod) => {
assert.equal(e.code, "InvalidDocumentBatch");
assert.equal(
e.message,
"Batch request contains too many records. Max 10 records are permitted."
"Invalid document in request. Batch request contains too many records. Max 10 records are permitted."
);
}
});
@ -2489,7 +2511,7 @@ matrix([["APIKey", "AAD"]] as const, async (authMethod: AuthMethod) => {
assert.equal(e.code, "InvalidDocumentBatch");
assert.equal(
e.message,
"Request Payload sent is too large to be processed. Limit request size to: 524288"
"Invalid document in request. Request Payload sent is too large to be processed. Limit request size to: 524288"
);
}
});