@azure/ai-text-analytics 5.1.1-alpha.20250619.1 → 5.1.1-alpha.20250730.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/browser/analyzeActionsResult.js +6 -7
- package/dist/browser/analyzeActionsResult.js.map +1 -1
- package/dist/browser/analyzeHealthcareEntitiesResult.js +7 -3
- package/dist/browser/analyzeHealthcareEntitiesResult.js.map +1 -1
- package/dist/browser/analyzeSentimentResult.js +7 -4
- package/dist/browser/analyzeSentimentResult.js.map +1 -1
- package/dist/browser/detectLanguageResult.js +4 -1
- package/dist/browser/detectLanguageResult.js.map +1 -1
- package/dist/browser/extractKeyPhrasesResult.js +4 -1
- package/dist/browser/extractKeyPhrasesResult.js.map +1 -1
- package/dist/browser/generated/generatedClient.js +12 -4
- package/dist/browser/generated/generatedClient.js.map +1 -1
- package/dist/browser/generated/models/mappers.js +44 -10
- package/dist/browser/generated/models/mappers.js.map +1 -1
- package/dist/browser/lro/analyze/operation.js +27 -18
- package/dist/browser/lro/analyze/operation.js.map +1 -1
- package/dist/browser/lro/health/operation.js +27 -34
- package/dist/browser/lro/health/operation.js.map +1 -1
- package/dist/browser/lro/poller.js +5 -7
- package/dist/browser/lro/poller.js.map +1 -1
- package/dist/browser/recognizeCategorizedEntitiesResult.js +4 -1
- package/dist/browser/recognizeCategorizedEntitiesResult.js.map +1 -1
- package/dist/browser/recognizeLinkedEntitiesResult.js +4 -1
- package/dist/browser/recognizeLinkedEntitiesResult.js.map +1 -1
- package/dist/browser/recognizePiiEntitiesResult.js +5 -2
- package/dist/browser/recognizePiiEntitiesResult.js.map +1 -1
- package/dist/browser/textAnalyticsClient.js +38 -16
- package/dist/browser/textAnalyticsClient.js.map +1 -1
- package/dist/browser/util.js +6 -8
- package/dist/browser/util.js.map +1 -1
- package/dist/commonjs/analyzeActionsResult.js +6 -7
- package/dist/commonjs/analyzeActionsResult.js.map +1 -1
- package/dist/commonjs/analyzeHealthcareEntitiesResult.js +7 -3
- package/dist/commonjs/analyzeHealthcareEntitiesResult.js.map +1 -1
- package/dist/commonjs/analyzeSentimentResult.js +7 -4
- package/dist/commonjs/analyzeSentimentResult.js.map +1 -1
- package/dist/commonjs/detectLanguageResult.js +4 -1
- package/dist/commonjs/detectLanguageResult.js.map +1 -1
- package/dist/commonjs/extractKeyPhrasesResult.js +4 -1
- package/dist/commonjs/extractKeyPhrasesResult.js.map +1 -1
- package/dist/commonjs/generated/generatedClient.js +12 -4
- package/dist/commonjs/generated/generatedClient.js.map +1 -1
- package/dist/commonjs/generated/models/mappers.js +44 -10
- package/dist/commonjs/generated/models/mappers.js.map +1 -1
- package/dist/commonjs/lro/analyze/operation.js +27 -18
- package/dist/commonjs/lro/analyze/operation.js.map +1 -1
- package/dist/commonjs/lro/health/operation.js +27 -34
- package/dist/commonjs/lro/health/operation.js.map +1 -1
- package/dist/commonjs/lro/poller.js +5 -7
- package/dist/commonjs/lro/poller.js.map +1 -1
- package/dist/commonjs/recognizeCategorizedEntitiesResult.js +4 -1
- package/dist/commonjs/recognizeCategorizedEntitiesResult.js.map +1 -1
- package/dist/commonjs/recognizeLinkedEntitiesResult.js +4 -1
- package/dist/commonjs/recognizeLinkedEntitiesResult.js.map +1 -1
- package/dist/commonjs/recognizePiiEntitiesResult.js +5 -2
- package/dist/commonjs/recognizePiiEntitiesResult.js.map +1 -1
- package/dist/commonjs/textAnalyticsClient.js +38 -16
- package/dist/commonjs/textAnalyticsClient.js.map +1 -1
- package/dist/commonjs/tsdoc-metadata.json +11 -11
- package/dist/commonjs/util.js +6 -8
- package/dist/commonjs/util.js.map +1 -1
- package/dist/esm/analyzeActionsResult.js +6 -7
- package/dist/esm/analyzeActionsResult.js.map +1 -1
- package/dist/esm/analyzeHealthcareEntitiesResult.js +7 -3
- package/dist/esm/analyzeHealthcareEntitiesResult.js.map +1 -1
- package/dist/esm/analyzeSentimentResult.js +7 -4
- package/dist/esm/analyzeSentimentResult.js.map +1 -1
- package/dist/esm/detectLanguageResult.js +4 -1
- package/dist/esm/detectLanguageResult.js.map +1 -1
- package/dist/esm/extractKeyPhrasesResult.js +4 -1
- package/dist/esm/extractKeyPhrasesResult.js.map +1 -1
- package/dist/esm/generated/generatedClient.js +12 -4
- package/dist/esm/generated/generatedClient.js.map +1 -1
- package/dist/esm/generated/models/mappers.js +44 -10
- package/dist/esm/generated/models/mappers.js.map +1 -1
- package/dist/esm/lro/analyze/operation.js +27 -18
- package/dist/esm/lro/analyze/operation.js.map +1 -1
- package/dist/esm/lro/health/operation.js +27 -34
- package/dist/esm/lro/health/operation.js.map +1 -1
- package/dist/esm/lro/poller.js +5 -7
- package/dist/esm/lro/poller.js.map +1 -1
- package/dist/esm/recognizeCategorizedEntitiesResult.js +4 -1
- package/dist/esm/recognizeCategorizedEntitiesResult.js.map +1 -1
- package/dist/esm/recognizeLinkedEntitiesResult.js +4 -1
- package/dist/esm/recognizeLinkedEntitiesResult.js.map +1 -1
- package/dist/esm/recognizePiiEntitiesResult.js +5 -2
- package/dist/esm/recognizePiiEntitiesResult.js.map +1 -1
- package/dist/esm/textAnalyticsClient.js +38 -16
- package/dist/esm/textAnalyticsClient.js.map +1 -1
- package/dist/esm/util.js +6 -8
- package/dist/esm/util.js.map +1 -1
- package/dist/react-native/analyzeActionsResult.js +6 -7
- package/dist/react-native/analyzeActionsResult.js.map +1 -1
- package/dist/react-native/analyzeHealthcareEntitiesResult.js +7 -3
- package/dist/react-native/analyzeHealthcareEntitiesResult.js.map +1 -1
- package/dist/react-native/analyzeSentimentResult.js +7 -4
- package/dist/react-native/analyzeSentimentResult.js.map +1 -1
- package/dist/react-native/detectLanguageResult.js +4 -1
- package/dist/react-native/detectLanguageResult.js.map +1 -1
- package/dist/react-native/extractKeyPhrasesResult.js +4 -1
- package/dist/react-native/extractKeyPhrasesResult.js.map +1 -1
- package/dist/react-native/generated/generatedClient.js +12 -4
- package/dist/react-native/generated/generatedClient.js.map +1 -1
- package/dist/react-native/generated/models/mappers.js +44 -10
- package/dist/react-native/generated/models/mappers.js.map +1 -1
- package/dist/react-native/lro/analyze/operation.js +27 -18
- package/dist/react-native/lro/analyze/operation.js.map +1 -1
- package/dist/react-native/lro/health/operation.js +27 -34
- package/dist/react-native/lro/health/operation.js.map +1 -1
- package/dist/react-native/lro/poller.js +5 -7
- package/dist/react-native/lro/poller.js.map +1 -1
- package/dist/react-native/recognizeCategorizedEntitiesResult.js +4 -1
- package/dist/react-native/recognizeCategorizedEntitiesResult.js.map +1 -1
- package/dist/react-native/recognizeLinkedEntitiesResult.js +4 -1
- package/dist/react-native/recognizeLinkedEntitiesResult.js.map +1 -1
- package/dist/react-native/recognizePiiEntitiesResult.js +5 -2
- package/dist/react-native/recognizePiiEntitiesResult.js.map +1 -1
- package/dist/react-native/textAnalyticsClient.js +38 -16
- package/dist/react-native/textAnalyticsClient.js.map +1 -1
- package/dist/react-native/util.js +6 -8
- package/dist/react-native/util.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operation.js","sourceRoot":"","sources":["../../../../src/lro/analyze/operation.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;AAmBlC,OAAO,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAE3E,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEjF,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAErD,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAoFzC;;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,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AElE,IAAI,CAAC,KAAK,CAAC,WAAW,IAAI,eAAe,CAAC,IAAI,EAAE,CAAC;YAC/C,MAAM,aAAa,GAAG,IAAI,CAAC,yBAAyB,CAAC,KAAK,CAAC,WAAY,EAAE;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;QAC3B,CAAC;QAED,IAAI,OAAO,OAAO,CAAC,YAAY,KAAK,UAAU,EAAE,CAAC;YAC/C,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;QAC9B,CAAC;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 type { OperationOptions } from \"@azure/core-client\";\n\nimport type { AbortSignalLike } from \"@azure/abort-controller\";\n\nimport type {\n AnalyzeStatusOptionalParams as AnalyzeActionsOperationStatusOptions,\n AnalyzeJobState,\n AnalyzeResponse as BeginAnalyzeResponse,\n JobManifestTasks as GeneratedActions,\n TextDocumentBatchStatistics,\n TextDocumentInput,\n} from \"../../generated/models/index.js\";\nimport type {\n AnalyzeActionsResult,\n PagedAnalyzeActionsResult,\n PagedAsyncIterableAnalyzeActionsResult,\n} from \"../../analyzeActionsResult.js\";\nimport { createAnalyzeActionsResult } from \"../../analyzeActionsResult.js\";\nimport type { PageSettings } from \"@azure/core-paging\";\nimport { getOperationId, nextLinkToTopAndSkip, throwError } from \"../../util.js\";\nimport type { AnalysisPollOperationState, OperationMetadata } from \"../poller.js\";\nimport { AnalysisPollOperation } from \"../poller.js\";\nimport type { GeneratedClient as Client } from \"../../generated/index.js\";\nimport { logger } from \"../../logger.js\";\nimport type { 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;AAmBlC,OAAO,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAE3E,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEjF,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAErD,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAoFzC;;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,EAAE,QAAQ,CAAC,KAAK,CAAC,UAAU;QACjD,WAAW,EAAE,QAAQ,CAAC,WAAW;KAClC,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,OAAO,kCAAmC,SAAQ,qBAGvD;IAEU;IAEC;IACA;IACA;IACA;IACA;IAPV,YACS,KAAmC;IAC1C,wEAAwE;IAChE,MAAc,EACd,OAAsB,EACtB,SAA8B,EAC9B,OAAyB,EACzB,UAAsC,EAAE;QAEhD,KAAK,CAAC,KAAK,CAAC,CAAC;QARN,UAAK,GAAL,KAAK,CAA8B;QAElC,WAAM,GAAN,MAAM,CAAQ;QACd,YAAO,GAAP,OAAO,CAAe;QACtB,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,MAAM;YACN,KAAK,CAAC,MAAM,GAAG,aAAa,CAAC;YAC7B,KAAK,CAAC,WAAW,GAAG,IAAI,CAAC;QAC3B,CAAC;QAED,IAAI,OAAO,OAAO,CAAC,YAAY,KAAK,UAAU,EAAE,CAAC;YAC/C,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;QAC9B,CAAC;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 type { OperationOptions } from \"@azure/core-client\";\n\nimport type { AbortSignalLike } from \"@azure/abort-controller\";\n\nimport type {\n AnalyzeStatusOptionalParams as AnalyzeActionsOperationStatusOptions,\n AnalyzeJobState,\n AnalyzeResponse as BeginAnalyzeResponse,\n JobManifestTasks as GeneratedActions,\n TextDocumentBatchStatistics,\n TextDocumentInput,\n} from \"../../generated/models/index.js\";\nimport type {\n AnalyzeActionsResult,\n PagedAnalyzeActionsResult,\n PagedAsyncIterableAnalyzeActionsResult,\n} from \"../../analyzeActionsResult.js\";\nimport { createAnalyzeActionsResult } from \"../../analyzeActionsResult.js\";\nimport type { PageSettings } from \"@azure/core-paging\";\nimport { getOperationId, nextLinkToTopAndSkip, throwError } from \"../../util.js\";\nimport type { AnalysisPollOperationState, OperationMetadata } from \"../poller.js\";\nimport { AnalysisPollOperation } from \"../poller.js\";\nimport type { GeneratedClient as Client } from \"../../generated/index.js\";\nimport { logger } from \"../../logger.js\";\nimport type { 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,6 +1,5 @@
|
|
|
1
1
|
// Copyright (c) Microsoft Corporation.
|
|
2
2
|
// Licensed under the MIT License.
|
|
3
|
-
import { __asyncDelegator, __asyncGenerator, __asyncValues, __await } from "tslib";
|
|
4
3
|
import { makeHealthcareEntitiesErrorResult, makeHealthcareEntitiesResult, } from "../../analyzeHealthcareEntitiesResult.js";
|
|
5
4
|
import { addStrEncodingParam, getOperationId, nextLinkToTopAndSkip, throwError, } from "../../util.js";
|
|
6
5
|
import { AnalysisPollOperation } from "../poller.js";
|
|
@@ -21,6 +20,11 @@ function getMetaInfoFromResponse(response) {
|
|
|
21
20
|
* @internal
|
|
22
21
|
*/
|
|
23
22
|
export class BeginAnalyzeHealthcarePollerOperation extends AnalysisPollOperation {
|
|
23
|
+
state;
|
|
24
|
+
client;
|
|
25
|
+
tracing;
|
|
26
|
+
documents;
|
|
27
|
+
options;
|
|
24
28
|
constructor(state,
|
|
25
29
|
// eslint-disable-next-line @azure/azure-sdk/ts-use-interface-parameters
|
|
26
30
|
client, tracing, documents, options = {}) {
|
|
@@ -46,7 +50,7 @@ export class BeginAnalyzeHealthcarePollerOperation extends AnalysisPollOperation
|
|
|
46
50
|
return this;
|
|
47
51
|
},
|
|
48
52
|
byPage: (settings) => {
|
|
49
|
-
const pageOptions =
|
|
53
|
+
const pageOptions = { ...options, top: settings?.maxPageSize };
|
|
50
54
|
return this._listHealthcareEntitiesPaged(operationId, pageOptions);
|
|
51
55
|
},
|
|
52
56
|
};
|
|
@@ -54,39 +58,26 @@ export class BeginAnalyzeHealthcarePollerOperation extends AnalysisPollOperation
|
|
|
54
58
|
/**
|
|
55
59
|
* returns an iterator to the results of a healthcare operation.
|
|
56
60
|
*/
|
|
57
|
-
_listHealthcareEntities(operationId, options) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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
|
-
});
|
|
61
|
+
async *_listHealthcareEntities(operationId, options) {
|
|
62
|
+
for await (const page of this._listHealthcareEntitiesPaged(operationId, options)) {
|
|
63
|
+
yield* page;
|
|
64
|
+
}
|
|
76
65
|
}
|
|
77
66
|
/**
|
|
78
67
|
* returns an iterator to arrays of the results of a healthcare operation.
|
|
79
68
|
*/
|
|
80
|
-
_listHealthcareEntitiesPaged(operationId, options) {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
response
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
|
|
69
|
+
async *_listHealthcareEntitiesPaged(operationId, options) {
|
|
70
|
+
let response = await this._listHealthcareEntitiesSinglePage(operationId, options);
|
|
71
|
+
yield response.result;
|
|
72
|
+
while (response.skip) {
|
|
73
|
+
const optionsWithContinuation = {
|
|
74
|
+
...options,
|
|
75
|
+
top: response.top,
|
|
76
|
+
skip: response.skip,
|
|
77
|
+
};
|
|
78
|
+
response = await this._listHealthcareEntitiesSinglePage(operationId, optionsWithContinuation);
|
|
79
|
+
yield response.result;
|
|
80
|
+
}
|
|
90
81
|
}
|
|
91
82
|
/**
|
|
92
83
|
* returns an iterator to arrays of the sorted results of a healthcare operation.
|
|
@@ -96,7 +87,8 @@ export class BeginAnalyzeHealthcarePollerOperation extends AnalysisPollOperation
|
|
|
96
87
|
if (response.results) {
|
|
97
88
|
const result = processAndCombineSuccessfulAndErroneousDocuments(this.documents, response.results, makeHealthcareEntitiesResult, makeHealthcareEntitiesErrorResult);
|
|
98
89
|
return response.nextLink
|
|
99
|
-
?
|
|
90
|
+
? { result, ...nextLinkToTopAndSkip(response.nextLink) }
|
|
91
|
+
: { result };
|
|
100
92
|
}
|
|
101
93
|
else {
|
|
102
94
|
throw new Error("Healthcare action has succeeded but the there are no results!");
|
|
@@ -107,14 +99,15 @@ export class BeginAnalyzeHealthcarePollerOperation extends AnalysisPollOperation
|
|
|
107
99
|
* statistics and the model version used.
|
|
108
100
|
*/
|
|
109
101
|
async getHealthStatus(operationId, options) {
|
|
110
|
-
var _a;
|
|
111
102
|
const response = await this.tracing.withSpan("TextAnalyticsClient-getHealthStatus", options || {}, (finalOptions) => this.client.healthStatus(operationId, finalOptions));
|
|
112
103
|
switch (response.status) {
|
|
113
104
|
case "notStarted":
|
|
114
105
|
case "running":
|
|
115
106
|
break;
|
|
116
107
|
case "failed": {
|
|
117
|
-
const errors =
|
|
108
|
+
const errors = response.errors
|
|
109
|
+
?.map((e) => ` code ${e.code}, message: '${e.message}'`)
|
|
110
|
+
.join("\n");
|
|
118
111
|
const message = `Healthcare analysis failed. Error(s): ${errors || ""}`;
|
|
119
112
|
throw new Error(message);
|
|
120
113
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operation.js","sourceRoot":"","sources":["../../../../src/lro/health/operation.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;AAkBlC,OAAO,EACL,iCAAiC,EACjC,4BAA4B,GAC7B,MAAM,0CAA0C,CAAC;AAGlD,OAAO,EACL,mBAAmB,EACnB,cAAc,EACd,oBAAoB,EACpB,UAAU,GACX,MAAM,eAAe,CAAC;AAKvB,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAErD,OAAO,EAAE,gDAAgD,EAAE,MAAM,8BAA8B,CAAC;AAiFhG;;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;IAC7C,wEAAwE;IAChE,MAAc,EACd,OAAsB,EACtB,SAA8B,EAC9B,UAAiD,EAAE;QAE3D,KAAK,CAAC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,KAAK,CAAC,WAAW,EAAE;gBACnD,WAAW,EAAE,IAAI,CAAC,OAAO,CAAC,WAAW;gBACrC,cAAc,EAAE,IAAI,CAAC,OAAO,CAAC,cAAc;aAC5C,CAAC,CAAC;QACL,CAAC;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 type { AbortSignalLike } from \"@azure/abort-controller\";\nimport type { OperationOptions } from \"@azure/core-client\";\n\nimport type {\n HealthResponse as BeginAnalyzeHealthcareResponse,\n HealthcareJobState,\n HealthStatusOptionalParams as HealthcareJobStatusOptions,\n TextDocumentBatchStatistics,\n TextDocumentInput,\n} from \"../../generated/models/index.js\";\nimport type {\n AnalyzeHealthcareEntitiesResult,\n AnalyzeHealthcareEntitiesResultArray,\n PagedAnalyzeHealthcareEntitiesResult,\n PagedAsyncIterableAnalyzeHealthcareEntitiesResult,\n} from \"../../analyzeHealthcareEntitiesResult.js\";\nimport {\n makeHealthcareEntitiesErrorResult,\n makeHealthcareEntitiesResult,\n} from \"../../analyzeHealthcareEntitiesResult.js\";\nimport type { PageSettings } from \"@azure/core-paging\";\nimport type { StringIndexType } from \"../../util.js\";\nimport {\n addStrEncodingParam,\n getOperationId,\n nextLinkToTopAndSkip,\n throwError,\n} from \"../../util.js\";\nimport type {\n AnalysisPollOperationState,\n OperationMetadata as AnalyzeHealthcareEntitiesOperationMetadata,\n} from \"../poller.js\";\nimport { AnalysisPollOperation } from \"../poller.js\";\nimport type { GeneratedClient as Client } from \"../../generated/index.js\";\nimport { processAndCombineSuccessfulAndErroneousDocuments } from \"../../textAnalyticsResult.js\";\nimport type { TextAnalyticsOperationOptions } from \"../../textAnalyticsOperationOptions.js\";\nimport type { 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://learn.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;AAkBlC,OAAO,EACL,iCAAiC,EACjC,4BAA4B,GAC7B,MAAM,0CAA0C,CAAC;AAGlD,OAAO,EACL,mBAAmB,EACnB,cAAc,EACd,oBAAoB,EACpB,UAAU,GACX,MAAM,eAAe,CAAC;AAKvB,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAErD,OAAO,EAAE,gDAAgD,EAAE,MAAM,8BAA8B,CAAC;AAiFhG;;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;IAEU;IAEC;IACA;IACA;IACA;IANV,YACS,KAAsC;IAC7C,wEAAwE;IAChE,MAAc,EACd,OAAsB,EACtB,SAA8B,EAC9B,UAAiD,EAAE;QAE3D,KAAK,CAAC,KAAK,CAAC,CAAC;QAPN,UAAK,GAAL,KAAK,CAAiC;QAErC,WAAM,GAAN,MAAM,CAAQ;QACd,YAAO,GAAP,OAAO,CAAe;QACtB,cAAS,GAAT,SAAS,CAAqB;QAC9B,YAAO,GAAP,OAAO,CAA4C;IAG7D,CAAC;IAED;;;;OAIG;IACK,4BAA4B,CAClC,WAAmB,EACnB,UAAsC,EAAE;QAExC,MAAM,IAAI,GAAG,IAAI,CAAC,uBA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GAAG,eAAe,CAAC,gBAAgB,CAAC,MAAM,CAAC;QAEvD,IAAI,CAAC,KAAK,CAAC,WAAW,IAAI,eAAe,CAAC,IAAI,EAAE,CAAC;YAC/C,MAAM,aAAa,GAAG,IAAI,CAAC,4BAA4B,CAAC,KAAK,CAAC,WAAY,EAAE;gBAC1E,WAAW,EAAE,IAAI,CAAC,OAAO,CAAC,WAAW;gBACrC,cAAc,EAAE,IAAI,CAAC,OAAO,CAAC,cAAc;aAC5C,CAAC,CAAC;YACH,KAAK,CAAC,MAAM,GAAG,MAAM,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;QAC3B,CAAC;QACD,IAAI,OAAO,OAAO,CAAC,YAAY,KAAK,UAAU,EAAE,CAAC;YAC/C,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;QAC9B,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,MAAM;QACV,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QACzB,IAAI,KAAK,CAAC,WAAW,EAAE,CAAC;YACtB,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;QACL,CAAC;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 type { AbortSignalLike } from \"@azure/abort-controller\";\nimport type { OperationOptions } from \"@azure/core-client\";\n\nimport type {\n HealthResponse as BeginAnalyzeHealthcareResponse,\n HealthcareJobState,\n HealthStatusOptionalParams as HealthcareJobStatusOptions,\n TextDocumentBatchStatistics,\n TextDocumentInput,\n} from \"../../generated/models/index.js\";\nimport type {\n AnalyzeHealthcareEntitiesResult,\n AnalyzeHealthcareEntitiesResultArray,\n PagedAnalyzeHealthcareEntitiesResult,\n PagedAsyncIterableAnalyzeHealthcareEntitiesResult,\n} from \"../../analyzeHealthcareEntitiesResult.js\";\nimport {\n makeHealthcareEntitiesErrorResult,\n makeHealthcareEntitiesResult,\n} from \"../../analyzeHealthcareEntitiesResult.js\";\nimport type { PageSettings } from \"@azure/core-paging\";\nimport type { StringIndexType } from \"../../util.js\";\nimport {\n addStrEncodingParam,\n getOperationId,\n nextLinkToTopAndSkip,\n throwError,\n} from \"../../util.js\";\nimport type {\n AnalysisPollOperationState,\n OperationMetadata as AnalyzeHealthcareEntitiesOperationMetadata,\n} from \"../poller.js\";\nimport { AnalysisPollOperation } from \"../poller.js\";\nimport type { GeneratedClient as Client } from \"../../generated/index.js\";\nimport { processAndCombineSuccessfulAndErroneousDocuments } from \"../../textAnalyticsResult.js\";\nimport type { TextAnalyticsOperationOptions } from \"../../textAnalyticsOperationOptions.js\";\nimport type { 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://learn.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"]}
|
package/dist/esm/lro/poller.js
CHANGED
|
@@ -7,13 +7,10 @@ import { delay } from "../util.js";
|
|
|
7
7
|
* @internal
|
|
8
8
|
*/
|
|
9
9
|
export class AnalysisPoller extends Poller {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
*/
|
|
15
|
-
this.updateIntervalInMs = 2000;
|
|
16
|
-
}
|
|
10
|
+
/**
|
|
11
|
+
* Defines how much time the poller is going to wait before making a new request to the service.
|
|
12
|
+
*/
|
|
13
|
+
updateIntervalInMs = 2000;
|
|
17
14
|
/**
|
|
18
15
|
* The method used by the poller to wait before attempting to update its operation.
|
|
19
16
|
*/
|
|
@@ -26,6 +23,7 @@ export class AnalysisPoller extends Poller {
|
|
|
26
23
|
* @internal
|
|
27
24
|
*/
|
|
28
25
|
export class AnalysisPollOperation {
|
|
26
|
+
state;
|
|
29
27
|
constructor(state) {
|
|
30
28
|
this.state = state;
|
|
31
29
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"poller.js","sourceRoot":"","sources":["../../../src/lro/poller.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAIzC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AA+CnC;;;GAGG;AACH,MAAM,OAAgB,cAGpB,SAAQ,MAAuB;
|
|
1
|
+
{"version":3,"file":"poller.js","sourceRoot":"","sources":["../../../src/lro/poller.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAIzC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AA+CnC;;;GAGG;AACH,MAAM,OAAgB,cAGpB,SAAQ,MAAuB;IAC/B;;OAEG;IACI,kBAAkB,GAAW,IAAI,CAAC;IAEzC;;OAEG;IACH,KAAK,CAAC,KAAK;QACT,OAAO,KAAK,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;IACxC,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAgB,qBAAqB;IAGtB;IAAnB,YAAmB,KAAa;QAAb,UAAK,GAAL,KAAK,CAAQ;IAAG,CAAC;IAcpC;;OAEG;IACI,QAAQ;QACb,OAAO,IAAI,CAAC,SAAS,CAAC;YACpB,KAAK,EAAE,IAAI,CAAC,KAAK;SAClB,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { PollOperation, PollOperationState } from \"@azure/core-lro\";\nimport { Poller } from \"@azure/core-lro\";\nimport type { TracingClient } from \"@azure/core-tracing\";\nimport type { GeneratedClient } from \"../generated/generatedClient.js\";\nimport type { State, TextDocumentInput } from \"../generated/models/index.js\";\nimport { delay } from \"../util.js\";\n\n/**\n * Common parameters to a Poller.\n * @internal\n */\nexport interface AnalysisPollerOptions {\n readonly client: GeneratedClient;\n readonly tracing: TracingClient;\n readonly documents: TextDocumentInput[];\n updateIntervalInMs?: number;\n resumeFrom?: string;\n}\n\n/**\n * Metadata information for an analysis poller operation.\n */\nexport interface OperationMetadata {\n /**\n * The date and time the operation was created.\n */\n createdOn: Date;\n /**\n * The date and time when the operation results will expire on the server.\n */\n expiresOn?: Date;\n /**\n * The operation id.\n */\n operationId: string;\n /**\n * The time the operation status was last updated.\n */\n lastModifiedOn: Date;\n /**\n * The current status of the operation.\n */\n status: State;\n}\n\n/**\n * An interface representing the state of an analysis poller operation.\n */\nexport interface AnalysisPollOperationState<TResult>\n extends PollOperationState<TResult>,\n OperationMetadata {}\n\n/**\n * Common properties and methods of analysis Pollers.\n * @internal\n */\nexport abstract class AnalysisPoller<\n TState extends PollOperationState<TResult>,\n TResult,\n> extends Poller<TState, TResult> {\n /**\n * Defines how much time the poller is going to wait before making a new request to the service.\n */\n public updateIntervalInMs: number = 2000;\n\n /**\n * The method used by the poller to wait before attempting to update its operation.\n */\n async delay(): Promise<void> {\n return delay(this.updateIntervalInMs);\n }\n}\n\n/**\n * Common properties and methods of polling operations.\n * @internal\n */\nexport abstract class AnalysisPollOperation<TState, TResult>\n implements PollOperation<TState, TResult>\n{\n constructor(public state: TState) {}\n\n /**\n * Meant to reach to the service and update the Poller operation.\n * @param options - The optional parameters, which is only an abortSignal from \\@azure/abort-controller\n */\n public abstract update(): Promise<PollOperation<TState, TResult>>;\n\n /**\n * Meant to reach to the service and cancel the Poller operation.\n * @param options - The optional parameters, which is only an abortSignal from \\@azure/abort-controller\n */\n public abstract cancel(): Promise<PollOperation<TState, TResult>>;\n\n /**\n * Serializes the Poller operation.\n */\n public toString(): string {\n return JSON.stringify({\n state: this.state,\n });\n }\n}\n"]}
|
|
@@ -6,7 +6,10 @@ import { makeTextAnalyticsErrorResult, makeTextAnalyticsSuccessResult, } from ".
|
|
|
6
6
|
*/
|
|
7
7
|
export function makeRecognizeCategorizedEntitiesResult(result) {
|
|
8
8
|
const { entities, statistics, warnings, id } = result;
|
|
9
|
-
return
|
|
9
|
+
return {
|
|
10
|
+
...makeTextAnalyticsSuccessResult(id, warnings, statistics),
|
|
11
|
+
entities,
|
|
12
|
+
};
|
|
10
13
|
}
|
|
11
14
|
/**
|
|
12
15
|
* @internal
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recognizeCategorizedEntitiesResult.js","sourceRoot":"","sources":["../../src/recognizeCategorizedEntitiesResult.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAMlC,OAAO,EACL,4BAA4B,EAC5B,8BAA8B,GAC/B,MAAM,0BAA0B,CAAC;AAgClC;;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;AAMlC,OAAO,EACL,4BAA4B,EAC5B,8BAA8B,GAC/B,MAAM,0BAA0B,CAAC;AAgClC;;GAEG;AACH,MAAM,UAAU,sCAAsC,CACpD,MAAwB;IAExB,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,EAAE,EAAE,GAAG,MAAM,CAAC;IACtD,OAAO;QACL,GAAG,8BAA8B,CAAC,EAAE,EAAE,QAAQ,EAAE,UAAU,CAAC;QAC3D,QAAQ;KACT,CAAC;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 type {\n TextAnalyticsErrorResult,\n TextAnalyticsSuccessResult,\n} from \"./textAnalyticsResult.js\";\nimport {\n makeTextAnalyticsErrorResult,\n makeTextAnalyticsSuccessResult,\n} from \"./textAnalyticsResult.js\";\nimport type { DocumentEntities, Entity, TextAnalyticsError } from \"./generated/models/index.js\";\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,7 +6,10 @@ import { makeTextAnalyticsErrorResult, makeTextAnalyticsSuccessResult, } from ".
|
|
|
6
6
|
*/
|
|
7
7
|
export function makeRecognizeLinkedEntitiesResult(result) {
|
|
8
8
|
const { statistics, id, warnings, entities } = result;
|
|
9
|
-
return
|
|
9
|
+
return {
|
|
10
|
+
...makeTextAnalyticsSuccessResult(id, warnings, statistics),
|
|
11
|
+
entities,
|
|
12
|
+
};
|
|
10
13
|
}
|
|
11
14
|
/**
|
|
12
15
|
* @internal
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recognizeLinkedEntitiesResult.js","sourceRoot":"","sources":["../../src/recognizeLinkedEntitiesResult.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAMlC,OAAO,EACL,4BAA4B,EAC5B,8BAA8B,GAC/B,MAAM,0BAA0B,CAAC;AA8BlC;;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;AAMlC,OAAO,EACL,4BAA4B,EAC5B,8BAA8B,GAC/B,MAAM,0BAA0B,CAAC;AA8BlC;;GAEG;AACH,MAAM,UAAU,iCAAiC,CAC/C,MAA8B;IAE9B,MAAM,EAAE,UAAU,EAAE,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAC;IACtD,OAAO;QACL,GAAG,8BAA8B,CAAC,EAAE,EAAE,QAAQ,EAAE,UAAU,CAAC;QAC3D,QAAQ;KACT,CAAC;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 type {\n TextAnalyticsErrorResult,\n TextAnalyticsSuccessResult,\n} from \"./textAnalyticsResult.js\";\nimport {\n makeTextAnalyticsErrorResult,\n makeTextAnalyticsSuccessResult,\n} from \"./textAnalyticsResult.js\";\nimport type {\n DocumentLinkedEntities,\n LinkedEntity,\n TextAnalyticsError,\n} from \"./generated/models/index.js\";\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,8 +6,11 @@ import { makeTextAnalyticsErrorResult, makeTextAnalyticsSuccessResult, } from ".
|
|
|
6
6
|
*/
|
|
7
7
|
export function makeRecognizePiiEntitiesResult(document) {
|
|
8
8
|
const { id, entities, warnings, statistics, redactedText } = document;
|
|
9
|
-
return
|
|
10
|
-
|
|
9
|
+
return {
|
|
10
|
+
...makeTextAnalyticsSuccessResult(id, warnings, statistics),
|
|
11
|
+
entities,
|
|
12
|
+
redactedText,
|
|
13
|
+
};
|
|
11
14
|
}
|
|
12
15
|
/**
|
|
13
16
|
* @internal
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recognizePiiEntitiesResult.js","sourceRoot":"","sources":["../../src/recognizePiiEntitiesResult.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAMlC,OAAO,EACL,4BAA4B,EAC5B,8BAA8B,GAC/B,MAAM,0BAA0B,CAAC;AAoClC;;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;AAMlC,OAAO,EACL,4BAA4B,EAC5B,8BAA8B,GAC/B,MAAM,0BAA0B,CAAC;AAoClC;;GAEG;AACH,MAAM,UAAU,8BAA8B,CAC5C,QAA6B;IAE7B,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,YAAY,EAAE,GAAG,QAAQ,CAAC;IACtE,OAAO;QACL,GAAG,8BAA8B,CAAC,EAAE,EAAE,QAAQ,EAAE,UAAU,CAAC;QAC3D,QAAQ;QACR,YAAY;KACb,CAAC;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 type {\n TextAnalyticsErrorResult,\n TextAnalyticsSuccessResult,\n} from \"./textAnalyticsResult.js\";\nimport {\n makeTextAnalyticsErrorResult,\n makeTextAnalyticsSuccessResult,\n} from \"./textAnalyticsResult.js\";\nimport type { Entity, PiiDocumentEntities, TextAnalyticsError } from \"./generated/models/index.js\";\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,6 +1,5 @@
|
|
|
1
1
|
// Copyright (c) Microsoft Corporation.
|
|
2
2
|
// Licensed under the MIT License.
|
|
3
|
-
import { __rest } from "tslib";
|
|
4
3
|
import { bearerTokenAuthenticationPolicy } from "@azure/core-rest-pipeline";
|
|
5
4
|
import { isTokenCredential } from "@azure/core-auth";
|
|
6
5
|
import { SDK_VERSION } from "./constants.js";
|
|
@@ -32,6 +31,24 @@ export var PiiEntityDomain;
|
|
|
32
31
|
* Client class for interacting with Azure Text Analytics.
|
|
33
32
|
*/
|
|
34
33
|
export class TextAnalyticsClient {
|
|
34
|
+
/**
|
|
35
|
+
* The URL to the TextAnalytics endpoint
|
|
36
|
+
*/
|
|
37
|
+
endpointUrl;
|
|
38
|
+
/**
|
|
39
|
+
* The default country hint to use. Defaults to "us".
|
|
40
|
+
*/
|
|
41
|
+
defaultCountryHint;
|
|
42
|
+
/**
|
|
43
|
+
* The default language to use. Defaults to "en".
|
|
44
|
+
*/
|
|
45
|
+
defaultLanguage;
|
|
46
|
+
/**
|
|
47
|
+
* @internal
|
|
48
|
+
* A reference to the auto-generated TextAnalytics HTTP client.
|
|
49
|
+
*/
|
|
50
|
+
client;
|
|
51
|
+
_tracing;
|
|
35
52
|
/**
|
|
36
53
|
* Creates an instance of TextAnalyticsClient.
|
|
37
54
|
*
|
|
@@ -47,7 +64,7 @@ export class TextAnalyticsClient {
|
|
|
47
64
|
*/
|
|
48
65
|
constructor(endpointUrl, credential, options = {}) {
|
|
49
66
|
this.endpointUrl = endpointUrl;
|
|
50
|
-
const { defaultCountryHint = "us", defaultLanguage = "en"
|
|
67
|
+
const { defaultCountryHint = "us", defaultLanguage = "en", ...pipelineOptions } = options;
|
|
51
68
|
this.defaultCountryHint = defaultCountryHint;
|
|
52
69
|
this.defaultLanguage = defaultLanguage;
|
|
53
70
|
const libInfo = `azsdk-js-ai-textanalytics/${SDK_VERSION}`;
|
|
@@ -60,12 +77,15 @@ export class TextAnalyticsClient {
|
|
|
60
77
|
else {
|
|
61
78
|
pipelineOptions.userAgentOptions.userAgentPrefix = libInfo;
|
|
62
79
|
}
|
|
63
|
-
const internalPipelineOptions =
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
80
|
+
const internalPipelineOptions = {
|
|
81
|
+
...pipelineOptions,
|
|
82
|
+
...{
|
|
83
|
+
loggingOptions: {
|
|
84
|
+
logger: logger.info,
|
|
85
|
+
additionalAllowedHeaderNames: ["x-ms-correlation-request-id", "x-ms-request-id"],
|
|
86
|
+
},
|
|
67
87
|
},
|
|
68
|
-
}
|
|
88
|
+
};
|
|
69
89
|
this.client = new GeneratedClient(this.endpointUrl, internalPipelineOptions);
|
|
70
90
|
const authPolicy = isTokenCredential(credential)
|
|
71
91
|
? bearerTokenAuthenticationPolicy({ credential, scopes: DEFAULT_COGNITIVE_SCOPE })
|
|
@@ -90,7 +110,10 @@ export class TextAnalyticsClient {
|
|
|
90
110
|
}
|
|
91
111
|
else {
|
|
92
112
|
// Replace "none" hints with ""
|
|
93
|
-
realInputs = documents.map((input) => (
|
|
113
|
+
realInputs = documents.map((input) => ({
|
|
114
|
+
...input,
|
|
115
|
+
countryHint: input.countryHint === "none" ? "" : input.countryHint,
|
|
116
|
+
}));
|
|
94
117
|
realOptions = countryHintOrOptions || {};
|
|
95
118
|
}
|
|
96
119
|
return this._tracing.withSpan("TextAnalyticsClient-detectLanguages", makeGeneratedDetectLanguageOptions(realOptions), (finalOptions) => this.client
|
|
@@ -213,7 +236,7 @@ export class TextAnalyticsClient {
|
|
|
213
236
|
realInputs = documents;
|
|
214
237
|
realOptions = languageOrOptions || {};
|
|
215
238
|
}
|
|
216
|
-
const { updateIntervalInMs, resumeFrom
|
|
239
|
+
const { updateIntervalInMs, resumeFrom, ...restOptions } = realOptions;
|
|
217
240
|
const poller = new BeginAnalyzeHealthcarePoller({
|
|
218
241
|
client: this.client,
|
|
219
242
|
tracing: this._tracing,
|
|
@@ -241,7 +264,7 @@ export class TextAnalyticsClient {
|
|
|
241
264
|
realOptions = languageOrOptions || {};
|
|
242
265
|
}
|
|
243
266
|
const compiledActions = compileAnalyzeInput(actions);
|
|
244
|
-
const { updateIntervalInMs, resumeFrom
|
|
267
|
+
const { updateIntervalInMs, resumeFrom, ...restOptions } = realOptions;
|
|
245
268
|
const poller = new BeginAnalyzeActionsPoller({
|
|
246
269
|
client: this.client,
|
|
247
270
|
tracing: this._tracing,
|
|
@@ -259,13 +282,12 @@ export class TextAnalyticsClient {
|
|
|
259
282
|
* @internal
|
|
260
283
|
*/
|
|
261
284
|
function compileAnalyzeInput(actions) {
|
|
262
|
-
var _a, _b, _c, _d, _e;
|
|
263
285
|
return {
|
|
264
|
-
entityRecognitionPiiTasks:
|
|
265
|
-
entityRecognitionTasks:
|
|
266
|
-
keyPhraseExtractionTasks:
|
|
267
|
-
entityLinkingTasks:
|
|
268
|
-
sentimentAnalysisTasks:
|
|
286
|
+
entityRecognitionPiiTasks: actions.recognizePiiEntitiesActions?.map(compose(setStrEncodingParam, compose(setCategoriesFilter, addParamsToTask))),
|
|
287
|
+
entityRecognitionTasks: actions.recognizeEntitiesActions?.map(compose(setStrEncodingParam, addParamsToTask)),
|
|
288
|
+
keyPhraseExtractionTasks: actions.extractKeyPhrasesActions?.map(addParamsToTask),
|
|
289
|
+
entityLinkingTasks: actions.recognizeLinkedEntitiesActions?.map(compose(setStrEncodingParam, addParamsToTask)),
|
|
290
|
+
sentimentAnalysisTasks: actions.analyzeSentimentActions?.map(compose(setStrEncodingParam, compose(setOpinionMining, addParamsToTask))),
|
|
269
291
|
};
|
|
270
292
|
}
|
|
271
293
|
function isStringArray(documents) {
|