Skip to content

Commit

Permalink
Add extra plugin for query enhancements (#6869)
Browse files Browse the repository at this point in the history
* add query enhancements plugin

Signed-off-by: Kawika Avilla <kavilla414@gmail.com>

* no submodule

Signed-off-by: Kawika Avilla <kavilla414@gmail.com>

---------

Signed-off-by: Kawika Avilla <kavilla414@gmail.com>
  • Loading branch information
kavilla committed Jun 3, 2024
1 parent e3aa6dc commit cb6ab68
Show file tree
Hide file tree
Showing 66 changed files with 8,274 additions and 2,019 deletions.
5 changes: 5 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ module.exports = {
'src/legacy/**/*',
'(src)/plugins/**/(public|server)/**/*',
'examples/**/*',
'plugins-extra/**/*',
],
from: [
'src/core/public/**/*',
Expand Down Expand Up @@ -322,6 +323,7 @@ module.exports = {
'src/legacy/**/*',
'(src)/plugins/**/(public|server)/**/*',
'examples/**/*',
'plugins-extra/**/*',
'!(src)/**/*.test.*',
],
from: [
Expand All @@ -338,13 +340,16 @@ module.exports = {
'!(src)/plugins/**/server/**/*',

'examples/**/*',
'plugins-extra/**/*',
'!examples/**/server/**/*',
'!plugins-extra/**/server/**/*',
],
from: [
'src/core/server',
'src/core/server/**/*',
'(src)/plugins/*/server/**/*',
'examples/**/server/**/*',
'plugins-extra/**/server/*',
],
errorMessage:
'Server modules cannot be imported into client modules or shared modules.',
Expand Down
4 changes: 2 additions & 2 deletions config/opensearch_dashboards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -333,9 +333,9 @@
# usageCollection.uiMetric.enabled: false

# Set the value to true to enable enhancements for the data plugin
# data.enhancements.enabled: false
data.enhancements.enabled: true

# Set the backend roles in groups or users, whoever has the backend roles or exactly match the user ids defined in this config will be regard as dashboard admin.
# Dashboard admin will have the access to all the workspaces(workspace.enabled: true) and objects inside OpenSearch Dashboards.
# opensearchDashboards.dashboardAdmin.groups: ["dashboard_admin"]
# opensearchDashboards.dashboardAdmin.users: ["dashboard_admin"]
# opensearchDashboards.dashboardAdmin.users: ["dashboard_admin"]
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@
"packages": [
"packages/*",
"examples/*",
"plugins-extra/*",
"test/plugin_functional/plugins/*",
"test/interpreter_functional/plugins/*"
],
Expand Down
1 change: 1 addition & 0 deletions packages/osd-config/src/__mocks__/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export function getEnvOptions(options: DeepPartial<EnvOptions> = {}): EnvOptions
disableOptimizer: true,
cache: true,
dist: false,
extraPlugins: false,
runExamples: false,
...(options.cliArgs || {}),
},
Expand Down
2 changes: 2 additions & 0 deletions packages/osd-config/src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export interface CliArgs {
basePath: boolean;
/** @deprecated use disableOptimizer to know if the @osd/optimizer is disabled in development */
optimize?: boolean;
extraPlugins: boolean;
runExamples: boolean;
disableOptimizer: boolean;
cache: boolean;
Expand Down Expand Up @@ -133,6 +134,7 @@ export class Env {
this.pluginSearchPaths = [
resolve(this.homeDir, 'src', 'plugins'),
resolve(this.homeDir, 'plugins'),
...(options.cliArgs.extraPlugins ? [resolve(this.homeDir, 'plugins-extra')] : []),
...(options.cliArgs.runExamples ? [resolve(this.homeDir, 'examples')] : []),
resolve(this.homeDir, '..', 'opensearch-dashboards-extra'),
];
Expand Down
9 changes: 9 additions & 0 deletions packages/osd-optimizer/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ run(
throw createFlagError('expected --dist to have no value');
}

const extraPlugins = flags.extraPlugins ?? false;
if (typeof extraPlugins !== 'boolean') {
throw createFlagError('expected --extraPlugins to have no value');
}

const examples = flags.examples ?? false;
if (typeof examples !== 'boolean') {
throw createFlagError('expected --no-examples to have no value');
Expand Down Expand Up @@ -117,6 +122,7 @@ run(
maxWorkerCount,
dist: dist || updateLimits,
cache,
extraPlugins: extraPlugins && !(validateLimits || updateLimits),
examples: examples && !(validateLimits || updateLimits),
profileWebpack,
extraPluginScanDirs,
Expand Down Expand Up @@ -153,6 +159,7 @@ run(
boolean: [
'core',
'watch',
'extraPlugins',
'examples',
'dist',
'cache',
Expand All @@ -165,6 +172,7 @@ run(
string: ['workers', 'scan-dir', 'filter'],
default: {
core: true,
extraPlugins: false,
examples: true,
cache: true,
'inspect-workers': true,
Expand All @@ -177,6 +185,7 @@ run(
--no-core disable generating the core bundle
--no-cache disable the cache
--filter comma-separated list of bundle id filters, results from multiple flags are merged, * and ! are supported
--extra-plugins build the extra plugins
--no-examples don't build the example plugins
--dist create bundles that are suitable for inclusion in the OpenSearch Dashboards distributable, enabled when running with --update-limits
--scan-dir add a directory to the list of directories scanned for plugins (specify as many times as necessary)
Expand Down
4 changes: 4 additions & 0 deletions packages/osd-optimizer/src/node/node_auto_tranpilation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ const IGNORE_PATTERNS = [
// is `x-pack` and `b` is not `node_modules`
/[\/\\]node_modules[\/\\](?!x-pack[\/\\](?!node_modules)([^\/\\]+))([^\/\\]+[\/\\][^\/\\]+)/,

// ignore paths matching `/node_modules/{a}/{b}`, unless `a`
// is `plugins-extra` and `b` is not `node_modules`
/[\/\\]node_modules[\/\\](?!plugins-extra[\/\\](?!node_modules)([^\/\\]+))([^\/\\]+[\/\\][^\/\\]+)/,

// ignore any path in the packages, unless it is in the package's
// root `src` directory, in any test or __tests__ directory, or it
// ends with .test.js, .test.ts, or .test.tsx
Expand Down
4 changes: 4 additions & 0 deletions packages/osd-optimizer/src/optimizer/optimizer_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ interface Options {
/** set to true to inspecting workers when the parent process is being inspected */
inspectWorkers?: boolean;

/** include extra plugins in default scan dirs */
extraPlugins?: boolean;
/** include examples in default scan dirs */
examples?: boolean;
/** absolute paths to specific plugins that should be built */
Expand Down Expand Up @@ -153,6 +155,7 @@ export class OptimizerConfig {
static parseOptions(options: Options): ParsedOptions {
const watch = !!options.watch;
const dist = !!options.dist;
const extraPlugins = !!options.extraPlugins;
const examples = !!options.examples;
const profileWebpack = !!options.profileWebpack;
const inspectWorkers = !!options.inspectWorkers;
Expand All @@ -178,6 +181,7 @@ export class OptimizerConfig {
const pluginScanDirs = options.pluginScanDirs || [
Path.resolve(repoRoot, 'src/plugins'),
Path.resolve(repoRoot, 'plugins'),
...(extraPlugins ? [Path.resolve('plugins-extra')] : []),
...(examples ? [Path.resolve('examples')] : []),
Path.resolve(repoRoot, 'opensearch-dashboards-extra'),
];
Expand Down
4 changes: 4 additions & 0 deletions packages/osd-plugin-generator/src/ask_questions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ export interface Answers {
}

export const INTERNAL_PLUGIN_LOCATIONS: Array<{ name: string; value: string }> = [
{
name: 'OpenSearch Dashboards Extra',
value: Path.resolve(REPO_ROOT, 'plugins-extra'),
},
{
name: 'OpenSearch Dashboards Example',
value: Path.resolve(REPO_ROOT, 'examples'),
Expand Down
4 changes: 4 additions & 0 deletions packages/osd-plugin-generator/src/plugin_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ export const PLUGIN_TYPE_OPTIONS: Array<{ name: string; value: PluginType }> = [
name: 'Installable plugin',
value: { thirdParty: true, installDir: Path.resolve(REPO_ROOT, 'plugins') },
},
{
name: 'OpenSearch Dashboards Extra',
value: { thirdParty: false, installDir: Path.resolve(REPO_ROOT, 'plugins-extra') },
},
{
name: 'OpenSearch Dashboards Example',
value: { thirdParty: false, installDir: Path.resolve(REPO_ROOT, 'examples') },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,11 @@ export function loadOpenSearchDashboardsPlatformPlugin(pluginDir: string) {
const parentDir = Path.resolve(pluginDir, '..');

const isFixture = pluginDir.includes('__fixtures__');
const isExtra = Path.basename(parentDir) === 'plugins-extra';
const isExample = Path.basename(parentDir) === 'examples';
const isRootPlugin = parentDir === Path.resolve(REPO_ROOT, 'plugins');

if (isFixture || isExample || isRootPlugin) {
if (isFixture || isExtra || isExample || isRootPlugin) {
return parseOpenSearchDashboardsPlatformPlugin(
Path.resolve(pluginDir, 'opensearch_dashboards.json')
);
Expand Down
Loading

0 comments on commit cb6ab68

Please sign in to comment.