From ee2fa5697e3f12c669c10cd71bf259c3e6194075 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 23 May 2024 17:49:34 +0000 Subject: [PATCH] added fix for runAsync query without mds id (#323) * added fix for runAsync query without mds id Signed-off-by: sumukhswamy * linter fix Signed-off-by: sumukhswamy * fixed linter issue Signed-off-by: sumukhswamy * fixed linter issue Signed-off-by: sumukhswamy * added change for linting issue Signed-off-by: sumukhswamy * linter issues Signed-off-by: sumukhswamy * linter issues Signed-off-by: sumukhswamy * linting fix Signed-off-by: sumukhswamy * more linting issues Signed-off-by: sumukhswamy * added linting fixes Signed-off-by: sumukhswamy * refactored flyout code with interface Signed-off-by: sumukhswamy * added fix for import of interface Signed-off-by: sumukhswamy * added linter fix Signed-off-by: sumukhswamy * added linter fix Signed-off-by: sumukhswamy * added linter fix Signed-off-by: sumukhswamy * addressed pr comments Signed-off-by: sumukhswamy * linter fix Signed-off-by: sumukhswamy --------- Signed-off-by: sumukhswamy (cherry picked from commit 4ae9a534fe60e2336d15bbe6729640b079c8f8a7) Signed-off-by: github-actions[bot] --- public/components/SQLPage/SQLPage.tsx | 12 +- .../register_observability_dependencies.tsx | 7 +- public/types.ts | 6 +- server/plugin.ts | 29 +--- server/routes/index.ts | 21 ++- server/routes/query.ts | 156 ++++++++++++------ 6 files changed, 144 insertions(+), 87 deletions(-) diff --git a/public/components/SQLPage/SQLPage.tsx b/public/components/SQLPage/SQLPage.tsx index c752e92..372c43c 100644 --- a/public/components/SQLPage/SQLPage.tsx +++ b/public/components/SQLPage/SQLPage.tsx @@ -34,7 +34,7 @@ interface SQLPageProps { onClear: () => void; updateSQLQueries: (query: string) => void; sqlQuery: string; - sqlTranslations: ResponseDetail[]; + sqlTranslations: Array>; selectedDatasource: EuiComboBoxOptionOption[]; asyncLoading: boolean; openAccelerationFlyout: boolean; @@ -68,7 +68,10 @@ export class SQLPage extends React.Component { } setAccelerationFlyout = () => { - this.renderCreateAccelerationFlyout(this.props.selectedDatasource[0].label,this.props.dataSourceMDSId); + this.renderCreateAccelerationFlyout({ + dataSource: this.props.selectedDatasource[0].label, + dataSourceMDSId: this.props.dataSourceMDSId, + }); }; componentDidUpdate(prevProps: SQLPageProps) { @@ -214,7 +217,10 @@ export class SQLPage extends React.Component { - this.renderCreateAccelerationFlyout(this.props.selectedDatasource[0].label,this.props.dataSourceMDSId) + this.renderCreateAccelerationFlyout({ + dataSource: this.props.selectedDatasource[0].label, + dataSourceMDSId: this.props.dataSourceMDSId, + }) } isDisabled={this.props.asyncLoading} > diff --git a/public/dependencies/register_observability_dependencies.tsx b/public/dependencies/register_observability_dependencies.tsx index c21c6f8..c1ca5b6 100644 --- a/public/dependencies/register_observability_dependencies.tsx +++ b/public/dependencies/register_observability_dependencies.tsx @@ -5,8 +5,7 @@ import { createGetterSetter } from '../../../../src/plugins/opensearch_dashboards_utils/public'; import { catalogCacheRefs } from '../framework/catalog_cache_refs'; -import { ObservabilityStart } from '../types'; - +import { ObservabilityStart, RenderAccelerationFlyoutParams } from '../types'; export const [ getRenderAccelerationDetailsFlyout, setRenderAccelerationDetailsFlyout, @@ -20,7 +19,9 @@ export const [ export const [ getRenderCreateAccelerationFlyout, setRenderCreateAccelerationFlyout, -] = createGetterSetter<(dataSource: string, dataSourceMDSId?: string) => void>('renderCreateAccelerationFlyout'); +] = createGetterSetter<({ dataSource, dataSourceMDSId }: RenderAccelerationFlyoutParams) => void>( + 'renderCreateAccelerationFlyout' +); export const registerObservabilityDependencies = (start?: ObservabilityStart) => { if (!start) { diff --git a/public/types.ts b/public/types.ts index 9ed0ed5..5104f28 100644 --- a/public/types.ts +++ b/public/types.ts @@ -7,11 +7,11 @@ import { DataSourcePluginStart } from '../../../src/plugins/data_source/public/t import { NavigationPublicPluginStart } from '../../../src/plugins/navigation/public'; import { ObservabilityStart } from './types'; +// eslint-disable-next-line @typescript-eslint/no-empty-interface export interface WorkbenchPluginSetup {} // eslint-disable-next-line @typescript-eslint/no-empty-interface -export interface WorkbenchPluginStart { -} +export interface WorkbenchPluginStart {} export interface AppPluginStartDependencies { navigation: NavigationPublicPluginStart; @@ -20,3 +20,5 @@ export interface AppPluginStartDependencies { } export type { ObservabilityStart } from '../../dashboards-observability/public'; + +export type { RenderAccelerationFlyoutParams } from '../../dashboards-observability/common/types/data_connections'; diff --git a/server/plugin.ts b/server/plugin.ts index d414af6..8e58d62 100644 --- a/server/plugin.ts +++ b/server/plugin.ts @@ -3,20 +3,12 @@ * SPDX-License-Identifier: Apache-2.0 */ - -import { - CoreSetup, - CoreStart, - ILegacyClusterClient, - Logger, - Plugin, - PluginInitializerContext, -} from '../../../src/core/server'; +import { CoreSetup, Logger, Plugin, PluginInitializerContext } from '../../../src/core/server'; import { DataSourcePluginSetup } from '../../../src/plugins/data_source/server/types'; import { DataSourceManagementPlugin } from '../../../src/plugins/data_source_management/public/plugin'; import sqlPlugin from './clusters/sql/sqlPlugin'; -import defineRoutes from './routes'; +import { defineRoutes } from './routes'; import { WorkbenchPluginSetup, WorkbenchPluginStart } from './types'; export interface WorkbenchPluginSetupDependencies { @@ -31,22 +23,17 @@ export class WorkbenchPlugin implements Plugin> => { + async ( + context, + request, + response + ): Promise> => { const retVal = await service.describeSQLQuery(context, request); return response.ok({ body: retVal, @@ -46,11 +49,15 @@ export default function query(server: IRouter, service: QueryService, openSearch validate: { body: schema.any(), query: schema.object({ - dataSourceMDSId: schema.maybe(schema.string({ defaultValue: '' })) - }) + dataSourceMDSId: schema.maybe(schema.string({ defaultValue: '' })), + }), }, }, - async (context, request, response): Promise> => { + async ( + context, + request, + response + ): Promise> => { const retVal = await service.describePPLQuery(context, request); return response.ok({ body: retVal, @@ -64,11 +71,15 @@ export default function query(server: IRouter, service: QueryService, openSearch validate: { body: schema.any(), query: schema.object({ - dataSourceMDSId: schema.maybe(schema.string({ defaultValue: '' })) - }) + dataSourceMDSId: schema.maybe(schema.string({ defaultValue: '' })), + }), }, }, - async (context, request, response): Promise> => { + async ( + context, + request, + response + ): Promise> => { const retVal = await service.describeSQLCsv(context, request); return response.ok({ body: retVal, @@ -82,11 +93,15 @@ export default function query(server: IRouter, service: QueryService, openSearch validate: { body: schema.any(), query: schema.object({ - dataSourceMDSId: schema.maybe(schema.string({ defaultValue: '' })) - }) + dataSourceMDSId: schema.maybe(schema.string({ defaultValue: '' })), + }), }, }, - async (context, request, response): Promise> => { + async ( + context, + request, + response + ): Promise> => { const retVal = await service.describePPLCsv(context, request); return response.ok({ body: retVal, @@ -100,11 +115,15 @@ export default function query(server: IRouter, service: QueryService, openSearch validate: { body: schema.any(), query: schema.object({ - dataSourceMDSId: schema.maybe(schema.string({ defaultValue: '' })) - }) + dataSourceMDSId: schema.maybe(schema.string({ defaultValue: '' })), + }), }, }, - async (context, request, response): Promise> => { + async ( + context, + request, + response + ): Promise> => { const retVal = await service.describeSQLJson(context, request); return response.ok({ body: retVal, @@ -118,11 +137,15 @@ export default function query(server: IRouter, service: QueryService, openSearch validate: { body: schema.any(), query: schema.object({ - dataSourceMDSId: schema.maybe(schema.string({ defaultValue: '' })) - }) + dataSourceMDSId: schema.maybe(schema.string({ defaultValue: '' })), + }), }, }, - async (context, request, response): Promise> => { + async ( + context, + request, + response + ): Promise> => { const retVal = await service.describePPLJson(context, request); return response.ok({ body: retVal, @@ -136,11 +159,15 @@ export default function query(server: IRouter, service: QueryService, openSearch validate: { body: schema.any(), query: schema.object({ - dataSourceMDSId: schema.maybe(schema.string({ defaultValue: '' })) - }) + dataSourceMDSId: schema.maybe(schema.string({ defaultValue: '' })), + }), }, }, - async (context, request, response): Promise> => { + async ( + context, + request, + response + ): Promise> => { const retVal = await service.describeSQLText(context, request); return response.ok({ body: retVal, @@ -154,11 +181,15 @@ export default function query(server: IRouter, service: QueryService, openSearch validate: { body: schema.any(), query: schema.object({ - dataSourceMDSId: schema.maybe(schema.string({ defaultValue: '' })) - }) + dataSourceMDSId: schema.maybe(schema.string({ defaultValue: '' })), + }), }, }, - async (context, request, response): Promise> => { + async ( + context, + request, + response + ): Promise> => { const retVal = await service.describePPLText(context, request); return response.ok({ body: retVal, @@ -172,73 +203,94 @@ export default function query(server: IRouter, service: QueryService, openSearch validate: { body: schema.any(), query: schema.object({ - dataSourceMDSId: schema.maybe(schema.string({ defaultValue: '' })) - }) + dataSourceMDSId: schema.maybe(schema.string({ defaultValue: '' })), + }), }, }, - async (context, request, response): Promise> => { + async ( + context, + request, + response + ): Promise> => { const retVal = await service.describeSQLAsyncQuery(context, request); return response.ok({ body: retVal, }); } - ) + ); server.get( { - path: ROUTE_PATH_SPARK_SQL_JOB_QUERY + "/{id}" + "/{dataSourceMDSId}", + path: ROUTE_PATH_SPARK_SQL_JOB_QUERY + '/{id}' + '/{dataSourceMDSId?}', validate: { params: schema.object({ id: schema.string(), - dataSourceMDSId: schema.maybe(schema.string({ defaultValue: '' })) + dataSourceMDSId: schema.maybe(schema.string({ defaultValue: '' })), }), }, }, - async (context, request, response): Promise> => { - const retVal = await service.describeSQLAsyncGetQuery(context, request, request.params.id, request.params.dataSourceMDSId); + async ( + context, + request, + response + ): Promise> => { + const retVal = await service.describeSQLAsyncGetQuery( + context, + request, + request.params.id, + request.params.dataSourceMDSId + ); return response.ok({ body: retVal, }); } - ) + ); server.delete( { - path: ROUTE_PATH_SPARK_SQL_JOB_QUERY + "/{id}" + "/{dataSourceMDSId?}", + path: ROUTE_PATH_SPARK_SQL_JOB_QUERY + '/{id}' + '/{dataSourceMDSId?}', validate: { params: schema.object({ id: schema.string(), - dataSourceMDSId: schema.maybe(schema.string({ defaultValue: '' })) + dataSourceMDSId: schema.maybe(schema.string({ defaultValue: '' })), }), - query: schema.object({ - dataSourceMDSId: schema.maybe(schema.string({ defaultValue: '' })) - }) }, }, - async (context, request, response): Promise> => { - const retVal = await service.describeAsyncDeleteQuery(context, request, request.params.id, request.params.dataSourceMDSId); + async ( + context, + request, + response + ): Promise> => { + const retVal = await service.describeAsyncDeleteQuery( + context, + request, + request.params.id, + request.params.dataSourceMDSId + ); return response.ok({ body: retVal, }); } - ) - + ); + server.get( { path: `${ROUTE_PATH_GET_DATASOURCES}/{dataSourceMDSId?}`, validate: { params: schema.object({ - dataSourceMDSId: schema.maybe(schema.string({ defaultValue: '' })) + dataSourceMDSId: schema.maybe(schema.string({ defaultValue: '' })), }), }, }, - async (context, request, response): Promise> => { + async ( + context, + request, + response + ): Promise> => { const retVal = await service.describeSyncQueryDataSources(context, request); return response.ok({ body: retVal, }); } - ) - - -} \ No newline at end of file + ); +}