Skip to content

Commit b498d80

Browse files
committed
Add @kbn/data-views-as-code plugin
1 parent bfb1b79 commit b498d80

11 files changed

Lines changed: 147 additions & 0 deletions

File tree

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,7 @@
578578
"@kbn/data-view-management-plugin": "link:src/platform/plugins/shared/data_view_management",
579579
"@kbn/data-view-utils": "link:src/platform/packages/shared/kbn-data-view-utils",
580580
"@kbn/data-view-validation": "link:src/platform/packages/shared/kbn-data-view-validation",
581+
"@kbn/data-views-as-code-plugin": "link:src/platform/plugins/shared/data_views_as_code",
581582
"@kbn/data-views-plugin": "link:src/platform/plugins/shared/data_views",
582583
"@kbn/data-visualizer-plugin": "link:x-pack/platform/plugins/private/data_visualizer",
583584
"@kbn/dataset-quality-plugin": "link:x-pack/platform/plugins/shared/dataset_quality",
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Data views as code
2+
3+
This plugin contains the defined endpoints for data views as code, following the as code standards.
4+
5+
Why a different plugin from `@kbn/data-views-plugin`? Because the as code utilities, schemas and transforms, rely on `@kbn/data-views-plugin` mainly for typing. This means that we can't reuse this utilities inside `@kbn/data-views-plugin` without causing a circular dependency. That can be fixed by creating a new package that relies on this pieces.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"type": "plugin",
3+
"id": "@kbn/data-views-as-code-plugin",
4+
"owner": ["@elastic/kibana-data-discovery"],
5+
"group": "platform",
6+
"visibility": "shared",
7+
"description": "The data views as code plugin offers different endpoints following the as code standards",
8+
"plugin": {
9+
"id": "dataViewsAsCode",
10+
"browser": false,
11+
"server": true,
12+
"requiredPlugins": ["dataViews"],
13+
"optionalPlugins": [],
14+
"requiredBundles": [],
15+
"extraPublicDirs": []
16+
}
17+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# This file is generated by the @kbn/moon package. Any manual edits will be erased!
2+
# To extend this, write your extensions/overrides to 'moon.extend.yml'
3+
# then regenerate this file with: 'node scripts/regenerate_moon_projects.js --update --filter @kbn/visualization-listing-plugin'
4+
5+
$schema: https://moonrepo.dev/schemas/project.json
6+
id: '@kbn/data-views-as-code-plugin'
7+
layer: unknown
8+
owners:
9+
defaultOwner: '@elastic/kibana-data-discovery'
10+
toolchains:
11+
default: node
12+
language: typescript
13+
project:
14+
title: '@kbn/data-views-as-code-plugin'
15+
description: Moon project for @kbn/data-views-as-code-plugin
16+
channel: ''
17+
owner: '@elastic/kibana-data-discovery'
18+
sourceRoot: src/platform/plugins/shared/data_views_as_code
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the "Elastic License
4+
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
5+
* Public License v 1"; you may not use this file except in compliance with, at
6+
* your election, the "Elastic License 2.0", the "GNU Affero General Public
7+
* License v3.0 only", or the "Server Side Public License, v 1".
8+
*/
9+
10+
export async function plugin() {
11+
const { DataViewsAsCodeServerPlugin } = await import('./plugin');
12+
return new DataViewsAsCodeServerPlugin();
13+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the "Elastic License
4+
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
5+
* Public License v 1"; you may not use this file except in compliance with, at
6+
* your election, the "Elastic License 2.0", the "GNU Affero General Public
7+
* License v3.0 only", or the "Server Side Public License, v 1".
8+
*/
9+
10+
import type { CoreSetup, Plugin } from '@kbn/core/server';
11+
import { registerRoutes } from './routes';
12+
import type {
13+
DataViewsAsCodeServerPluginSetupDependencies,
14+
DataViewsAsCodeServerPluginStartDependencies,
15+
} from './types';
16+
17+
export class DataViewsAsCodeServerPlugin
18+
implements
19+
Plugin<
20+
void,
21+
void,
22+
DataViewsAsCodeServerPluginSetupDependencies,
23+
DataViewsAsCodeServerPluginStartDependencies
24+
>
25+
{
26+
public setup(core: CoreSetup<DataViewsAsCodeServerPluginStartDependencies, void>) {
27+
registerRoutes({ http: core.http });
28+
}
29+
30+
public start() {}
31+
32+
public stop() {}
33+
}
34+
35+
export { DataViewsAsCodeServerPlugin as Plugin };
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the "Elastic License
4+
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
5+
* Public License v 1"; you may not use this file except in compliance with, at
6+
* your election, the "Elastic License 2.0", the "GNU Affero General Public
7+
* License v3.0 only", or the "Server Side Public License, v 1".
8+
*/
9+
10+
import type { HttpServiceSetup } from '@kbn/core/server';
11+
export const INITIAL_REST_VERSION = '2023-10-31';
12+
13+
interface RegisterRoutesArgs {
14+
http: HttpServiceSetup;
15+
}
16+
17+
export function registerRoutes(_: RegisterRoutesArgs) {
18+
// The routes are going to be registered here at plugin setup
19+
// 1. GET /api/data_views/{id}
20+
// 2. POST /api/data_views
21+
// 3. PUT /api/data_views/{id}
22+
// 4. DELETE /api/data_views/{id}
23+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the "Elastic License
4+
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
5+
* Public License v 1"; you may not use this file except in compliance with, at
6+
* your election, the "Elastic License 2.0", the "GNU Affero General Public
7+
* License v3.0 only", or the "Server Side Public License, v 1".
8+
*/
9+
import type {
10+
DataViewsServerPluginSetup,
11+
DataViewsServerPluginStart,
12+
} from '@kbn/data-views-plugin/server';
13+
14+
export interface DataViewsAsCodeServerPluginSetupDependencies {
15+
dataViews: DataViewsServerPluginSetup;
16+
}
17+
18+
export interface DataViewsAsCodeServerPluginStartDependencies {
19+
dataViews: DataViewsServerPluginStart;
20+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"extends": "@kbn/tsconfig-base/tsconfig.json",
3+
"compilerOptions": {
4+
"outDir": "target/types"
5+
},
6+
"include": ["server/**/*"],
7+
"kbn_references": ["@kbn/core", "@kbn/data-views-plugin"],
8+
"exclude": ["target/**/*"]
9+
}

tsconfig.base.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -990,6 +990,8 @@
990990
"@kbn/data-view-utils/*": ["src/platform/packages/shared/kbn-data-view-utils/*"],
991991
"@kbn/data-view-validation": ["src/platform/packages/shared/kbn-data-view-validation"],
992992
"@kbn/data-view-validation/*": ["src/platform/packages/shared/kbn-data-view-validation/*"],
993+
"@kbn/data-views-as-code-plugin": ["src/platform/plugins/shared/data_views_as_code"],
994+
"@kbn/data-views-as-code-plugin/*": ["src/platform/plugins/shared/data_views_as_code/*"],
993995
"@kbn/data-views-plugin": ["src/platform/plugins/shared/data_views"],
994996
"@kbn/data-views-plugin/*": ["src/platform/plugins/shared/data_views/*"],
995997
"@kbn/data-visualizer-plugin": ["x-pack/platform/plugins/private/data_visualizer"],

0 commit comments

Comments
 (0)