@azure/ai-text-analytics 5.1.1-alpha.20240112.1 → 5.1.1-alpha.20240117.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.
- package/dist/index.js +107 -164
- package/dist/index.js.map +1 -1
- package/dist-esm/src/analyzeActionsResult.js +7 -6
- package/dist-esm/src/analyzeActionsResult.js.map +1 -1
- package/dist-esm/src/analyzeHealthcareEntitiesResult.js +3 -7
- package/dist-esm/src/analyzeHealthcareEntitiesResult.js.map +1 -1
- package/dist-esm/src/analyzeSentimentResult.js +4 -7
- package/dist-esm/src/analyzeSentimentResult.js.map +1 -1
- package/dist-esm/src/detectLanguageResult.js +1 -4
- package/dist-esm/src/detectLanguageResult.js.map +1 -1
- package/dist-esm/src/extractKeyPhrasesResult.js +1 -4
- package/dist-esm/src/extractKeyPhrasesResult.js.map +1 -1
- package/dist-esm/src/generated/generatedClient.js +4 -10
- package/dist-esm/src/generated/generatedClient.js.map +1 -1
- package/dist-esm/src/generated/models/mappers.js +10 -44
- package/dist-esm/src/generated/models/mappers.js.map +1 -1
- package/dist-esm/src/lro/analyze/operation.js +18 -21
- package/dist-esm/src/lro/analyze/operation.js.map +1 -1
- package/dist-esm/src/lro/health/operation.js +34 -22
- package/dist-esm/src/lro/health/operation.js.map +1 -1
- package/dist-esm/src/recognizeCategorizedEntitiesResult.js +1 -4
- package/dist-esm/src/recognizeCategorizedEntitiesResult.js.map +1 -1
- package/dist-esm/src/recognizeLinkedEntitiesResult.js +1 -4
- package/dist-esm/src/recognizeLinkedEntitiesResult.js.map +1 -1
- package/dist-esm/src/recognizePiiEntitiesResult.js +2 -5
- package/dist-esm/src/recognizePiiEntitiesResult.js.map +1 -1
- package/dist-esm/src/textAnalyticsClient.js +16 -20
- package/dist-esm/src/textAnalyticsClient.js.map +1 -1
- package/dist-esm/src/util.js +8 -6
- package/dist-esm/src/util.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
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CAAC;IAED,KAAK,CAAC,MAAM;QACV,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QACzB,MAAM,CAAC,OAAO,CAAC,iEAAiE,CAAC,CAAC;QAClF,KAAK,CAAC,WAAW,GAAG,IAAI,CAAC;QACzB,OAAO,IAAI,CAAC;IACd,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { OperationOptions } from \"@azure/core-client\";\n\nimport { AbortSignalLike } from \"@azure/abort-controller\";\n\nimport {\n AnalyzeStatusOptionalParams as AnalyzeActionsOperationStatusOptions,\n AnalyzeJobState,\n AnalyzeResponse as BeginAnalyzeResponse,\n JobManifestTasks as GeneratedActions,\n TextDocumentBatchStatistics,\n TextDocumentInput,\n} from \"../../generated/models\";\nimport {\n AnalyzeActionsResult,\n PagedAnalyzeActionsResult,\n PagedAsyncIterableAnalyzeActionsResult,\n createAnalyzeActionsResult,\n} from \"../../analyzeActionsResult\";\nimport { PageSettings } from \"@azure/core-paging\";\nimport { getOperationId, nextLinkToTopAndSkip, throwError } from \"../../util\";\nimport { AnalysisPollOperation, AnalysisPollOperationState, OperationMetadata } from \"../poller\";\nimport { GeneratedClient as Client } from \"../../generated\";\nimport { logger } from \"../../logger\";\nimport { TracingClient } from \"@azure/core-tracing\";\n\n/**\n * @internal\n */\ninterface AnalyzeResultsWithPagination {\n result: AnalyzeActionsResult;\n top?: number;\n skip?: number;\n}\n\n/**\n * The metadata for beginAnalyzeActions operations.\n */\nexport interface AnalyzeActionsOperationMetadata extends OperationMetadata {\n /**\n * Number of successfully completed actions.\n */\n actionsSucceededCount: number;\n /**\n * Number of failed actions.\n */\n actionsFailedCount: number;\n /**\n * Number of actions still in progress.\n */\n actionsInProgressCount: number;\n /**\n * The operation's display name.\n */\n displayName?: string;\n}\n\n/**\n * @internal\n */\ninterface AnalyzeActionsOperationStatus {\n done: boolean;\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 operationMetdata: Omit<AnalyzeActionsOperationMetadata, \"operationId\">;\n}\n\n/**\n * @internal\n */\ninterface BeginAnalyzeInternalOptions extends OperationOptions {\n displayName?: string;\n}\n\n/**\n * Options for the begin analyze actions operation.\n */\nexport interface BeginAnalyzeActionsOptions extends OperationOptions {\n /**\n * Delay to wait until next poll, in milliseconds.\n */\n updateIntervalInMs?: number;\n /**\n * A serialized poller which can be used to resume an existing paused Long-Running-Operation.\n */\n resumeFrom?: string;\n /**\n * If set to true, response will contain input and document level statistics.\n */\n includeStatistics?: boolean;\n /**\n * The operation's display name.\n */\n displayName?: string;\n}\n\n/**\n * The state of the begin analyze polling operation.\n */\nexport interface AnalyzeActionsOperationState\n extends AnalysisPollOperationState<PagedAnalyzeActionsResult>,\n AnalyzeActionsOperationMetadata {}\n\n/**\n * @internal\n */\nfunction getMetaInfoFromResponse(\n response: AnalyzeJobState,\n): Omit<AnalyzeActionsOperationMetadata, \"operationId\"> {\n return {\n createdOn: response.createdDateTime,\n lastModifiedOn: response.lastUpdateDateTime,\n expiresOn: response.expirationDateTime,\n status: response.status,\n actionsSucceededCount: response.tasks.completed,\n actionsFailedCount: response.tasks.failed,\n actionsInProgressCount: response.tasks.inProgress,\n displayName: response.displayName,\n };\n}\n\n/**\n * Class that represents a poller that waits for results of the analyze\n * operation.\n * @internal\n */\nexport class BeginAnalyzeActionsPollerOperation extends AnalysisPollOperation<\n AnalyzeActionsOperationState,\n PagedAnalyzeActionsResult\n> {\n constructor(\n public state: AnalyzeActionsOperationState,\n // eslint-disable-next-line @azure/azure-sdk/ts-use-interface-parameters\n private client: Client,\n private tracing: TracingClient,\n private documents: TextDocumentInput[],\n private actions: GeneratedActions,\n private options: BeginAnalyzeActionsOptions = {},\n ) {\n super(state);\n }\n\n /**\n * should be called only after all the status of the analyze actions operations became\n * \"succeeded\" and it returns an iterator for the results and provides a\n * byPage method to return the results paged.\n */\n private listAnalyzeActionsResults(\n operationId: string,\n options: AnalyzeActionsOperationStatusOptions = {},\n ): PagedAsyncIterableAnalyzeActionsResult {\n const iter = this._listAnalyzeActionsResultsPaged(operationId, options);\n return {\n next() {\n return iter.next();\n },\n [Symbol.asyncIterator]() {\n return this;\n },\n byPage: (settings?: PageSettings) => {\n const pageOptions = { ...options, top: settings?.maxPageSize };\n return this._listAnalyzeActionsResultsPaged(operationId, pageOptions);\n },\n };\n }\n\n /**\n * returns an iterator to arrays of the results of an analyze actions operation.\n */\n private async *_listAnalyzeActionsResultsPaged(\n operationId: string,\n options?: AnalyzeActionsOperationStatusOptions,\n ): AsyncIterableIterator<AnalyzeActionsResult> {\n let response = await this._listAnalyzeActionsResultsSinglePage(operationId, options);\n yield response.result;\n while (response.skip) {\n const optionsWithContinuation: AnalyzeActionsOperationStatusOptions = {\n ...options,\n top: response.top,\n skip: response.skip,\n };\n response = await this._listAnalyzeActionsResultsSinglePage(\n operationId,\n optionsWithContinuation,\n );\n yield response.result;\n }\n }\n\n /**\n * returns an iterator to arrays of the sorted results of an analyze actions operation.\n */\n private async _listAnalyzeActionsResultsSinglePage(\n operationId: string,\n options?: AnalyzeActionsOperationStatusOptions,\n ): Promise<AnalyzeResultsWithPagination> {\n const response = await this.tracing.withSpan(\n \"TextAnalyticsClient-_listAnalyzeActionsResultsSinglePage\",\n options || {},\n (finalOptions) => this.client.analyzeStatus(operationId, finalOptions),\n );\n const result = createAnalyzeActionsResult(response, this.documents);\n return response.nextLink ? { result, ...nextLinkToTopAndSkip(response.nextLink) } : { result };\n }\n\n /**\n * returns whether the analyze actions operation is done and if so returns also\n * statistics.\n */\n private async getAnalyzeActionsOperationStatus(\n operationId: string,\n options?: AnalyzeActionsOperationStatusOptions,\n ): Promise<AnalyzeActionsOperationStatus> {\n const response = await this.tracing.withSpan(\n \"TextAnalyticsClient-getAnalyzeActionsOperationStatus\",\n options || {},\n (finalOptions) => this.client.analyzeStatus(operationId, finalOptions),\n );\n switch (response.status) {\n case \"notStarted\":\n case \"running\":\n break;\n default: {\n return {\n done: true,\n statistics: response.statistics,\n operationMetdata: getMetaInfoFromResponse(response),\n };\n }\n }\n return { done: false, operationMetdata: getMetaInfoFromResponse(response) };\n }\n\n private async beginAnalyzeActions(\n documents: TextDocumentInput[],\n actions: GeneratedActions,\n options?: BeginAnalyzeInternalOptions,\n ): Promise<BeginAnalyzeResponse> {\n return this.tracing.withSpan(\n \"TextAnalyticsClient-beginAnalyze\",\n options || {},\n (finalOptions) =>\n throwError(\n this.client.analyze({\n body: {\n analysisInput: { documents: documents },\n tasks: actions,\n displayName: options?.displayName,\n },\n ...finalOptions,\n }),\n ),\n );\n }\n\n async update(\n options: {\n abortSignal?: AbortSignalLike;\n fireProgress?: (state: AnalyzeActionsOperationState) => void;\n } = {},\n ): Promise<BeginAnalyzeActionsPollerOperation> {\n const state = this.state;\n const updatedAbortSignal = options.abortSignal;\n if (!state.isStarted) {\n state.isStarted = true;\n const response = await this.beginAnalyzeActions(this.documents, this.actions, {\n displayName: this.options.displayName,\n tracingOptions: this.options.tracingOptions,\n requestOptions: this.options.requestOptions,\n abortSignal: updatedAbortSignal ? updatedAbortSignal : this.options.abortSignal,\n });\n if (!response.operationLocation) {\n throw new Error(\n \"Expects a valid 'operationLocation' to retrieve analyze results but did not find any\",\n );\n }\n state.operationId = getOperationId(response.operationLocation);\n }\n\n const operationStatus = await this.getAnalyzeActionsOperationStatus(state.operationId!, {\n abortSignal: updatedAbortSignal ? updatedAbortSignal : options.abortSignal,\n includeStatistics: this.options.includeStatistics,\n tracingOptions: this.options.tracingOptions,\n });\n\n state.createdOn = operationStatus.operationMetdata.createdOn;\n state.expiresOn = operationStatus.operationMetdata.expiresOn;\n state.lastModifiedOn = operationStatus.operationMetdata.lastModifiedOn;\n state.status = operationStatus.operationMetdata.status;\n state.actionsSucceededCount = operationStatus.operationMetdata.actionsSucceededCount;\n state.actionsFailedCount = operationStatus.operationMetdata.actionsFailedCount;\n state.actionsInProgressCount = operationStatus.operationMetdata.actionsInProgressCount;\n state.displayName = operationStatus.operationMetdata?.displayName;\n\n if (!state.isCompleted && operationStatus.done) {\n const pagedIterator = this.listAnalyzeActionsResults(state.operationId!, {\n abortSignal: this.options.abortSignal,\n tracingOptions: this.options.tracingOptions,\n includeStatistics: this.options.includeStatistics,\n onResponse: this.options.onResponse,\n serializerOptions: this.options.serializerOptions,\n });\n // Attach stats if the service starts to return them\n // https://github.com/Azure/azure-sdk-for-js/issues/14139\n // state.result = Object.assign(pagedIterator, {\n // statistics: operationStatus.statistics\n // });\n state.result = pagedIterator;\n state.isCompleted = true;\n }\n\n if (typeof options.fireProgress === \"function\") {\n options.fireProgress(state);\n }\n return this;\n }\n\n async cancel(): Promise<BeginAnalyzeActionsPollerOperation> {\n const state = this.state;\n logger.warning(`The service does not yet support cancellation for beginAnalyze.`);\n state.isCancelled = true;\n return this;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"operation.js","sourceRoot":"","sources":["../../../../src/lro/analyze/operation.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;AAclC,OAAO,EAIL,0BAA0B,GAC3B,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC9E,OAAO,EAAE,qBAAqB,EAAiD,MAAM,WAAW,CAAC;AAEjG,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAoFtC;;GAEG;AACH,SAAS,uBAAuB,CAC9B,QAAyB;IAEzB,OAAO;QACL,SAAS,EAAE,QAAQ,CAAC,eAAe;QACnC,cAAc,EAAE,QAAQ,CAAC,kBAAkB;QAC3C,SAAS,EAAE,QAAQ,CAAC,kBAAkB;QACtC,MAAM,EAAE,QAAQ,CAAC,MAAM;QACvB,qBAAqB,EAAE,QAAQ,CAAC,KAAK,CAAC,SAAS;QAC/C,kBAAkB,EAAE,QAAQ,CAAC,KAAK,CAAC,MAAM;QACzC,sBAAsB,EA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AE;gBACvE,WAAW,EAAE,IAAI,CAAC,OAAO,CAAC,WAAW;gBACrC,cAAc,EAAE,IAAI,CAAC,OAAO,CAAC,cAAc;gBAC3C,iBAAiB,EAAE,IAAI,CAAC,OAAO,CAAC,iBAAiB;gBACjD,UAAU,EAAE,IAAI,CAAC,OAAO,CAAC,UAAU;gBACnC,iBAAiB,EAAE,IAAI,CAAC,OAAO,CAAC,iBAAiB;aAClD,CAAC,CAAC;YACH,oDAAoD;YACpD,yDAAyD;YACzD,gDAAgD;YAChD,2CAA2C;YAC3C,MAAM;YACN,KAAK,CAAC,MAAM,GAAG,aAAa,CAAC;YAC7B,KAAK,CAAC,WAAW,GAAG,IAAI,CAAC;SAC1B;QAED,IAAI,OAAO,OAAO,CAAC,YAAY,KAAK,UAAU,EAAE;YAC9C,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;SAC7B;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,MAAM;QACV,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QACzB,MAAM,CAAC,OAAO,CAAC,iEAAiE,CAAC,CAAC;QAClF,KAAK,CAAC,WAAW,GAAG,IAAI,CAAC;QACzB,OAAO,IAAI,CAAC;IACd,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { OperationOptions } from \"@azure/core-client\";\n\nimport { AbortSignalLike } from \"@azure/abort-controller\";\n\nimport {\n AnalyzeStatusOptionalParams as AnalyzeActionsOperationStatusOptions,\n AnalyzeJobState,\n AnalyzeResponse as BeginAnalyzeResponse,\n JobManifestTasks as GeneratedActions,\n TextDocumentBatchStatistics,\n TextDocumentInput,\n} from \"../../generated/models\";\nimport {\n AnalyzeActionsResult,\n PagedAnalyzeActionsResult,\n PagedAsyncIterableAnalyzeActionsResult,\n createAnalyzeActionsResult,\n} from \"../../analyzeActionsResult\";\nimport { PageSettings } from \"@azure/core-paging\";\nimport { getOperationId, nextLinkToTopAndSkip, throwError } from \"../../util\";\nimport { AnalysisPollOperation, AnalysisPollOperationState, OperationMetadata } from \"../poller\";\nimport { GeneratedClient as Client } from \"../../generated\";\nimport { logger } from \"../../logger\";\nimport { TracingClient } from \"@azure/core-tracing\";\n\n/**\n * @internal\n */\ninterface AnalyzeResultsWithPagination {\n result: AnalyzeActionsResult;\n top?: number;\n skip?: number;\n}\n\n/**\n * The metadata for beginAnalyzeActions operations.\n */\nexport interface AnalyzeActionsOperationMetadata extends OperationMetadata {\n /**\n * Number of successfully completed actions.\n */\n actionsSucceededCount: number;\n /**\n * Number of failed actions.\n */\n actionsFailedCount: number;\n /**\n * Number of actions still in progress.\n */\n actionsInProgressCount: number;\n /**\n * The operation's display name.\n */\n displayName?: string;\n}\n\n/**\n * @internal\n */\ninterface AnalyzeActionsOperationStatus {\n done: boolean;\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 operationMetdata: Omit<AnalyzeActionsOperationMetadata, \"operationId\">;\n}\n\n/**\n * @internal\n */\ninterface BeginAnalyzeInternalOptions extends OperationOptions {\n displayName?: string;\n}\n\n/**\n * Options for the begin analyze actions operation.\n */\nexport interface BeginAnalyzeActionsOptions extends OperationOptions {\n /**\n * Delay to wait until next poll, in milliseconds.\n */\n updateIntervalInMs?: number;\n /**\n * A serialized poller which can be used to resume an existing paused Long-Running-Operation.\n */\n resumeFrom?: string;\n /**\n * If set to true, response will contain input and document level statistics.\n */\n includeStatistics?: boolean;\n /**\n * The operation's display name.\n */\n displayName?: string;\n}\n\n/**\n * The state of the begin analyze polling operation.\n */\nexport interface AnalyzeActionsOperationState\n extends AnalysisPollOperationState<PagedAnalyzeActionsResult>,\n AnalyzeActionsOperationMetadata {}\n\n/**\n * @internal\n */\nfunction getMetaInfoFromResponse(\n response: AnalyzeJobState,\n): Omit<AnalyzeActionsOperationMetadata, \"operationId\"> {\n return {\n createdOn: response.createdDateTime,\n lastModifiedOn: response.lastUpdateDateTime,\n expiresOn: response.expirationDateTime,\n status: response.status,\n actionsSucceededCount: response.tasks.completed,\n actionsFailedCount: response.tasks.failed,\n actionsInProgressCount: response.tasks.inProgress,\n displayName: response.displayName,\n };\n}\n\n/**\n * Class that represents a poller that waits for results of the analyze\n * operation.\n * @internal\n */\nexport class BeginAnalyzeActionsPollerOperation extends AnalysisPollOperation<\n AnalyzeActionsOperationState,\n PagedAnalyzeActionsResult\n> {\n constructor(\n public state: AnalyzeActionsOperationState,\n // eslint-disable-next-line @azure/azure-sdk/ts-use-interface-parameters\n private client: Client,\n private tracing: TracingClient,\n private documents: TextDocumentInput[],\n private actions: GeneratedActions,\n private options: BeginAnalyzeActionsOptions = {},\n ) {\n super(state);\n }\n\n /**\n * should be called only after all the status of the analyze actions operations became\n * \"succeeded\" and it returns an iterator for the results and provides a\n * byPage method to return the results paged.\n */\n private listAnalyzeActionsResults(\n operationId: string,\n options: AnalyzeActionsOperationStatusOptions = {},\n ): PagedAsyncIterableAnalyzeActionsResult {\n const iter = this._listAnalyzeActionsResultsPaged(operationId, options);\n return {\n next() {\n return iter.next();\n },\n [Symbol.asyncIterator]() {\n return this;\n },\n byPage: (settings?: PageSettings) => {\n const pageOptions = { ...options, top: settings?.maxPageSize };\n return this._listAnalyzeActionsResultsPaged(operationId, pageOptions);\n },\n };\n }\n\n /**\n * returns an iterator to arrays of the results of an analyze actions operation.\n */\n private async *_listAnalyzeActionsResultsPaged(\n operationId: string,\n options?: AnalyzeActionsOperationStatusOptions,\n ): AsyncIterableIterator<AnalyzeActionsResult> {\n let response = await this._listAnalyzeActionsResultsSinglePage(operationId, options);\n yield response.result;\n while (response.skip) {\n const optionsWithContinuation: AnalyzeActionsOperationStatusOptions = {\n ...options,\n top: response.top,\n skip: response.skip,\n };\n response = await this._listAnalyzeActionsResultsSinglePage(\n operationId,\n optionsWithContinuation,\n );\n yield response.result;\n }\n }\n\n /**\n * returns an iterator to arrays of the sorted results of an analyze actions operation.\n */\n private async _listAnalyzeActionsResultsSinglePage(\n operationId: string,\n options?: AnalyzeActionsOperationStatusOptions,\n ): Promise<AnalyzeResultsWithPagination> {\n const response = await this.tracing.withSpan(\n \"TextAnalyticsClient-_listAnalyzeActionsResultsSinglePage\",\n options || {},\n (finalOptions) => this.client.analyzeStatus(operationId, finalOptions),\n );\n const result = createAnalyzeActionsResult(response, this.documents);\n return response.nextLink ? { result, ...nextLinkToTopAndSkip(response.nextLink) } : { result };\n }\n\n /**\n * returns whether the analyze actions operation is done and if so returns also\n * statistics.\n */\n private async getAnalyzeActionsOperationStatus(\n operationId: string,\n options?: AnalyzeActionsOperationStatusOptions,\n ): Promise<AnalyzeActionsOperationStatus> {\n const response = await this.tracing.withSpan(\n \"TextAnalyticsClient-getAnalyzeActionsOperationStatus\",\n options || {},\n (finalOptions) => this.client.analyzeStatus(operationId, finalOptions),\n );\n switch (response.status) {\n case \"notStarted\":\n case \"running\":\n break;\n default: {\n return {\n done: true,\n statistics: response.statistics,\n operationMetdata: getMetaInfoFromResponse(response),\n };\n }\n }\n return { done: false, operationMetdata: getMetaInfoFromResponse(response) };\n }\n\n private async beginAnalyzeActions(\n documents: TextDocumentInput[],\n actions: GeneratedActions,\n options?: BeginAnalyzeInternalOptions,\n ): Promise<BeginAnalyzeResponse> {\n return this.tracing.withSpan(\n \"TextAnalyticsClient-beginAnalyze\",\n options || {},\n (finalOptions) =>\n throwError(\n this.client.analyze({\n body: {\n analysisInput: { documents: documents },\n tasks: actions,\n displayName: options?.displayName,\n },\n ...finalOptions,\n }),\n ),\n );\n }\n\n async update(\n options: {\n abortSignal?: AbortSignalLike;\n fireProgress?: (state: AnalyzeActionsOperationState) => void;\n } = {},\n ): Promise<BeginAnalyzeActionsPollerOperation> {\n const state = this.state;\n const updatedAbortSignal = options.abortSignal;\n if (!state.isStarted) {\n state.isStarted = true;\n const response = await this.beginAnalyzeActions(this.documents, this.actions, {\n displayName: this.options.displayName,\n tracingOptions: this.options.tracingOptions,\n requestOptions: this.options.requestOptions,\n abortSignal: updatedAbortSignal ? updatedAbortSignal : this.options.abortSignal,\n });\n if (!response.operationLocation) {\n throw new Error(\n \"Expects a valid 'operationLocation' to retrieve analyze results but did not find any\",\n );\n }\n state.operationId = getOperationId(response.operationLocation);\n }\n\n const operationStatus = await this.getAnalyzeActionsOperationStatus(state.operationId!, {\n abortSignal: updatedAbortSignal ? updatedAbortSignal : options.abortSignal,\n includeStatistics: this.options.includeStatistics,\n tracingOptions: this.options.tracingOptions,\n });\n\n state.createdOn = operationStatus.operationMetdata.createdOn;\n state.expiresOn = operationStatus.operationMetdata.expiresOn;\n state.lastModifiedOn = operationStatus.operationMetdata.lastModifiedOn;\n state.status = operationStatus.operationMetdata.status;\n state.actionsSucceededCount = operationStatus.operationMetdata.actionsSucceededCount;\n state.actionsFailedCount = operationStatus.operationMetdata.actionsFailedCount;\n state.actionsInProgressCount = operationStatus.operationMetdata.actionsInProgressCount;\n state.displayName = operationStatus.operationMetdata?.displayName;\n\n if (!state.isCompleted && operationStatus.done) {\n const pagedIterator = this.listAnalyzeActionsResults(state.operationId!, {\n abortSignal: this.options.abortSignal,\n tracingOptions: this.options.tracingOptions,\n includeStatistics: this.options.includeStatistics,\n onResponse: this.options.onResponse,\n serializerOptions: this.options.serializerOptions,\n });\n // Attach stats if the service starts to return them\n // https://github.com/Azure/azure-sdk-for-js/issues/14139\n // state.result = Object.assign(pagedIterator, {\n // statistics: operationStatus.statistics\n // });\n state.result = pagedIterator;\n state.isCompleted = true;\n }\n\n if (typeof options.fireProgress === \"function\") {\n options.fireProgress(state);\n }\n return this;\n }\n\n async cancel(): Promise<BeginAnalyzeActionsPollerOperation> {\n const state = this.state;\n logger.warning(`The service does not yet support cancellation for beginAnalyze.`);\n state.isCancelled = true;\n return this;\n }\n}\n"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// Copyright (c) Microsoft Corporation.
|
|
2
2
|
// Licensed under the MIT license.
|
|
3
|
+
import { __asyncDelegator, __asyncGenerator, __asyncValues, __await } from "tslib";
|
|
3
4
|
import { makeHealthcareEntitiesErrorResult, makeHealthcareEntitiesResult, } from "../../analyzeHealthcareEntitiesResult";
|
|
4
5
|
import { addStrEncodingParam, getOperationId, nextLinkToTopAndSkip, throwError, } from "../../util";
|
|
5
6
|
import { AnalysisPollOperation, } from "../poller";
|
|
@@ -45,7 +46,7 @@ export class BeginAnalyzeHealthcarePollerOperation extends AnalysisPollOperation
|
|
|
45
46
|
return this;
|
|
46
47
|
},
|
|
47
48
|
byPage: (settings) => {
|
|
48
|
-
const pageOptions = {
|
|
49
|
+
const pageOptions = Object.assign(Object.assign({}, options), { top: settings === null || settings === void 0 ? void 0 : settings.maxPageSize });
|
|
49
50
|
return this._listHealthcareEntitiesPaged(operationId, pageOptions);
|
|
50
51
|
},
|
|
51
52
|
};
|
|
@@ -53,26 +54,39 @@ export class BeginAnalyzeHealthcarePollerOperation extends AnalysisPollOperation
|
|
|
53
54
|
/**
|
|
54
55
|
* returns an iterator to the results of a healthcare operation.
|
|
55
56
|
*/
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
57
|
+
_listHealthcareEntities(operationId, options) {
|
|
58
|
+
return __asyncGenerator(this, arguments, function* _listHealthcareEntities_1() {
|
|
59
|
+
var _a, e_1, _b, _c;
|
|
60
|
+
try {
|
|
61
|
+
for (var _d = true, _e = __asyncValues(this._listHealthcareEntitiesPaged(operationId, options)), _f; _f = yield __await(_e.next()), _a = _f.done, !_a; _d = true) {
|
|
62
|
+
_c = _f.value;
|
|
63
|
+
_d = false;
|
|
64
|
+
const page = _c;
|
|
65
|
+
yield __await(yield* __asyncDelegator(__asyncValues(page)));
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
69
|
+
finally {
|
|
70
|
+
try {
|
|
71
|
+
if (!_d && !_a && (_b = _e.return)) yield __await(_b.call(_e));
|
|
72
|
+
}
|
|
73
|
+
finally { if (e_1) throw e_1.error; }
|
|
74
|
+
}
|
|
75
|
+
});
|
|
60
76
|
}
|
|
61
77
|
/**
|
|
62
78
|
* returns an iterator to arrays of the results of a healthcare operation.
|
|
63
79
|
*/
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
yield response.result;
|
|
75
|
-
}
|
|
80
|
+
_listHealthcareEntitiesPaged(operationId, options) {
|
|
81
|
+
return __asyncGenerator(this, arguments, function* _listHealthcareEntitiesPaged_1() {
|
|
82
|
+
let response = yield __await(this._listHealthcareEntitiesSinglePage(operationId, options));
|
|
83
|
+
yield yield __await(response.result);
|
|
84
|
+
while (response.skip) {
|
|
85
|
+
const optionsWithContinuation = Object.assign(Object.assign({}, options), { top: response.top, skip: response.skip });
|
|
86
|
+
response = yield __await(this._listHealthcareEntitiesSinglePage(operationId, optionsWithContinuation));
|
|
87
|
+
yield yield __await(response.result);
|
|
88
|
+
}
|
|
89
|
+
});
|
|
76
90
|
}
|
|
77
91
|
/**
|
|
78
92
|
* returns an iterator to arrays of the sorted results of a healthcare operation.
|
|
@@ -82,8 +96,7 @@ export class BeginAnalyzeHealthcarePollerOperation extends AnalysisPollOperation
|
|
|
82
96
|
if (response.results) {
|
|
83
97
|
const result = processAndCombineSuccessfulAndErroneousDocuments(this.documents, response.results, makeHealthcareEntitiesResult, makeHealthcareEntitiesErrorResult);
|
|
84
98
|
return response.nextLink
|
|
85
|
-
? { result,
|
|
86
|
-
: { result };
|
|
99
|
+
? Object.assign({ result }, nextLinkToTopAndSkip(response.nextLink)) : { result };
|
|
87
100
|
}
|
|
88
101
|
else {
|
|
89
102
|
throw new Error("Healthcare action has succeeded but the there are no results!");
|
|
@@ -94,15 +107,14 @@ export class BeginAnalyzeHealthcarePollerOperation extends AnalysisPollOperation
|
|
|
94
107
|
* statistics and the model version used.
|
|
95
108
|
*/
|
|
96
109
|
async getHealthStatus(operationId, options) {
|
|
110
|
+
var _a;
|
|
97
111
|
const response = await this.tracing.withSpan("TextAnalyticsClient-getHealthStatus", options || {}, (finalOptions) => this.client.healthStatus(operationId, finalOptions));
|
|
98
112
|
switch (response.status) {
|
|
99
113
|
case "notStarted":
|
|
100
114
|
case "running":
|
|
101
115
|
break;
|
|
102
116
|
case "failed": {
|
|
103
|
-
const errors = response.errors
|
|
104
|
-
?.map((e) => ` code ${e.code}, message: '${e.message}'`)
|
|
105
|
-
.join("\n");
|
|
117
|
+
const errors = (_a = response.errors) === null || _a === void 0 ? void 0 : _a.map((e) => ` code ${e.code}, message: '${e.message}'`).join("\n");
|
|
106
118
|
const message = `Healthcare analysis failed. Error(s): ${errors || ""}`;
|
|
107
119
|
throw new Error(message);
|
|
108
120
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operation.js","sourceRoot":"","sources":["../../../../src/lro/health/operation.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAYlC,OAAO,EAKL,iCAAiC,EACjC,4BAA4B,GAC7B,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EAEL,mBAAmB,EACnB,cAAc,EACd,oBAAoB,EACpB,UAAU,GACX,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,qBAAqB,GAGtB,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,gDAAgD,EAAE,MAAM,2BAA2B,CAAC;AAiF7F;;GAEG;AACH,SAAS,uBAAuB,CAC9B,QAA4B;IAE5B,OAAO;QACL,SAAS,EAAE,QAAQ,CAAC,eAAe;QACnC,cAAc,EAAE,QAAQ,CAAC,kBAAkB;QAC3C,SAAS,EAAE,QAAQ,CAAC,kBAAkB;QACtC,MAAM,EAAE,QAAQ,CAAC,MAAM;KACxB,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,OAAO,qCAAsC,SAAQ,qBAG1D;IACC,YACS,KAAsC;I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,IAAI,CAAC;QACzB,OAAO,IAAI,CAAC;IACd,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { AbortSignalLike } from \"@azure/abort-controller\";\nimport { OperationOptions } from \"@azure/core-client\";\n\nimport {\n HealthResponse as BeginAnalyzeHealthcareResponse,\n HealthcareJobState,\n HealthStatusOptionalParams as HealthcareJobStatusOptions,\n TextDocumentBatchStatistics,\n TextDocumentInput,\n} from \"../../generated/models\";\nimport {\n AnalyzeHealthcareEntitiesResult,\n AnalyzeHealthcareEntitiesResultArray,\n PagedAnalyzeHealthcareEntitiesResult,\n PagedAsyncIterableAnalyzeHealthcareEntitiesResult,\n makeHealthcareEntitiesErrorResult,\n makeHealthcareEntitiesResult,\n} from \"../../analyzeHealthcareEntitiesResult\";\nimport { PageSettings } from \"@azure/core-paging\";\nimport {\n StringIndexType,\n addStrEncodingParam,\n getOperationId,\n nextLinkToTopAndSkip,\n throwError,\n} from \"../../util\";\nimport {\n AnalysisPollOperation,\n AnalysisPollOperationState,\n OperationMetadata as AnalyzeHealthcareEntitiesOperationMetadata,\n} from \"../poller\";\nimport { GeneratedClient as Client } from \"../../generated\";\nimport { processAndCombineSuccessfulAndErroneousDocuments } from \"../../textAnalyticsResult\";\nimport { TextAnalyticsOperationOptions } from \"../../textAnalyticsOperationOptions\";\nimport { TracingClient } from \"@azure/core-tracing\";\n\n/**\n * @internal\n */\ninterface AnalyzeHealthcareEntitiesResultWithPagination {\n result: AnalyzeHealthcareEntitiesResultArray;\n top?: number;\n skip?: number;\n}\n\n/**\n * @internal\n */\ninterface HealthcareJobStatus {\n done: boolean;\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 operationMetdata: Omit<AnalyzeHealthcareEntitiesOperationMetadata, \"operationId\">;\n}\n\n/**\n * @internal\n */\ninterface BeginAnalyzeHealthcareInternalOptions extends OperationOptions {\n /**\n * This value indicates which model will be used for scoring. If a model-version is\n * not specified, the API should default to the latest, non-preview version.\n * For supported model versions, see operation-specific documentation, for example:\n * https://docs.microsoft.com/azure/cognitive-services/text-analytics/how-tos/text-analytics-how-to-sentiment-analysis#model-versioning\n */\n modelVersion?: string;\n /**\n * Specifies the measurement unit used to calculate the offset and length properties.\n * Possible units are \"TextElements_v8\", \"UnicodeCodePoint\", and \"Utf16CodeUnit\".\n * The default is the JavaScript's default which is \"Utf16CodeUnit\".\n */\n stringIndexType?: StringIndexType;\n /**\n * If set to false, you opt-in to have your text input logged for troubleshooting. By default, Text Analytics\n * will not log your input text for healthcare entities analysis. Setting this parameter to false,\n * enables input logging.\n */\n loggingOptOut?: boolean;\n}\n\n/**\n * Options for the begin analyze healthcare entities operation.\n */\nexport interface BeginAnalyzeHealthcareEntitiesOptions extends TextAnalyticsOperationOptions {\n /**\n * Delay to wait until next poll, in milliseconds.\n */\n stringIndexType?: StringIndexType;\n /**\n * Delay to wait until next poll, in milliseconds.\n */\n updateIntervalInMs?: number;\n /**\n * A serialized poller which can be used to resume an existing paused Long-Running-Operation.\n */\n resumeFrom?: string;\n}\n\n/**\n * The state of the begin analyze healthcare polling operation.\n */\nexport interface AnalyzeHealthcareOperationState\n extends AnalysisPollOperationState<PagedAnalyzeHealthcareEntitiesResult> {}\n\n/**\n * @internal\n */\nfunction getMetaInfoFromResponse(\n response: HealthcareJobState,\n): Omit<AnalyzeHealthcareEntitiesOperationMetadata, \"operationId\"> {\n return {\n createdOn: response.createdDateTime,\n lastModifiedOn: response.lastUpdateDateTime,\n expiresOn: response.expirationDateTime,\n status: response.status,\n };\n}\n\n/**\n * Class that represents a poller that waits for the healthcare results.\n * @internal\n */\nexport class BeginAnalyzeHealthcarePollerOperation extends AnalysisPollOperation<\n AnalyzeHealthcareOperationState,\n PagedAnalyzeHealthcareEntitiesResult\n> {\n constructor(\n public state: AnalyzeHealthcareOperationState,\n // eslint-disable-next-line @azure/azure-sdk/ts-use-interface-parameters\n private client: Client,\n private tracing: TracingClient,\n private documents: TextDocumentInput[],\n private options: BeginAnalyzeHealthcareEntitiesOptions = {},\n ) {\n super(state);\n }\n\n /**\n * should be called only after all the status of the healthcare operations became\n * \"succeeded\" and it returns an iterator for the results and provides a\n * byPage method to return the results paged.\n */\n private listHealthcareEntitiesByPage(\n operationId: string,\n options: HealthcareJobStatusOptions = {},\n ): PagedAsyncIterableAnalyzeHealthcareEntitiesResult {\n const iter = this._listHealthcareEntities(operationId, options);\n return {\n next() {\n return iter.next();\n },\n [Symbol.asyncIterator]() {\n return this;\n },\n byPage: (settings?: PageSettings) => {\n const pageOptions = { ...options, top: settings?.maxPageSize };\n return this._listHealthcareEntitiesPaged(operationId, pageOptions);\n },\n };\n }\n\n /**\n * returns an iterator to the results of a healthcare operation.\n */\n private async *_listHealthcareEntities(\n operationId: string,\n options?: HealthcareJobStatusOptions,\n ): AsyncIterableIterator<AnalyzeHealthcareEntitiesResult> {\n for await (const page of this._listHealthcareEntitiesPaged(operationId, options)) {\n yield* page;\n }\n }\n\n /**\n * returns an iterator to arrays of the results of a healthcare operation.\n */\n private async *_listHealthcareEntitiesPaged(\n operationId: string,\n options?: HealthcareJobStatusOptions,\n ): AsyncIterableIterator<AnalyzeHealthcareEntitiesResultArray> {\n let response = await this._listHealthcareEntitiesSinglePage(operationId, options);\n yield response.result;\n while (response.skip) {\n const optionsWithContinuation: HealthcareJobStatusOptions = {\n ...options,\n top: response.top,\n skip: response.skip,\n };\n response = await this._listHealthcareEntitiesSinglePage(operationId, optionsWithContinuation);\n yield response.result;\n }\n }\n\n /**\n * returns an iterator to arrays of the sorted results of a healthcare operation.\n */\n private async _listHealthcareEntitiesSinglePage(\n operationId: string,\n options?: HealthcareJobStatusOptions,\n ): Promise<AnalyzeHealthcareEntitiesResultWithPagination> {\n const response = await this.tracing.withSpan(\n \"TextAnalyticsClient-_listHealthcareEntitiesSinglePage\",\n options || {},\n (finalOptions) => this.client.healthStatus(operationId, finalOptions),\n );\n if (response.results) {\n const result = processAndCombineSuccessfulAndErroneousDocuments(\n this.documents,\n response.results,\n makeHealthcareEntitiesResult,\n makeHealthcareEntitiesErrorResult,\n );\n return response.nextLink\n ? { result, ...nextLinkToTopAndSkip(response.nextLink) }\n : { result };\n } else {\n throw new Error(\"Healthcare action has succeeded but the there are no results!\");\n }\n }\n\n /**\n * returns whether the healthcare operation is done and if so returns also\n * statistics and the model version used.\n */\n private async getHealthStatus(\n operationId: string,\n options?: HealthcareJobStatusOptions,\n ): Promise<HealthcareJobStatus> {\n const response = await this.tracing.withSpan(\n \"TextAnalyticsClient-getHealthStatus\",\n options || {},\n (finalOptions) => this.client.healthStatus(operationId, finalOptions),\n );\n switch (response.status) {\n case \"notStarted\":\n case \"running\":\n break;\n case \"failed\": {\n const errors = response.errors\n ?.map((e) => ` code ${e.code}, message: '${e.message}'`)\n .join(\"\\n\");\n const message = `Healthcare analysis failed. Error(s): ${errors || \"\"}`;\n throw new Error(message);\n }\n default: {\n if (response.results) {\n return {\n done: true,\n statistics: response.results.statistics,\n modelVersion: response.results.modelVersion,\n operationMetdata: getMetaInfoFromResponse(response),\n };\n } else {\n throw new Error(\"Healthcare action has finished but the there are no results!\");\n }\n }\n }\n return { done: false, operationMetdata: getMetaInfoFromResponse(response) };\n }\n\n private async beginAnalyzeHealthcare(\n documents: TextDocumentInput[],\n options?: BeginAnalyzeHealthcareInternalOptions,\n ): Promise<BeginAnalyzeHealthcareResponse> {\n return this.tracing.withSpan(\n \"TextAnalyticsClient-beginAnalyzeHealthcare\",\n addStrEncodingParam(options || {}),\n (finalOptions) => throwError(this.client.health({ documents: documents }, finalOptions)),\n );\n }\n\n async update(\n options: {\n abortSignal?: AbortSignalLike;\n fireProgress?: (state: AnalyzeHealthcareOperationState) => void;\n } = {},\n ): Promise<BeginAnalyzeHealthcarePollerOperation> {\n const state = this.state;\n const updatedAbortSignal = options.abortSignal;\n if (!state.isStarted) {\n state.isStarted = true;\n const response = await this.beginAnalyzeHealthcare(this.documents, {\n requestOptions: this.options.requestOptions,\n tracingOptions: this.options.tracingOptions,\n abortSignal: updatedAbortSignal ? updatedAbortSignal : options.abortSignal,\n modelVersion: this.options.modelVersion,\n stringIndexType: this.options.stringIndexType,\n loggingOptOut: this.options.disableServiceLogs,\n });\n if (!response.operationLocation) {\n throw new Error(\n \"Expects a valid 'operationLocation' to retrieve health results but did not find any\",\n );\n }\n state.operationId = getOperationId(response.operationLocation);\n }\n const operationStatus = await this.getHealthStatus(state.operationId!, {\n abortSignal: updatedAbortSignal ? updatedAbortSignal : options.abortSignal,\n includeStatistics: this.options.includeStatistics,\n tracingOptions: this.options.tracingOptions,\n onResponse: this.options.onResponse,\n serializerOptions: this.options.serializerOptions,\n });\n\n state.createdOn = operationStatus.operationMetdata.createdOn;\n state.expiresOn = operationStatus.operationMetdata.expiresOn;\n state.lastModifiedOn = operationStatus.operationMetdata.lastModifiedOn;\n state.status = operationStatus.operationMetdata.status;\n\n if (!state.isCompleted && operationStatus.done) {\n const pagedIterator = this.listHealthcareEntitiesByPage(state.operationId!, {\n abortSignal: this.options.abortSignal,\n tracingOptions: this.options.tracingOptions,\n });\n state.result = Object.assign(pagedIterator, {\n statistics: operationStatus.statistics,\n modelVersion: operationStatus.modelVersion!,\n });\n state.isCompleted = true;\n }\n if (typeof options.fireProgress === \"function\") {\n options.fireProgress(state);\n }\n return this;\n }\n\n async cancel(): Promise<BeginAnalyzeHealthcarePollerOperation> {\n const state = this.state;\n if (state.operationId) {\n await this.client.cancelHealthJob(state.operationId, {\n abortSignal: this.options.abortSignal,\n tracingOptions: this.options.tracingOptions,\n });\n }\n state.isCancelled = true;\n return this;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"operation.js","sourceRoot":"","sources":["../../../../src/lro/health/operation.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;AAYlC,OAAO,EAKL,iCAAiC,EACj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,CAAC,MAAM,CAAC,aAAa,EAAE;gBAC1C,UAAU,EAAE,eAAe,CAAC,UAAU;gBACtC,YAAY,EAAE,eAAe,CAAC,YAAa;aAC5C,CAAC,CAAC;YACH,KAAK,CAAC,WAAW,GAAG,IAAI,CAAC;SAC1B;QACD,IAAI,OAAO,OAAO,CAAC,YAAY,KAAK,UAAU,EAAE;YAC9C,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;SAC7B;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,MAAM;QACV,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QACzB,IAAI,KAAK,CAAC,WAAW,EAAE;YACrB,MAAM,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,KAAK,CAAC,WAAW,EAAE;gBACnD,WAAW,EAAE,IAAI,CAAC,OAAO,CAAC,WAAW;gBACrC,cAAc,EAAE,IAAI,CAAC,OAAO,CAAC,cAAc;aAC5C,CAAC,CAAC;SACJ;QACD,KAAK,CAAC,WAAW,GAAG,IAAI,CAAC;QACzB,OAAO,IAAI,CAAC;IACd,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { AbortSignalLike } from \"@azure/abort-controller\";\nimport { OperationOptions } from \"@azure/core-client\";\n\nimport {\n HealthResponse as BeginAnalyzeHealthcareResponse,\n HealthcareJobState,\n HealthStatusOptionalParams as HealthcareJobStatusOptions,\n TextDocumentBatchStatistics,\n TextDocumentInput,\n} from \"../../generated/models\";\nimport {\n AnalyzeHealthcareEntitiesResult,\n AnalyzeHealthcareEntitiesResultArray,\n PagedAnalyzeHealthcareEntitiesResult,\n PagedAsyncIterableAnalyzeHealthcareEntitiesResult,\n makeHealthcareEntitiesErrorResult,\n makeHealthcareEntitiesResult,\n} from \"../../analyzeHealthcareEntitiesResult\";\nimport { PageSettings } from \"@azure/core-paging\";\nimport {\n StringIndexType,\n addStrEncodingParam,\n getOperationId,\n nextLinkToTopAndSkip,\n throwError,\n} from \"../../util\";\nimport {\n AnalysisPollOperation,\n AnalysisPollOperationState,\n OperationMetadata as AnalyzeHealthcareEntitiesOperationMetadata,\n} from \"../poller\";\nimport { GeneratedClient as Client } from \"../../generated\";\nimport { processAndCombineSuccessfulAndErroneousDocuments } from \"../../textAnalyticsResult\";\nimport { TextAnalyticsOperationOptions } from \"../../textAnalyticsOperationOptions\";\nimport { TracingClient } from \"@azure/core-tracing\";\n\n/**\n * @internal\n */\ninterface AnalyzeHealthcareEntitiesResultWithPagination {\n result: AnalyzeHealthcareEntitiesResultArray;\n top?: number;\n skip?: number;\n}\n\n/**\n * @internal\n */\ninterface HealthcareJobStatus {\n done: boolean;\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 operationMetdata: Omit<AnalyzeHealthcareEntitiesOperationMetadata, \"operationId\">;\n}\n\n/**\n * @internal\n */\ninterface BeginAnalyzeHealthcareInternalOptions extends OperationOptions {\n /**\n * This value indicates which model will be used for scoring. If a model-version is\n * not specified, the API should default to the latest, non-preview version.\n * For supported model versions, see operation-specific documentation, for example:\n * https://docs.microsoft.com/azure/cognitive-services/text-analytics/how-tos/text-analytics-how-to-sentiment-analysis#model-versioning\n */\n modelVersion?: string;\n /**\n * Specifies the measurement unit used to calculate the offset and length properties.\n * Possible units are \"TextElements_v8\", \"UnicodeCodePoint\", and \"Utf16CodeUnit\".\n * The default is the JavaScript's default which is \"Utf16CodeUnit\".\n */\n stringIndexType?: StringIndexType;\n /**\n * If set to false, you opt-in to have your text input logged for troubleshooting. By default, Text Analytics\n * will not log your input text for healthcare entities analysis. Setting this parameter to false,\n * enables input logging.\n */\n loggingOptOut?: boolean;\n}\n\n/**\n * Options for the begin analyze healthcare entities operation.\n */\nexport interface BeginAnalyzeHealthcareEntitiesOptions extends TextAnalyticsOperationOptions {\n /**\n * Delay to wait until next poll, in milliseconds.\n */\n stringIndexType?: StringIndexType;\n /**\n * Delay to wait until next poll, in milliseconds.\n */\n updateIntervalInMs?: number;\n /**\n * A serialized poller which can be used to resume an existing paused Long-Running-Operation.\n */\n resumeFrom?: string;\n}\n\n/**\n * The state of the begin analyze healthcare polling operation.\n */\nexport interface AnalyzeHealthcareOperationState\n extends AnalysisPollOperationState<PagedAnalyzeHealthcareEntitiesResult> {}\n\n/**\n * @internal\n */\nfunction getMetaInfoFromResponse(\n response: HealthcareJobState,\n): Omit<AnalyzeHealthcareEntitiesOperationMetadata, \"operationId\"> {\n return {\n createdOn: response.createdDateTime,\n lastModifiedOn: response.lastUpdateDateTime,\n expiresOn: response.expirationDateTime,\n status: response.status,\n };\n}\n\n/**\n * Class that represents a poller that waits for the healthcare results.\n * @internal\n */\nexport class BeginAnalyzeHealthcarePollerOperation extends AnalysisPollOperation<\n AnalyzeHealthcareOperationState,\n PagedAnalyzeHealthcareEntitiesResult\n> {\n constructor(\n public state: AnalyzeHealthcareOperationState,\n // eslint-disable-next-line @azure/azure-sdk/ts-use-interface-parameters\n private client: Client,\n private tracing: TracingClient,\n private documents: TextDocumentInput[],\n private options: BeginAnalyzeHealthcareEntitiesOptions = {},\n ) {\n super(state);\n }\n\n /**\n * should be called only after all the status of the healthcare operations became\n * \"succeeded\" and it returns an iterator for the results and provides a\n * byPage method to return the results paged.\n */\n private listHealthcareEntitiesByPage(\n operationId: string,\n options: HealthcareJobStatusOptions = {},\n ): PagedAsyncIterableAnalyzeHealthcareEntitiesResult {\n const iter = this._listHealthcareEntities(operationId, options);\n return {\n next() {\n return iter.next();\n },\n [Symbol.asyncIterator]() {\n return this;\n },\n byPage: (settings?: PageSettings) => {\n const pageOptions = { ...options, top: settings?.maxPageSize };\n return this._listHealthcareEntitiesPaged(operationId, pageOptions);\n },\n };\n }\n\n /**\n * returns an iterator to the results of a healthcare operation.\n */\n private async *_listHealthcareEntities(\n operationId: string,\n options?: HealthcareJobStatusOptions,\n ): AsyncIterableIterator<AnalyzeHealthcareEntitiesResult> {\n for await (const page of this._listHealthcareEntitiesPaged(operationId, options)) {\n yield* page;\n }\n }\n\n /**\n * returns an iterator to arrays of the results of a healthcare operation.\n */\n private async *_listHealthcareEntitiesPaged(\n operationId: string,\n options?: HealthcareJobStatusOptions,\n ): AsyncIterableIterator<AnalyzeHealthcareEntitiesResultArray> {\n let response = await this._listHealthcareEntitiesSinglePage(operationId, options);\n yield response.result;\n while (response.skip) {\n const optionsWithContinuation: HealthcareJobStatusOptions = {\n ...options,\n top: response.top,\n skip: response.skip,\n };\n response = await this._listHealthcareEntitiesSinglePage(operationId, optionsWithContinuation);\n yield response.result;\n }\n }\n\n /**\n * returns an iterator to arrays of the sorted results of a healthcare operation.\n */\n private async _listHealthcareEntitiesSinglePage(\n operationId: string,\n options?: HealthcareJobStatusOptions,\n ): Promise<AnalyzeHealthcareEntitiesResultWithPagination> {\n const response = await this.tracing.withSpan(\n \"TextAnalyticsClient-_listHealthcareEntitiesSinglePage\",\n options || {},\n (finalOptions) => this.client.healthStatus(operationId, finalOptions),\n );\n if (response.results) {\n const result = processAndCombineSuccessfulAndErroneousDocuments(\n this.documents,\n response.results,\n makeHealthcareEntitiesResult,\n makeHealthcareEntitiesErrorResult,\n );\n return response.nextLink\n ? { result, ...nextLinkToTopAndSkip(response.nextLink) }\n : { result };\n } else {\n throw new Error(\"Healthcare action has succeeded but the there are no results!\");\n }\n }\n\n /**\n * returns whether the healthcare operation is done and if so returns also\n * statistics and the model version used.\n */\n private async getHealthStatus(\n operationId: string,\n options?: HealthcareJobStatusOptions,\n ): Promise<HealthcareJobStatus> {\n const response = await this.tracing.withSpan(\n \"TextAnalyticsClient-getHealthStatus\",\n options || {},\n (finalOptions) => this.client.healthStatus(operationId, finalOptions),\n );\n switch (response.status) {\n case \"notStarted\":\n case \"running\":\n break;\n case \"failed\": {\n const errors = response.errors\n ?.map((e) => ` code ${e.code}, message: '${e.message}'`)\n .join(\"\\n\");\n const message = `Healthcare analysis failed. Error(s): ${errors || \"\"}`;\n throw new Error(message);\n }\n default: {\n if (response.results) {\n return {\n done: true,\n statistics: response.results.statistics,\n modelVersion: response.results.modelVersion,\n operationMetdata: getMetaInfoFromResponse(response),\n };\n } else {\n throw new Error(\"Healthcare action has finished but the there are no results!\");\n }\n }\n }\n return { done: false, operationMetdata: getMetaInfoFromResponse(response) };\n }\n\n private async beginAnalyzeHealthcare(\n documents: TextDocumentInput[],\n options?: BeginAnalyzeHealthcareInternalOptions,\n ): Promise<BeginAnalyzeHealthcareResponse> {\n return this.tracing.withSpan(\n \"TextAnalyticsClient-beginAnalyzeHealthcare\",\n addStrEncodingParam(options || {}),\n (finalOptions) => throwError(this.client.health({ documents: documents }, finalOptions)),\n );\n }\n\n async update(\n options: {\n abortSignal?: AbortSignalLike;\n fireProgress?: (state: AnalyzeHealthcareOperationState) => void;\n } = {},\n ): Promise<BeginAnalyzeHealthcarePollerOperation> {\n const state = this.state;\n const updatedAbortSignal = options.abortSignal;\n if (!state.isStarted) {\n state.isStarted = true;\n const response = await this.beginAnalyzeHealthcare(this.documents, {\n requestOptions: this.options.requestOptions,\n tracingOptions: this.options.tracingOptions,\n abortSignal: updatedAbortSignal ? updatedAbortSignal : options.abortSignal,\n modelVersion: this.options.modelVersion,\n stringIndexType: this.options.stringIndexType,\n loggingOptOut: this.options.disableServiceLogs,\n });\n if (!response.operationLocation) {\n throw new Error(\n \"Expects a valid 'operationLocation' to retrieve health results but did not find any\",\n );\n }\n state.operationId = getOperationId(response.operationLocation);\n }\n const operationStatus = await this.getHealthStatus(state.operationId!, {\n abortSignal: updatedAbortSignal ? updatedAbortSignal : options.abortSignal,\n includeStatistics: this.options.includeStatistics,\n tracingOptions: this.options.tracingOptions,\n onResponse: this.options.onResponse,\n serializerOptions: this.options.serializerOptions,\n });\n\n state.createdOn = operationStatus.operationMetdata.createdOn;\n state.expiresOn = operationStatus.operationMetdata.expiresOn;\n state.lastModifiedOn = operationStatus.operationMetdata.lastModifiedOn;\n state.status = operationStatus.operationMetdata.status;\n\n if (!state.isCompleted && operationStatus.done) {\n const pagedIterator = this.listHealthcareEntitiesByPage(state.operationId!, {\n abortSignal: this.options.abortSignal,\n tracingOptions: this.options.tracingOptions,\n });\n state.result = Object.assign(pagedIterator, {\n statistics: operationStatus.statistics,\n modelVersion: operationStatus.modelVersion!,\n });\n state.isCompleted = true;\n }\n if (typeof options.fireProgress === \"function\") {\n options.fireProgress(state);\n }\n return this;\n }\n\n async cancel(): Promise<BeginAnalyzeHealthcarePollerOperation> {\n const state = this.state;\n if (state.operationId) {\n await this.client.cancelHealthJob(state.operationId, {\n abortSignal: this.options.abortSignal,\n tracingOptions: this.options.tracingOptions,\n });\n }\n state.isCancelled = true;\n return this;\n }\n}\n"]}
|
|
@@ -6,10 +6,7 @@ import { makeTextAnalyticsErrorResult, makeTextAnalyticsSuccessResult, } from ".
|
|
|
6
6
|
*/
|
|
7
7
|
export function makeRecognizeCategorizedEntitiesResult(result) {
|
|
8
8
|
const { entities, statistics, warnings, id } = result;
|
|
9
|
-
return {
|
|
10
|
-
...makeTextAnalyticsSuccessResult(id, warnings, statistics),
|
|
11
|
-
entities,
|
|
12
|
-
};
|
|
9
|
+
return Object.assign(Object.assign({}, makeTextAnalyticsSuccessResult(id, warnings, statistics)), { entities });
|
|
13
10
|
}
|
|
14
11
|
/**
|
|
15
12
|
* @internal
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recognizeCategorizedEntitiesResult.js","sourceRoot":"","sources":["../../src/recognizeCategorizedEntitiesResult.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAGL,4BAA4B,EAC5B,8BAA8B,GAC/B,MAAM,uBAAuB,CAAC;AAgC/B;;GAEG;AACH,MAAM,UAAU,sCAAsC,CACpD,MAAwB;IAExB,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,EAAE,EAAE,GAAG,MAAM,CAAC;IACtD,
|
|
1
|
+
{"version":3,"file":"recognizeCategorizedEntitiesResult.js","sourceRoot":"","sources":["../../src/recognizeCategorizedEntitiesResult.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAGL,4BAA4B,EAC5B,8BAA8B,GAC/B,MAAM,uBAAuB,CAAC;AAgC/B;;GAEG;AACH,MAAM,UAAU,sCAAsC,CACpD,MAAwB;IAExB,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,EAAE,EAAE,GAAG,MAAM,CAAC;IACtD,uCACK,8BAA8B,CAAC,EAAE,EAAE,QAAQ,EAAE,UAAU,CAAC,KAC3D,QAAQ,IACR;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,2CAA2C,CACzD,EAAU,EACV,KAAyB;IAEzB,OAAO,4BAA4B,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;AACjD,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n TextAnalyticsErrorResult,\n TextAnalyticsSuccessResult,\n makeTextAnalyticsErrorResult,\n makeTextAnalyticsSuccessResult,\n} from \"./textAnalyticsResult\";\nimport { DocumentEntities, Entity, TextAnalyticsError } from \"./generated/models\";\n\n/**\n * An entity from text analysis with information about its categorical\n * classification.\n */\nexport interface CategorizedEntity extends Entity {}\n\n/**\n * The result of the recognize entities operation on a single document.\n */\nexport type RecognizeCategorizedEntitiesResult =\n | RecognizeCategorizedEntitiesSuccessResult\n | RecognizeCategorizedEntitiesErrorResult;\n\n/**\n * The result of the recognize entities operation on a single document, containing the collection of\n * `Entity` objects identified in that document.\n */\nexport interface RecognizeCategorizedEntitiesSuccessResult extends TextAnalyticsSuccessResult {\n /**\n * The collection of entities identified in the input document.\n */\n readonly entities: CategorizedEntity[];\n}\n\n/**\n * An error result from the recognize entities operation on a single document.\n */\nexport type RecognizeCategorizedEntitiesErrorResult = TextAnalyticsErrorResult;\n\n/**\n * @internal\n */\nexport function makeRecognizeCategorizedEntitiesResult(\n result: DocumentEntities,\n): RecognizeCategorizedEntitiesSuccessResult {\n const { entities, statistics, warnings, id } = result;\n return {\n ...makeTextAnalyticsSuccessResult(id, warnings, statistics),\n entities,\n };\n}\n\n/**\n * @internal\n */\nexport function makeRecognizeCategorizedEntitiesErrorResult(\n id: string,\n error: TextAnalyticsError,\n): RecognizeCategorizedEntitiesErrorResult {\n return makeTextAnalyticsErrorResult(id, error);\n}\n"]}
|
|
@@ -6,10 +6,7 @@ import { makeTextAnalyticsErrorResult, makeTextAnalyticsSuccessResult, } from ".
|
|
|
6
6
|
*/
|
|
7
7
|
export function makeRecognizeLinkedEntitiesResult(result) {
|
|
8
8
|
const { statistics, id, warnings, entities } = result;
|
|
9
|
-
return {
|
|
10
|
-
...makeTextAnalyticsSuccessResult(id, warnings, statistics),
|
|
11
|
-
entities,
|
|
12
|
-
};
|
|
9
|
+
return Object.assign(Object.assign({}, makeTextAnalyticsSuccessResult(id, warnings, statistics)), { entities });
|
|
13
10
|
}
|
|
14
11
|
/**
|
|
15
12
|
* @internal
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recognizeLinkedEntitiesResult.js","sourceRoot":"","sources":["../../src/recognizeLinkedEntitiesResult.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAGL,4BAA4B,EAC5B,8BAA8B,GAC/B,MAAM,uBAAuB,CAAC;AA0B/B;;GAEG;AACH,MAAM,UAAU,iCAAiC,CAC/C,MAA8B;IAE9B,MAAM,EAAE,UAAU,EAAE,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAC;IACtD,
|
|
1
|
+
{"version":3,"file":"recognizeLinkedEntitiesResult.js","sourceRoot":"","sources":["../../src/recognizeLinkedEntitiesResult.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAGL,4BAA4B,EAC5B,8BAA8B,GAC/B,MAAM,uBAAuB,CAAC;AA0B/B;;GAEG;AACH,MAAM,UAAU,iCAAiC,CAC/C,MAA8B;IAE9B,MAAM,EAAE,UAAU,EAAE,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAC;IACtD,uCACK,8BAA8B,CAAC,EAAE,EAAE,QAAQ,EAAE,UAAU,CAAC,KAC3D,QAAQ,IACR;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,sCAAsC,CACpD,EAAU,EACV,KAAyB;IAEzB,OAAO,4BAA4B,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;AACjD,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n TextAnalyticsErrorResult,\n TextAnalyticsSuccessResult,\n makeTextAnalyticsErrorResult,\n makeTextAnalyticsSuccessResult,\n} from \"./textAnalyticsResult\";\nimport { DocumentLinkedEntities, LinkedEntity, TextAnalyticsError } from \"./generated/models\";\n\n/**\n * The result of the recognize linked entities operation on a single document.\n */\nexport type RecognizeLinkedEntitiesResult =\n | RecognizeLinkedEntitiesSuccessResult\n | RecognizeLinkedEntitiesErrorResult;\n\n/**\n * The result of the recognize linked entities operation on a single document,\n * containing a collection of the `LinkedEntity` objects identified in that document.\n */\nexport interface RecognizeLinkedEntitiesSuccessResult extends TextAnalyticsSuccessResult {\n /**\n * The collection of entities identified in the input document.\n */\n readonly entities: LinkedEntity[];\n}\n\n/**\n * An error result from the recognize linked entities operation on a single document.\n */\nexport type RecognizeLinkedEntitiesErrorResult = TextAnalyticsErrorResult;\n\n/**\n * @internal\n */\nexport function makeRecognizeLinkedEntitiesResult(\n result: DocumentLinkedEntities,\n): RecognizeLinkedEntitiesSuccessResult {\n const { statistics, id, warnings, entities } = result;\n return {\n ...makeTextAnalyticsSuccessResult(id, warnings, statistics),\n entities,\n };\n}\n\n/**\n * @internal\n */\nexport function makeRecognizeLinkedEntitiesErrorResult(\n id: string,\n error: TextAnalyticsError,\n): RecognizeLinkedEntitiesErrorResult {\n return makeTextAnalyticsErrorResult(id, error);\n}\n"]}
|
|
@@ -6,11 +6,8 @@ import { makeTextAnalyticsErrorResult, makeTextAnalyticsSuccessResult, } from ".
|
|
|
6
6
|
*/
|
|
7
7
|
export function makeRecognizePiiEntitiesResult(document) {
|
|
8
8
|
const { id, entities, warnings, statistics, redactedText } = document;
|
|
9
|
-
return {
|
|
10
|
-
|
|
11
|
-
entities,
|
|
12
|
-
redactedText,
|
|
13
|
-
};
|
|
9
|
+
return Object.assign(Object.assign({}, makeTextAnalyticsSuccessResult(id, warnings, statistics)), { entities,
|
|
10
|
+
redactedText });
|
|
14
11
|
}
|
|
15
12
|
/**
|
|
16
13
|
* @internal
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recognizePiiEntitiesResult.js","sourceRoot":"","sources":["../../src/recognizePiiEntitiesResult.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAGL,4BAA4B,EAC5B,8BAA8B,GAC/B,MAAM,uBAAuB,CAAC;AAoC/B;;GAEG;AACH,MAAM,UAAU,8BAA8B,CAC5C,QAA6B;IAE7B,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,YAAY,EAAE,GAAG,QAAQ,CAAC;IACtE,
|
|
1
|
+
{"version":3,"file":"recognizePiiEntitiesResult.js","sourceRoot":"","sources":["../../src/recognizePiiEntitiesResult.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAGL,4BAA4B,EAC5B,8BAA8B,GAC/B,MAAM,uBAAuB,CAAC;AAoC/B;;GAEG;AACH,MAAM,UAAU,8BAA8B,CAC5C,QAA6B;IAE7B,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,YAAY,EAAE,GAAG,QAAQ,CAAC;IACtE,uCACK,8BAA8B,CAAC,EAAE,EAAE,QAAQ,EAAE,UAAU,CAAC,KAC3D,QAAQ;QACR,YAAY,IACZ;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,mCAAmC,CACjD,EAAU,EACV,KAAyB;IAEzB,OAAO,4BAA4B,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;AACjD,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n TextAnalyticsErrorResult,\n TextAnalyticsSuccessResult,\n makeTextAnalyticsErrorResult,\n makeTextAnalyticsSuccessResult,\n} from \"./textAnalyticsResult\";\nimport { Entity, PiiDocumentEntities, TextAnalyticsError } from \"./generated/models\";\n\n/**\n * An entity from PII recognition with information about the kind of PII\n * encountered.\n */\nexport interface PiiEntity extends Entity {}\n\n/**\n * The result of the recognize entities operation on a single document.\n */\nexport type RecognizePiiEntitiesResult =\n | RecognizePiiEntitiesSuccessResult\n | RecognizePiiEntitiesErrorResult;\n\n/**\n * The result of the recognize entities operation on a single document, containing the collection of\n * `Entity` objects identified in that document.\n */\nexport interface RecognizePiiEntitiesSuccessResult extends TextAnalyticsSuccessResult {\n /**\n * The collection of entities identified in the input document.\n */\n readonly entities: PiiEntity[];\n /**\n * The text redacted.\n */\n redactedText: string;\n}\n\n/**\n * An error result from the recognize entities operation on a single document.\n */\nexport type RecognizePiiEntitiesErrorResult = TextAnalyticsErrorResult;\n\n/**\n * @internal\n */\nexport function makeRecognizePiiEntitiesResult(\n document: PiiDocumentEntities,\n): RecognizePiiEntitiesSuccessResult {\n const { id, entities, warnings, statistics, redactedText } = document;\n return {\n ...makeTextAnalyticsSuccessResult(id, warnings, statistics),\n entities,\n redactedText,\n };\n}\n\n/**\n * @internal\n */\nexport function makeRecognizePiiEntitiesErrorResult(\n id: string,\n error: TextAnalyticsError,\n): RecognizePiiEntitiesErrorResult {\n return makeTextAnalyticsErrorResult(id, error);\n}\n"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// Copyright (c) Microsoft Corporation.
|
|
2
2
|
// Licensed under the MIT license.
|
|
3
|
+
import { __rest } from "tslib";
|
|
3
4
|
import { bearerTokenAuthenticationPolicy, } from "@azure/core-rest-pipeline";
|
|
4
5
|
import { isTokenCredential } from "@azure/core-auth";
|
|
5
6
|
import { SDK_VERSION } from "./constants";
|
|
@@ -49,7 +50,7 @@ export class TextAnalyticsClient {
|
|
|
49
50
|
*/
|
|
50
51
|
constructor(endpointUrl, credential, options = {}) {
|
|
51
52
|
this.endpointUrl = endpointUrl;
|
|
52
|
-
const { defaultCountryHint = "us", defaultLanguage = "en",
|
|
53
|
+
const { defaultCountryHint = "us", defaultLanguage = "en" } = options, pipelineOptions = __rest(options, ["defaultCountryHint", "defaultLanguage"]);
|
|
53
54
|
this.defaultCountryHint = defaultCountryHint;
|
|
54
55
|
this.defaultLanguage = defaultLanguage;
|
|
55
56
|
const libInfo = `azsdk-js-ai-textanalytics/${SDK_VERSION}`;
|
|
@@ -62,15 +63,12 @@ export class TextAnalyticsClient {
|
|
|
62
63
|
else {
|
|
63
64
|
pipelineOptions.userAgentOptions.userAgentPrefix = libInfo;
|
|
64
65
|
}
|
|
65
|
-
const internalPipelineOptions = {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
logger: logger.info,
|
|
70
|
-
additionalAllowedHeaderNames: ["x-ms-correlation-request-id", "x-ms-request-id"],
|
|
71
|
-
},
|
|
66
|
+
const internalPipelineOptions = Object.assign(Object.assign({}, pipelineOptions), {
|
|
67
|
+
loggingOptions: {
|
|
68
|
+
logger: logger.info,
|
|
69
|
+
additionalAllowedHeaderNames: ["x-ms-correlation-request-id", "x-ms-request-id"],
|
|
72
70
|
},
|
|
73
|
-
};
|
|
71
|
+
});
|
|
74
72
|
this.client = new GeneratedClient(this.endpointUrl, internalPipelineOptions);
|
|
75
73
|
const authPolicy = isTokenCredential(credential)
|
|
76
74
|
? bearerTokenAuthenticationPolicy({ credential, scopes: DEFAULT_COGNITIVE_SCOPE })
|
|
@@ -95,10 +93,7 @@ export class TextAnalyticsClient {
|
|
|
95
93
|
}
|
|
96
94
|
else {
|
|
97
95
|
// Replace "none" hints with ""
|
|
98
|
-
realInputs = documents.map((input) => ({
|
|
99
|
-
...input,
|
|
100
|
-
countryHint: input.countryHint === "none" ? "" : input.countryHint,
|
|
101
|
-
}));
|
|
96
|
+
realInputs = documents.map((input) => (Object.assign(Object.assign({}, input), { countryHint: input.countryHint === "none" ? "" : input.countryHint })));
|
|
102
97
|
realOptions = countryHintOrOptions || {};
|
|
103
98
|
}
|
|
104
99
|
return this._tracing.withSpan("TextAnalyticsClient-detectLanguages", makeGeneratedDetectLanguageOptions(realOptions), (finalOptions) => this.client
|
|
@@ -221,7 +216,7 @@ export class TextAnalyticsClient {
|
|
|
221
216
|
realInputs = documents;
|
|
222
217
|
realOptions = languageOrOptions || {};
|
|
223
218
|
}
|
|
224
|
-
const { updateIntervalInMs, resumeFrom,
|
|
219
|
+
const { updateIntervalInMs, resumeFrom } = realOptions, restOptions = __rest(realOptions, ["updateIntervalInMs", "resumeFrom"]);
|
|
225
220
|
const poller = new BeginAnalyzeHealthcarePoller({
|
|
226
221
|
client: this.client,
|
|
227
222
|
tracing: this._tracing,
|
|
@@ -249,7 +244,7 @@ export class TextAnalyticsClient {
|
|
|
249
244
|
realOptions = languageOrOptions || {};
|
|
250
245
|
}
|
|
251
246
|
const compiledActions = compileAnalyzeInput(actions);
|
|
252
|
-
const { updateIntervalInMs, resumeFrom,
|
|
247
|
+
const { updateIntervalInMs, resumeFrom } = realOptions, restOptions = __rest(realOptions, ["updateIntervalInMs", "resumeFrom"]);
|
|
253
248
|
const poller = new BeginAnalyzeActionsPoller({
|
|
254
249
|
client: this.client,
|
|
255
250
|
tracing: this._tracing,
|
|
@@ -267,12 +262,13 @@ export class TextAnalyticsClient {
|
|
|
267
262
|
* @internal
|
|
268
263
|
*/
|
|
269
264
|
function compileAnalyzeInput(actions) {
|
|
265
|
+
var _a, _b, _c, _d, _e;
|
|
270
266
|
return {
|
|
271
|
-
entityRecognitionPiiTasks: actions.recognizePiiEntitiesActions
|
|
272
|
-
entityRecognitionTasks: actions.recognizeEntitiesActions
|
|
273
|
-
keyPhraseExtractionTasks: actions.extractKeyPhrasesActions
|
|
274
|
-
entityLinkingTasks: actions.recognizeLinkedEntitiesActions
|
|
275
|
-
sentimentAnalysisTasks: actions.analyzeSentimentActions
|
|
267
|
+
entityRecognitionPiiTasks: (_a = actions.recognizePiiEntitiesActions) === null || _a === void 0 ? void 0 : _a.map(compose(setStrEncodingParam, compose(setCategoriesFilter, addParamsToTask))),
|
|
268
|
+
entityRecognitionTasks: (_b = actions.recognizeEntitiesActions) === null || _b === void 0 ? void 0 : _b.map(compose(setStrEncodingParam, addParamsToTask)),
|
|
269
|
+
keyPhraseExtractionTasks: (_c = actions.extractKeyPhrasesActions) === null || _c === void 0 ? void 0 : _c.map(addParamsToTask),
|
|
270
|
+
entityLinkingTasks: (_d = actions.recognizeLinkedEntitiesActions) === null || _d === void 0 ? void 0 : _d.map(compose(setStrEncodingParam, addParamsToTask)),
|
|
271
|
+
sentimentAnalysisTasks: (_e = actions.analyzeSentimentActions) === null || _e === void 0 ? void 0 : _e.map(compose(setStrEncodingParam, compose(setOpinionMining, addParamsToTask))),
|
|
276
272
|
};
|
|
277
273
|
}
|
|
278
274
|
function isStringArray(documents) {
|