-
Notifications
You must be signed in to change notification settings - Fork 892
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Tyler Ohlsen <ohltyler@amazon.com>
- Loading branch information
Showing
11 changed files
with
246 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/plugins/expressions/common/expression_types/specs/vis_layers.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { ExpressionTypeDefinition } from '../types'; | ||
import { VisLayers } from '../../../../../../src/plugins/plugin_integration/common'; | ||
|
||
const name = 'vis_layers'; | ||
|
||
export interface ExprVisLayers { | ||
type: typeof name; | ||
layers: VisLayers; | ||
} | ||
|
||
// Setting default empty arrays for null & undefined edge cases | ||
export const visLayers: ExpressionTypeDefinition<typeof name, ExprVisLayers> = { | ||
name, | ||
from: { | ||
null: () => { | ||
return { | ||
type: name, | ||
layers: [] as VisLayers, | ||
} as ExprVisLayers; | ||
}, | ||
undefined: () => { | ||
return { | ||
type: name, | ||
layers: [] as VisLayers, | ||
} as ExprVisLayers; | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
export { | ||
VisLayer, | ||
VisLayers, | ||
PointInTimeEventsVisLayer, | ||
PointInTimeEvent, | ||
PointInTimeEventMetadata, | ||
isPointInTimeEventsVisLayer, | ||
VisLayerResponseValue, | ||
VisLayerFunctionDefinition, | ||
} from './types'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { VisLayer, isPointInTimeEventsVisLayer } from './types'; | ||
|
||
describe('isPointInTimeEventsVisLayer()', function () { | ||
it('should return false if no events field', function () { | ||
const visLayer = { | ||
id: 'visLayerId', | ||
name: 'visLayerName', | ||
field1: 'value1', | ||
field2: 'value2', | ||
} as VisLayer; | ||
expect(isPointInTimeEventsVisLayer(visLayer)).toBe(false); | ||
}); | ||
|
||
it('should return true if events field exists', function () { | ||
const visLayer = { | ||
id: 'testId', | ||
name: 'testName', | ||
events: [ | ||
{ | ||
timestamp: 123, | ||
resourceId: 'testId', | ||
resourceName: 'testName', | ||
}, | ||
], | ||
} as VisLayer; | ||
expect(isPointInTimeEventsVisLayer(visLayer)).toBe(true); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { ExpressionFunctionDefinition } from '../../expressions'; | ||
|
||
export interface VisLayer { | ||
// will be used as the column ID | ||
id: string; | ||
// will be used as the name when hovering over the tooltip | ||
name: string; | ||
} | ||
|
||
export type VisLayers = VisLayer[]; | ||
|
||
export interface PointInTimeEventMetadata { | ||
resourceId: string; | ||
resourceName: string; | ||
tooltip?: string; | ||
} | ||
|
||
export interface PointInTimeEvent { | ||
timestamp: number; | ||
metadata: PointInTimeEventMetadata; | ||
} | ||
|
||
export interface PointInTimeEventsVisLayer extends VisLayer { | ||
events: PointInTimeEvent[]; | ||
} | ||
|
||
// used to determine what vis layer's interface is being implemented. | ||
// currently PointInTimeEventsLayer is the only interface extending VisLayer | ||
export const isPointInTimeEventsVisLayer = (obj: any) => { | ||
return 'events' in obj; | ||
}; | ||
|
||
export interface VisLayerResponseValue { | ||
visLayers: object; | ||
} | ||
|
||
export type VisLayerFunctionDefinition = ExpressionFunctionDefinition< | ||
string, | ||
VisLayerResponseValue, | ||
any, | ||
Promise<VisLayerResponseValue> | ||
>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"id": "pluginIntegration", | ||
"version": "opensearchDashboards", | ||
"server": true, | ||
"ui": true, | ||
"requiredPlugins": ["data", "savedObjects", "opensearchDashboardsUtils"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { PluginInitializerContext } from 'src/core/public'; | ||
import { PluginIntegrationPlugin, PluginIntegrationSetup, PluginIntegrationStart } from './plugin'; | ||
|
||
export function plugin(initializerContext: PluginInitializerContext) { | ||
return new PluginIntegrationPlugin(initializerContext); | ||
} | ||
export { PluginIntegrationSetup, PluginIntegrationStart }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { PluginInitializerContext, CoreSetup, CoreStart, Plugin } from '../../../core/public'; | ||
import { DataPublicPluginSetup, DataPublicPluginStart } from '../../data/public'; | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-empty-interface | ||
export interface PluginIntegrationSetup {} | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-empty-interface | ||
export interface PluginIntegrationStart {} | ||
|
||
export interface PluginIntegrationSetupDeps { | ||
data: DataPublicPluginSetup; | ||
} | ||
|
||
export interface PluginIntegrationStartDeps { | ||
data: DataPublicPluginStart; | ||
} | ||
|
||
export class PluginIntegrationPlugin | ||
implements | ||
Plugin< | ||
PluginIntegrationSetup, | ||
PluginIntegrationStart, | ||
PluginIntegrationSetupDeps, | ||
PluginIntegrationStartDeps | ||
> { | ||
constructor(initializerContext: PluginInitializerContext) {} | ||
|
||
public setup( | ||
core: CoreSetup<PluginIntegrationStartDeps, PluginIntegrationStart>, | ||
{ data }: PluginIntegrationSetupDeps | ||
): PluginIntegrationSetup { | ||
return {}; | ||
} | ||
|
||
public start(core: CoreStart, { data }: PluginIntegrationStartDeps): PluginIntegrationStart { | ||
return {}; | ||
} | ||
|
||
public stop() {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { PluginInitializerContext } from '../../../core/server'; | ||
import { PluginIntegrationPlugin } from './plugin'; | ||
|
||
export function plugin(initializerContext: PluginInitializerContext) { | ||
return new PluginIntegrationPlugin(initializerContext); | ||
} | ||
export { PluginIntegrationPluginSetup, PluginIntegrationPluginStart } from './plugin'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { | ||
PluginInitializerContext, | ||
CoreSetup, | ||
CoreStart, | ||
Plugin, | ||
Logger, | ||
} from '../../../core/server'; | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-empty-interface | ||
export interface PluginIntegrationPluginSetup {} | ||
// eslint-disable-next-line @typescript-eslint/no-empty-interface | ||
export interface PluginIntegrationPluginStart {} | ||
|
||
export class PluginIntegrationPlugin | ||
implements Plugin<PluginIntegrationPluginSetup, PluginIntegrationPluginStart> { | ||
private readonly logger: Logger; | ||
|
||
constructor(initializerContext: PluginInitializerContext) { | ||
this.logger = initializerContext.logger.get(); | ||
} | ||
|
||
public setup(core: CoreSetup) { | ||
this.logger.debug('pluginIntegration: Setup'); | ||
return {}; | ||
} | ||
|
||
public start(core: CoreStart) { | ||
this.logger.debug('pluginIntegration: Started'); | ||
return {}; | ||
} | ||
|
||
public stop() {} | ||
} |