@azure/ai-language-text 1.1.0-alpha.20221128.2 → 1.1.0-alpha.20221130.3

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.
@@ -51,7 +51,14 @@ function createSendPollRequest(settings) {
51
51
  return async (path) => {
52
52
  return throwError(sendRequest({
53
53
  client,
54
- opOptions: options,
54
+ opOptions: Object.assign(Object.assign({}, options), { onResponse: (rawResponse, response, error) => {
55
+ var _a;
56
+ const castResponse = response;
57
+ if (castResponse.status.toLowerCase() === "partiallysucceeded") {
58
+ castResponse.status = "failed";
59
+ }
60
+ (_a = options.onResponse) === null || _a === void 0 ? void 0 : _a.call(options, rawResponse, response, error);
61
+ } }),
55
62
  path,
56
63
  spanStr,
57
64
  spec: jobStatusOperationSpec,
@@ -1 +1 @@
1
- {"version":3,"file":"lro.js","sourceRoot":"","sources":["../../src/lro.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,KAAK,OAAO,MAAM,4BAA4B,CAAC;AACtD,OAAO,KAAK,UAAU,MAAM,+BAA+B,CAAC;AAc5D,OAAO,EAIL,gBAAgB,GACjB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAe,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AACxE,OAAO,EAAE,UAAU,EAAE,4BAA4B,EAAE,MAAM,cAAc,CAAC;AAGxE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,MAAM,UAAU,GAAG,gBAAgB,CAAC,OAAO,EAAE,WAAW,CAAC,KAAK,CAAC,CAAC;AAEhE,MAAM,sBAAsB,GAAkB;IAC5C,UAAU,EAAE,KAAK;IACjB,SAAS,EAAE;QACT,GAAG,EAAE;YACH,UAAU,EAAE,OAAO,CAAC,mBAAmB;SACxC;QACD,OAAO,EAAE;YACP,UAAU,EAAE,OAAO,CAAC,aAAa;SAClC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AG,QAAQ,CAAC;IAC1D,uCACK,MAAM,KACT,uBAAuB,EAAE,KAAK,IAAI,EAAE;YAClC,MAAM,OAAO,CAAC,QAAQ,CAAC,GAAG,UAAU,oBAAoB,EAAE,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,EAAE,CACxF,UAAU,CACR,cAAc,CACZ,CAAC,YAAY,EAAE,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,EAAE,EAAE,YAAY,CAAC,EAChE,YAAY,CACb,CACF,CACF,CAAC;QACJ,CAAC,IACD;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport * as Mappers from \"./generated/models/mappers\";\nimport * as Parameters from \"./generated/models/parameters\";\nimport {\n AnalyzeBatchActionUnion,\n AnalyzeTextJobStatusOptionalParams,\n AnalyzeTextJobStatusResponse,\n GeneratedClient,\n TextDocumentInput,\n} from \"./generated\";\nimport {\n AnalyzeBatchOperationState,\n AnalyzeBatchResult,\n PagedAnalyzeBatchResult,\n PollerLike,\n} from \"./models\";\nimport {\n FullOperationResponse,\n OperationOptions,\n OperationSpec,\n createSerializer,\n} from \"@azure/core-client\";\nimport { LongRunningOperation, LroResponse, SimplePollerLike } from \"@azure/core-lro\";\nimport { PagedResult, getPagedAsyncIterator } from \"@azure/core-paging\";\nimport { throwError, transformAnalyzeBatchResults } from \"./transforms\";\nimport { HttpMethods } from \"@azure/core-rest-pipeline\";\nimport { TracingClient } from \"@azure/core-tracing\";\nimport { clientName } from \"./constants\";\nimport { logger } from \"./logger\";\n\nconst serializer = createSerializer(Mappers, /* isXml */ false);\n\nconst jobStatusOperationSpec: OperationSpec = {\n httpMethod: \"GET\",\n responses: {\n 200: {\n bodyMapper: Mappers.AnalyzeTextJobState,\n },\n default: {\n bodyMapper: Mappers.ErrorResponse,\n },\n },\n headerParameters: [Parameters.accept],\n queryParameters: [Parameters.top, Parameters.skip, Parameters.includeStatistics],\n serializer,\n};\n\nasync function getRawResponse<TOptions extends OperationOptions, TResponse>(\n getResponse: (options: TOptions) => Promise<TResponse>,\n options: TOptions\n): Promise<LroResponse<TResponse>> {\n const { onResponse } = options || {};\n let rawResponse: FullOperationResponse;\n const flatResponse = await getResponse({\n ...options,\n onResponse: (response, flatResponseParam) => {\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\nasync function sendRequest<TOptions extends OperationOptions>(settings: {\n client: GeneratedClient;\n tracing: TracingClient;\n spec: OperationSpec;\n spanStr: string;\n opOptions: TOptions;\n path: string;\n httpMethod?: HttpMethods;\n}): Promise<LroResponse<unknown>> {\n const { client, opOptions, path, spanStr, spec, tracing, httpMethod = \"GET\" } = settings;\n return tracing.withSpan(spanStr, opOptions, async (finalOptions: TOptions) =>\n throwError(\n getRawResponse(\n (options) =>\n client.sendOperationRequest(\n { options },\n {\n ...spec,\n path,\n httpMethod,\n }\n ),\n finalOptions\n )\n )\n );\n}\n\n/**\n * @internal\n */\nfunction createSendPollRequest<TOptions extends OperationOptions>(settings: {\n client: GeneratedClient;\n tracing: TracingClient;\n options: TOptions;\n spanStr: string;\n}): (path: string) => Promise<LroResponse<unknown>> {\n const { client, options, tracing, spanStr } = settings;\n return async (path: string): Promise<LroResponse<unknown>> => {\n return throwError(\n sendRequest({\n client,\n opOptions: options,\n path,\n spanStr,\n spec: jobStatusOperationSpec,\n tracing,\n })\n );\n };\n}\n\n/**\n * @internal\n */\nexport function createAnalyzeBatchLro(settings: {\n client: GeneratedClient;\n tracing: TracingClient;\n commonOptions: OperationOptions;\n initialRequestOptions: {\n displayName?: string;\n };\n pollRequestOptions: {\n includeStatistics?: boolean;\n };\n documents: TextDocumentInput[];\n tasks: AnalyzeBatchActionUnion[];\n}): LongRunningOperation {\n const {\n client,\n commonOptions,\n documents,\n initialRequestOptions,\n pollRequestOptions,\n tasks,\n tracing,\n } = settings;\n return {\n async sendInitialRequest(): Promise<LroResponse<unknown>> {\n return tracing.withSpan(\n `${clientName}.beginAnalyzeBatch`,\n {\n ...commonOptions,\n ...initialRequestOptions,\n },\n async (finalOptions) =>\n throwError(\n getRawResponse(\n (paramOptions) =>\n client.analyzeBatch(\n {\n tasks,\n analysisInput: {\n documents,\n },\n displayName: initialRequestOptions.displayName,\n },\n paramOptions\n ),\n finalOptions\n )\n )\n );\n },\n sendPollRequest: createSendPollRequest({\n client,\n options: { ...commonOptions, ...pollRequestOptions },\n spanStr: `${clientName}.beginAnalyzeBatch`,\n tracing,\n }),\n };\n}\n\n/**\n * @internal\n */\nexport function getDocIDsFromState(serializedState: string): string[] {\n try {\n const { docIds } = JSON.parse(serializedState).state;\n return docIds;\n } catch (e) {\n logger.error(\n `Document IDs are not found in the LRO's state. The results may not be ordered correctly.`\n );\n return [];\n }\n}\n\n/**\n * @internal\n */\nexport function createCreateAnalyzeBatchPollerLro<OptionsT extends OperationOptions>(settings: {\n client: GeneratedClient;\n tracing: TracingClient;\n options: OptionsT;\n}): LongRunningOperation {\n const { client, options, tracing } = settings;\n return {\n async sendInitialRequest(): Promise<LroResponse<unknown>> {\n throw new Error(`The operation has already started`);\n },\n sendPollRequest: createSendPollRequest({\n client,\n options,\n spanStr: `${clientName}.beginAnalyzeBatch`,\n tracing,\n }),\n };\n}\n\n/**\n * @internal\n */\nexport function processAnalyzeResult(options: {\n client: GeneratedClient;\n tracing: TracingClient;\n docIds: string[];\n opOptions: AnalyzeTextJobStatusOptionalParams;\n state: { continuationToken: string };\n}): (result: unknown, state: AnalyzeBatchOperationState) => PagedAnalyzeBatchResult {\n return (): PagedAnalyzeBatchResult => {\n const { client, docIds, opOptions, tracing, state } = options;\n const pageURL = state.continuationToken;\n const pagedResult: PagedResult<AnalyzeBatchResult[]> = {\n firstPageLink: pageURL,\n getPage: async (pageLink: string, maxPageSize?: number) => {\n const response = await sendRequest({\n client,\n spec: jobStatusOperationSpec,\n spanStr: `${clientName}.beginAnalyzeBatch`,\n // if `top` is set to `undefined`, the default value will not be sent\n // as part of the request.\n opOptions: maxPageSize ? { ...opOptions, top: maxPageSize } : opOptions,\n path: pageLink,\n tracing,\n });\n const flatResponse = response.flatResponse as AnalyzeTextJobStatusResponse;\n return {\n page: transformAnalyzeBatchResults(docIds, flatResponse.tasks.items),\n nextPageLink: flatResponse.nextLink,\n };\n },\n };\n return getPagedAsyncIterator(pagedResult);\n };\n}\n\ntype Writable<T> = {\n -readonly [P in keyof T]: T[P];\n};\n\n/**\n * @internal\n */\nexport function createUpdateAnalyzeState(docIds?: string[]) {\n return (state: AnalyzeBatchOperationState, lastResponse: LroResponse): void => {\n const { createdOn, modifiedOn, id, displayName, expiresOn, tasks, lastUpdateDateTime } =\n lastResponse.flatResponse as AnalyzeTextJobStatusResponse & { lastUpdateDateTime: string };\n const mutableState = state as Writable<AnalyzeBatchOperationState> & {\n docIds?: string[];\n };\n mutableState.createdOn = createdOn;\n // FIXME: remove this mitigation when the service API is fixed\n mutableState.modifiedOn = modifiedOn ? modifiedOn : new Date(lastUpdateDateTime);\n mutableState.expiresOn = expiresOn;\n mutableState.displayName = displayName;\n mutableState.id = id;\n mutableState.actionSucceededCount = tasks.completed;\n mutableState.actionFailedCount = tasks.failed;\n mutableState.actionInProgressCount = tasks.inProgress;\n if (mutableState.docIds === undefined && docIds !== undefined) {\n mutableState.docIds = docIds;\n }\n };\n}\n\n/**\n * @internal\n */\nexport function createPollerWithCancellation(settings: {\n poller: SimplePollerLike<AnalyzeBatchOperationState, PagedAnalyzeBatchResult>;\n client: GeneratedClient;\n tracing: TracingClient;\n options: AnalyzeTextJobStatusOptionalParams;\n id: string;\n}): PollerLike<AnalyzeBatchOperationState, PagedAnalyzeBatchResult> {\n const { client, options, poller, id, tracing } = settings;\n return {\n ...poller,\n sendCancellationRequest: async () => {\n await tracing.withSpan(`${clientName}.beginAnalyzeBatch`, options, async (finalOptions) =>\n throwError(\n getRawResponse(\n (paramOptions) => client.analyzeText.cancelJob(id, paramOptions),\n finalOptions\n )\n )\n );\n },\n };\n}\n"]}
1
+ {"version":3,"file":"lro.js","sourceRoot":"","sources":["../../src/lro.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,KAAK,OAAO,MAAM,4BAA4B,CAAC;AACtD,OAAO,KAAK,UAAU,MAAM,+BAA+B,CAAC;AAc5D,OAAO,EAIL,gBAAgB,GACjB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAe,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AACxE,OAAO,EAAE,UAAU,EAAE,4BAA4B,EAAE,MAAM,cAAc,CAAC;AAGxE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,MAAM,UAAU,GAAG,gBAAgB,CAAC,OAAO,EAAE,WAAW,CAAC,KAAK,CAAC,CAAC;AAEhE,MAAM,sBAAsB,GAAkB;IAC5C,UAAU,EAAE,KAAK;IACjB,SAAS,EAAE;QACT,GAAG,EAAE;YACH,UAAU,EAAE,OAAO,CAAC,mBAAmB;SACxC;QACD,OAAO,EAAE;YACP,UAAU,EAAE,OAAO,CAAC,aAAa;SAClC;KACF;IACD,gBAAgB,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC;IACrC,eAAe,EAAE,CAAC,UAAU,CAAC,GAAG,EAAE,UAAU,CAAC,IAAI,EAAE,UAAU,CAAC,iBAAiB,CAAC;IAChF,UAAU;CACX,CAAC;AAEF,KAAK,UAAU,cAAc,CAC3B,WAAsD,EACtD,OAAiB;IAEjB,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,IAAI,EAAE,CAAC;IACrC,IAAI,WAAkC,CAAC;IACvC,MAAM,YAAY,GAAG,MAAM,WAAW,iCACjC,OAAO,KACV,UAAU,EAAE,CAAC,QAAQ,EAAE,iBAAiB,EAAE,EAAE;YAC1C,WAAW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,CAAC,GAAG,UAAU,oBAAoB,EAAE,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,EAAE,CACxF,UAAU,CACR,cAAc,CACZ,CAAC,YAAY,EAAE,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,EAAE,EAAE,YAAY,CAAC,EAChE,YAAY,CACb,CACF,CACF,CAAC;QACJ,CAAC,IACD;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport * as Mappers from \"./generated/models/mappers\";\nimport * as Parameters from \"./generated/models/parameters\";\nimport {\n AnalyzeBatchActionUnion,\n AnalyzeTextJobStatusOptionalParams,\n AnalyzeTextJobStatusResponse,\n GeneratedClient,\n TextDocumentInput,\n} from \"./generated\";\nimport {\n AnalyzeBatchOperationState,\n AnalyzeBatchResult,\n PagedAnalyzeBatchResult,\n PollerLike,\n} from \"./models\";\nimport {\n FullOperationResponse,\n OperationOptions,\n OperationSpec,\n createSerializer,\n} from \"@azure/core-client\";\nimport { LongRunningOperation, LroResponse, SimplePollerLike } from \"@azure/core-lro\";\nimport { PagedResult, getPagedAsyncIterator } from \"@azure/core-paging\";\nimport { throwError, transformAnalyzeBatchResults } from \"./transforms\";\nimport { HttpMethods } from \"@azure/core-rest-pipeline\";\nimport { TracingClient } from \"@azure/core-tracing\";\nimport { clientName } from \"./constants\";\nimport { logger } from \"./logger\";\n\nconst serializer = createSerializer(Mappers, /* isXml */ false);\n\nconst jobStatusOperationSpec: OperationSpec = {\n httpMethod: \"GET\",\n responses: {\n 200: {\n bodyMapper: Mappers.AnalyzeTextJobState,\n },\n default: {\n bodyMapper: Mappers.ErrorResponse,\n },\n },\n headerParameters: [Parameters.accept],\n queryParameters: [Parameters.top, Parameters.skip, Parameters.includeStatistics],\n serializer,\n};\n\nasync function getRawResponse<TOptions extends OperationOptions, TResponse>(\n getResponse: (options: TOptions) => Promise<TResponse>,\n options: TOptions\n): Promise<LroResponse<TResponse>> {\n const { onResponse } = options || {};\n let rawResponse: FullOperationResponse;\n const flatResponse = await getResponse({\n ...options,\n onResponse: (response, flatResponseParam) => {\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\nasync function sendRequest<TOptions extends OperationOptions>(settings: {\n client: GeneratedClient;\n tracing: TracingClient;\n spec: OperationSpec;\n spanStr: string;\n opOptions: TOptions;\n path: string;\n httpMethod?: HttpMethods;\n}): Promise<LroResponse<unknown>> {\n const { client, opOptions, path, spanStr, spec, tracing, httpMethod = \"GET\" } = settings;\n return tracing.withSpan(spanStr, opOptions, async (finalOptions: TOptions) =>\n throwError(\n getRawResponse(\n (options) =>\n client.sendOperationRequest(\n { options },\n {\n ...spec,\n path,\n httpMethod,\n }\n ),\n finalOptions\n )\n )\n );\n}\n\n/**\n * @internal\n */\nfunction createSendPollRequest<TOptions extends OperationOptions>(settings: {\n client: GeneratedClient;\n tracing: TracingClient;\n options: TOptions;\n spanStr: string;\n}): (path: string) => Promise<LroResponse<unknown>> {\n const { client, options, tracing, spanStr } = settings;\n return async (path: string): Promise<LroResponse<unknown>> => {\n return throwError(\n sendRequest({\n client,\n opOptions: {\n ...options,\n onResponse: (rawResponse, response, error) => {\n const castResponse = response as AnalyzeTextJobStatusResponse;\n if (castResponse.status.toLowerCase() === \"partiallysucceeded\") {\n castResponse.status = \"failed\";\n }\n\n options.onResponse?.(rawResponse, response, error);\n },\n },\n path,\n spanStr,\n spec: jobStatusOperationSpec,\n tracing,\n })\n );\n };\n}\n\n/**\n * @internal\n */\nexport function createAnalyzeBatchLro(settings: {\n client: GeneratedClient;\n tracing: TracingClient;\n commonOptions: OperationOptions;\n initialRequestOptions: {\n displayName?: string;\n };\n pollRequestOptions: {\n includeStatistics?: boolean;\n };\n documents: TextDocumentInput[];\n tasks: AnalyzeBatchActionUnion[];\n}): LongRunningOperation {\n const {\n client,\n commonOptions,\n documents,\n initialRequestOptions,\n pollRequestOptions,\n tasks,\n tracing,\n } = settings;\n return {\n async sendInitialRequest(): Promise<LroResponse<unknown>> {\n return tracing.withSpan(\n `${clientName}.beginAnalyzeBatch`,\n {\n ...commonOptions,\n ...initialRequestOptions,\n },\n async (finalOptions) =>\n throwError(\n getRawResponse(\n (paramOptions) =>\n client.analyzeBatch(\n {\n tasks,\n analysisInput: {\n documents,\n },\n displayName: initialRequestOptions.displayName,\n },\n paramOptions\n ),\n finalOptions\n )\n )\n );\n },\n sendPollRequest: createSendPollRequest({\n client,\n options: { ...commonOptions, ...pollRequestOptions },\n spanStr: `${clientName}.beginAnalyzeBatch`,\n tracing,\n }),\n };\n}\n\n/**\n * @internal\n */\nexport function getDocIDsFromState(serializedState: string): string[] {\n try {\n const { docIds } = JSON.parse(serializedState).state;\n return docIds;\n } catch (e) {\n logger.error(\n `Document IDs are not found in the LRO's state. The results may not be ordered correctly.`\n );\n return [];\n }\n}\n\n/**\n * @internal\n */\nexport function createCreateAnalyzeBatchPollerLro<OptionsT extends OperationOptions>(settings: {\n client: GeneratedClient;\n tracing: TracingClient;\n options: OptionsT;\n}): LongRunningOperation {\n const { client, options, tracing } = settings;\n return {\n async sendInitialRequest(): Promise<LroResponse<unknown>> {\n throw new Error(`The operation has already started`);\n },\n sendPollRequest: createSendPollRequest({\n client,\n options,\n spanStr: `${clientName}.beginAnalyzeBatch`,\n tracing,\n }),\n };\n}\n\n/**\n * @internal\n */\nexport function processAnalyzeResult(options: {\n client: GeneratedClient;\n tracing: TracingClient;\n docIds: string[];\n opOptions: AnalyzeTextJobStatusOptionalParams;\n state: { continuationToken: string };\n}): (result: unknown, state: AnalyzeBatchOperationState) => PagedAnalyzeBatchResult {\n return (): PagedAnalyzeBatchResult => {\n const { client, docIds, opOptions, tracing, state } = options;\n const pageURL = state.continuationToken;\n const pagedResult: PagedResult<AnalyzeBatchResult[]> = {\n firstPageLink: pageURL,\n getPage: async (pageLink: string, maxPageSize?: number) => {\n const response = await sendRequest({\n client,\n spec: jobStatusOperationSpec,\n spanStr: `${clientName}.beginAnalyzeBatch`,\n // if `top` is set to `undefined`, the default value will not be sent\n // as part of the request.\n opOptions: maxPageSize ? { ...opOptions, top: maxPageSize } : opOptions,\n path: pageLink,\n tracing,\n });\n const flatResponse = response.flatResponse as AnalyzeTextJobStatusResponse;\n return {\n page: transformAnalyzeBatchResults(docIds, flatResponse.tasks.items),\n nextPageLink: flatResponse.nextLink,\n };\n },\n };\n return getPagedAsyncIterator(pagedResult);\n };\n}\n\ntype Writable<T> = {\n -readonly [P in keyof T]: T[P];\n};\n\n/**\n * @internal\n */\nexport function createUpdateAnalyzeState(docIds?: string[]) {\n return (state: AnalyzeBatchOperationState, lastResponse: LroResponse): void => {\n const { createdOn, modifiedOn, id, displayName, expiresOn, tasks, lastUpdateDateTime } =\n lastResponse.flatResponse as AnalyzeTextJobStatusResponse & { lastUpdateDateTime: string };\n const mutableState = state as Writable<AnalyzeBatchOperationState> & {\n docIds?: string[];\n };\n mutableState.createdOn = createdOn;\n // FIXME: remove this mitigation when the service API is fixed\n mutableState.modifiedOn = modifiedOn ? modifiedOn : new Date(lastUpdateDateTime);\n mutableState.expiresOn = expiresOn;\n mutableState.displayName = displayName;\n mutableState.id = id;\n mutableState.actionSucceededCount = tasks.completed;\n mutableState.actionFailedCount = tasks.failed;\n mutableState.actionInProgressCount = tasks.inProgress;\n if (mutableState.docIds === undefined && docIds !== undefined) {\n mutableState.docIds = docIds;\n }\n };\n}\n\n/**\n * @internal\n */\nexport function createPollerWithCancellation(settings: {\n poller: SimplePollerLike<AnalyzeBatchOperationState, PagedAnalyzeBatchResult>;\n client: GeneratedClient;\n tracing: TracingClient;\n options: AnalyzeTextJobStatusOptionalParams;\n id: string;\n}): PollerLike<AnalyzeBatchOperationState, PagedAnalyzeBatchResult> {\n const { client, options, poller, id, tracing } = settings;\n return {\n ...poller,\n sendCancellationRequest: async () => {\n await tracing.withSpan(`${clientName}.beginAnalyzeBatch`, options, async (finalOptions) =>\n throwError(\n getRawResponse(\n (paramOptions) => client.analyzeText.cancelJob(id, paramOptions),\n finalOptions\n )\n )\n );\n },\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 text analysis features in the Azure Cognitive Language Service.",
6
- "version": "1.1.0-alpha.20221128.2",
6
+ "version": "1.1.0-alpha.20221130.3",
7
7
  "keywords": [
8
8
  "node",
9
9
  "azure",