mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
[Console] Remove unused spec-to-console package (#193426)
Closes https://github.com/elastic/kibana/issues/163333 ## Summary It was superseded by generate-console-definitions. ### For maintainers - [ ] This was checked for breaking API changes and was [labeled appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Elena Stoeva <59341489+ElenaStoeva@users.noreply.github.com>
This commit is contained in:
parent
65c7208290
commit
920d782392
24 changed files with 0 additions and 676 deletions
1
.github/CODEOWNERS
vendored
1
.github/CODEOWNERS
vendored
|
@ -898,7 +898,6 @@ packages/kbn-sort-package-json @elastic/kibana-operations
|
|||
packages/kbn-sort-predicates @elastic/kibana-visualizations
|
||||
x-pack/plugins/spaces @elastic/kibana-security
|
||||
x-pack/test/spaces_api_integration/common/plugins/spaces_test_plugin @elastic/kibana-security
|
||||
packages/kbn-spec-to-console @elastic/kibana-management
|
||||
packages/kbn-sse-utils @elastic/obs-knowledge-team
|
||||
packages/kbn-sse-utils-client @elastic/obs-knowledge-team
|
||||
packages/kbn-sse-utils-server @elastic/obs-knowledge-team
|
||||
|
|
|
@ -82,7 +82,6 @@ yarn kbn watch
|
|||
- @kbn/securitysolution-utils
|
||||
- @kbn/server-http-tools
|
||||
- @kbn/server-route-repository
|
||||
- @kbn/spec-to-console
|
||||
- @kbn/std
|
||||
- @kbn/storybook
|
||||
- @kbn/telemetry-utils
|
||||
|
|
|
@ -1475,7 +1475,6 @@
|
|||
"@kbn/serverless-storybook-config": "link:packages/serverless/storybook/config",
|
||||
"@kbn/some-dev-log": "link:packages/kbn-some-dev-log",
|
||||
"@kbn/sort-package-json": "link:packages/kbn-sort-package-json",
|
||||
"@kbn/spec-to-console": "link:packages/kbn-spec-to-console",
|
||||
"@kbn/stdio-dev-helpers": "link:packages/kbn-stdio-dev-helpers",
|
||||
"@kbn/storybook": "link:packages/kbn-storybook",
|
||||
"@kbn/synthetics-e2e": "link:x-pack/plugins/observability_solution/synthetics/e2e",
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
# Generate console definitions
|
||||
This package is a script to generate definitions used in Console to display autocomplete suggestions.
|
||||
The definitions files are generated from the Elasticsearch specification [repo](https://github.com/elastic/elasticsearch-specification).
|
||||
This script is
|
||||
a new implementation of an old `kbn-spec-to-console` package: The old script used [JSON specs](https://github.com/elastic/elasticsearch/tree/main/rest-api-spec) in the Elasticsearch repo as the source.
|
||||
|
||||
## Instructions
|
||||
1. Checkout the Elasticsearch specification [repo](https://github.com/elastic/elasticsearch-specification).
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
A mini utility to convert [Elasticsearch's REST spec](https://github.com/elastic/elasticsearch/blob/master/rest-api-spec) to Console's (Kibana) autocomplete format.
|
||||
|
||||
|
||||
It is used to semi-manually update Console's autocompletion rules.
|
||||
|
||||
### Retrieving the spec
|
||||
|
||||
If you don't have a copy of the Elasticsearch repo on your machine, follow these steps to clone only the rest API specs
|
||||
|
||||
```
|
||||
mkdir es-spec && cd es-spec
|
||||
git init
|
||||
git remote add origin https://github.com/elastic/elasticsearch
|
||||
git config core.sparsecheckout true
|
||||
echo "rest-api-spec/src/main/resources/rest-api-spec/api/*\nx-pack/plugin/src/test/resources/rest-api-spec/api/*" > .git/info/sparse-checkout
|
||||
git pull --depth=1 origin master
|
||||
```
|
||||
|
||||
### Usage
|
||||
|
||||
At the root of the Kibana repository, run the following commands:
|
||||
|
||||
```sh
|
||||
yarn spec_to_console -g "<ELASTICSEARCH-REPO-FOLDER>/rest-api-spec/src/main/resources/rest-api-spec/api/*" -d "src/plugins/console/server/lib/spec_definitions/json/generated"
|
||||
```
|
||||
|
||||
### Information used in Console that is not available in the REST spec
|
||||
|
||||
* Request bodies
|
||||
* Data fetched at runtime: indices, fields, snapshots, etc
|
||||
* Ad hoc additions
|
||||
|
||||
### Updating the script
|
||||
When converting query params defined in the REST API specs to console autocompletion definitions, the script relies on a set of known conversion rules specified in [lib/convert/params.js](https://github.com/elastic/kibana/blob/main/packages/kbn-spec-to-console/lib/convert/params.js).
|
||||
For example, `"keep_on_completion":{"type":"boolean"}` from REST API specs is converted to `"keep_on_completion": "__flag__"` in console autocomplete definitions.
|
||||
When an unknown parameter type is encountered in REST API specs, the script will throw an `Unexpected type error` and the file [lib/convert/params.js](https://github.com/elastic/kibana/blob/main/packages/kbn-spec-to-console/lib/convert/params.js) needs to be updated by adding a new conversion rule.
|
|
@ -1,69 +0,0 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the "Elastic License
|
||||
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
|
||||
* Public License v 1"; you may not use this file except in compliance with, at
|
||||
* your election, the "Elastic License 2.0", the "GNU Affero General Public
|
||||
* License v3.0 only", or the "Server Side Public License, v 1".
|
||||
*/
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const program = require('commander');
|
||||
const globby = require('globby');
|
||||
const chalk = require('chalk');
|
||||
|
||||
const packageJSON = require('../package.json');
|
||||
const convert = require('../lib/convert');
|
||||
|
||||
program
|
||||
.version(packageJSON.version)
|
||||
.option('-g --glob []', 'Files to convert')
|
||||
.option('-d --directory []', 'Output directory')
|
||||
.parse(process.argv);
|
||||
|
||||
if (!program.glob) {
|
||||
console.error('Expected input');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const files = globby.sync(program.glob);
|
||||
const totalFilesCount = files.length;
|
||||
let convertedFilesCount = 0;
|
||||
|
||||
console.log(chalk.bold(`Detected files (count: ${totalFilesCount}):`));
|
||||
console.log();
|
||||
console.log(files);
|
||||
console.log();
|
||||
|
||||
files.forEach((file) => {
|
||||
const spec = JSON.parse(fs.readFileSync(file));
|
||||
const convertedSpec = convert(spec);
|
||||
if (!Object.keys(convertedSpec).length) {
|
||||
console.log(
|
||||
// prettier-ignore
|
||||
`${chalk.yellow('Detected')} ${chalk.grey(file)} but no endpoints were converted; ${chalk.yellow('skipping')}...`
|
||||
);
|
||||
return;
|
||||
}
|
||||
const output = JSON.stringify(convertedSpec, null, 2);
|
||||
++convertedFilesCount;
|
||||
if (program.directory) {
|
||||
const outputName = path.basename(file);
|
||||
const outputPath = path.resolve(program.directory, outputName);
|
||||
try {
|
||||
fs.mkdirSync(program.directory, { recursive: true });
|
||||
fs.writeFileSync(outputPath, output + '\n');
|
||||
} catch (e) {
|
||||
console.log('Cannot write file ', e);
|
||||
}
|
||||
} else {
|
||||
console.log(output);
|
||||
}
|
||||
});
|
||||
|
||||
console.log();
|
||||
// prettier-ignore
|
||||
console.log(`${chalk.grey('Converted')} ${chalk.bold(`${convertedFilesCount}/${totalFilesCount}`)} ${chalk.grey('files')}`);
|
||||
console.log(`Check your ${chalk.bold('git status')}.`);
|
||||
console.log();
|
|
@ -1,11 +0,0 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the "Elastic License
|
||||
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
|
||||
* Public License v 1"; you may not use this file except in compliance with, at
|
||||
* your election, the "Elastic License 2.0", the "GNU Affero General Public
|
||||
* License v3.0 only", or the "Server Side Public License, v 1".
|
||||
*/
|
||||
|
||||
const convert = require('./lib/convert');
|
||||
module.exports = convert;
|
|
@ -1,14 +0,0 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the "Elastic License
|
||||
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
|
||||
* Public License v 1"; you may not use this file except in compliance with, at
|
||||
* your election, the "Elastic License 2.0", the "GNU Affero General Public
|
||||
* License v3.0 only", or the "Server Side Public License, v 1".
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
preset: '@kbn/test',
|
||||
rootDir: '../..',
|
||||
roots: ['<rootDir>/packages/kbn-spec-to-console'],
|
||||
};
|
|
@ -1,6 +0,0 @@
|
|||
{
|
||||
"type": "shared-common",
|
||||
"id": "@kbn/spec-to-console",
|
||||
"devOnly": true,
|
||||
"owner": "@elastic/kibana-management"
|
||||
}
|
|
@ -1,45 +0,0 @@
|
|||
{
|
||||
"cluster.health": {
|
||||
"url_params": {
|
||||
"expand_wildcards": [
|
||||
"open",
|
||||
"closed",
|
||||
"none",
|
||||
"all"
|
||||
],
|
||||
"level": [
|
||||
"cluster",
|
||||
"indices",
|
||||
"shards"
|
||||
],
|
||||
"local": "__flag__",
|
||||
"master_timeout": "",
|
||||
"timeout": "",
|
||||
"wait_for_active_shards": "",
|
||||
"wait_for_nodes": "",
|
||||
"wait_for_events": [
|
||||
"immediate",
|
||||
"urgent",
|
||||
"high",
|
||||
"normal",
|
||||
"low",
|
||||
"languid"
|
||||
],
|
||||
"wait_for_no_relocating_shards": "__flag__",
|
||||
"wait_for_no_initializing_shards": "__flag__",
|
||||
"wait_for_status": [
|
||||
"green",
|
||||
"yellow",
|
||||
"red"
|
||||
]
|
||||
},
|
||||
"methods": [
|
||||
"GET"
|
||||
],
|
||||
"patterns": [
|
||||
"_cluster/health",
|
||||
"_cluster/health/{index}"
|
||||
],
|
||||
"documentation": "https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-health.html"
|
||||
}
|
||||
}
|
|
@ -1,104 +0,0 @@
|
|||
{
|
||||
"cluster.health":{
|
||||
"documentation":{
|
||||
"url":"https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-health.html",
|
||||
"description":"Returns basic information about the health of the cluster."
|
||||
},
|
||||
"stability":"stable",
|
||||
"url":{
|
||||
"paths":[
|
||||
{
|
||||
"path":"/_cluster/health",
|
||||
"methods":[
|
||||
"GET"
|
||||
]
|
||||
},
|
||||
{
|
||||
"path":"/_cluster/health/{index}",
|
||||
"methods":[
|
||||
"GET"
|
||||
],
|
||||
"parts":{
|
||||
"index":{
|
||||
"type":"list",
|
||||
"description":"Limit the information returned to a specific index"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"params":{
|
||||
"expand_wildcards":{
|
||||
"type":"enum",
|
||||
"options":[
|
||||
"open",
|
||||
"closed",
|
||||
"none",
|
||||
"all"
|
||||
],
|
||||
"default":"all",
|
||||
"description":"Whether to expand wildcard expression to concrete indices that are open, closed or both."
|
||||
},
|
||||
"level":{
|
||||
"type":"enum",
|
||||
"options":[
|
||||
"cluster",
|
||||
"indices",
|
||||
"shards"
|
||||
],
|
||||
"default":"cluster",
|
||||
"description":"Specify the level of detail for returned information"
|
||||
},
|
||||
"local":{
|
||||
"type":"boolean",
|
||||
"description":"Return local information, do not retrieve the state from master node (default: false)"
|
||||
},
|
||||
"master_timeout":{
|
||||
"type":"time",
|
||||
"description":"Explicit operation timeout for connection to master node"
|
||||
},
|
||||
"timeout":{
|
||||
"type":"time",
|
||||
"description":"Explicit operation timeout"
|
||||
},
|
||||
"wait_for_active_shards":{
|
||||
"type":"string",
|
||||
"description":"Wait until the specified number of shards is active"
|
||||
},
|
||||
"wait_for_nodes":{
|
||||
"type":"string",
|
||||
"description":"Wait until the specified number of nodes is available"
|
||||
},
|
||||
"wait_for_events":{
|
||||
"type":"enum",
|
||||
"options":[
|
||||
"immediate",
|
||||
"urgent",
|
||||
"high",
|
||||
"normal",
|
||||
"low",
|
||||
"languid"
|
||||
],
|
||||
"description":"Wait until all currently queued events with the given priority are processed"
|
||||
},
|
||||
"wait_for_no_relocating_shards":{
|
||||
"type":"boolean",
|
||||
"description":"Whether to wait until there are no relocating shards in the cluster"
|
||||
},
|
||||
"wait_for_no_initializing_shards":{
|
||||
"type":"boolean",
|
||||
"description":"Whether to wait until there are no initializing shards in the cluster"
|
||||
},
|
||||
"wait_for_status":{
|
||||
"type":"enum",
|
||||
"options":[
|
||||
"green",
|
||||
"yellow",
|
||||
"red"
|
||||
],
|
||||
"default":null,
|
||||
"description":"Wait until cluster is in a specific state"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
{
|
||||
"snapshot.get": {
|
||||
"url_params": {
|
||||
"master_timeout": "",
|
||||
"ignore_unavailable": "__flag__",
|
||||
"index_names": "__flag__",
|
||||
"index_details": "__flag__",
|
||||
"include_repository": "__flag__",
|
||||
"sort": [
|
||||
"start_time",
|
||||
"duration",
|
||||
"name",
|
||||
"repository",
|
||||
"index_count",
|
||||
"shard_count",
|
||||
"failed_shard_count"
|
||||
],
|
||||
"size": 0,
|
||||
"order": [
|
||||
"asc",
|
||||
"desc"
|
||||
],
|
||||
"from_sort_value": "",
|
||||
"after": "",
|
||||
"offset": 0,
|
||||
"slm_policy_filter": "",
|
||||
"verbose": "__flag__"
|
||||
},
|
||||
"methods": [
|
||||
"GET"
|
||||
],
|
||||
"patterns": [
|
||||
"_snapshot/{repository}/{snapshot}"
|
||||
],
|
||||
"documentation": "https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html"
|
||||
}
|
||||
}
|
|
@ -1,91 +0,0 @@
|
|||
{
|
||||
"snapshot.get":{
|
||||
"documentation":{
|
||||
"url":"https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html",
|
||||
"description":"Returns information about a snapshot."
|
||||
},
|
||||
"stability":"stable",
|
||||
"visibility":"public",
|
||||
"headers":{
|
||||
"accept": [ "application/json"]
|
||||
},
|
||||
"url":{
|
||||
"paths":[
|
||||
{
|
||||
"path":"/_snapshot/{repository}/{snapshot}",
|
||||
"methods":[
|
||||
"GET"
|
||||
],
|
||||
"parts":{
|
||||
"repository":{
|
||||
"type":"string",
|
||||
"description":"A repository name"
|
||||
},
|
||||
"snapshot":{
|
||||
"type":"list",
|
||||
"description":"A comma-separated list of snapshot names"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"params":{
|
||||
"master_timeout":{
|
||||
"type":"time",
|
||||
"description":"Explicit operation timeout for connection to master node"
|
||||
},
|
||||
"ignore_unavailable":{
|
||||
"type":"boolean",
|
||||
"description":"Whether to ignore unavailable snapshots, defaults to false which means a SnapshotMissingException is thrown"
|
||||
},
|
||||
"index_names":{
|
||||
"type":"boolean",
|
||||
"description":"Whether to include the name of each index in the snapshot. Defaults to true."
|
||||
},
|
||||
"index_details":{
|
||||
"type":"boolean",
|
||||
"description":"Whether to include details of each index in the snapshot, if those details are available. Defaults to false."
|
||||
},
|
||||
"include_repository":{
|
||||
"type":"boolean",
|
||||
"description":"Whether to include the repository name in the snapshot info. Defaults to true."
|
||||
},
|
||||
"sort": {
|
||||
"type": "enum",
|
||||
"default": "start_time",
|
||||
"options": ["start_time", "duration", "name", "repository", "index_count", "shard_count", "failed_shard_count"],
|
||||
"description": "Allows setting a sort order for the result. Defaults to start_time"
|
||||
},
|
||||
"size": {
|
||||
"type": "integer",
|
||||
"description": "Maximum number of snapshots to return. Defaults to 0 which means return all that match without limit."
|
||||
},
|
||||
"order": {
|
||||
"type": "enum",
|
||||
"default": "asc",
|
||||
"options": ["asc", "desc"],
|
||||
"description": "Sort order"
|
||||
},
|
||||
"from_sort_value": {
|
||||
"type": "string",
|
||||
"description": "Value of the current sort column at which to start retrieval."
|
||||
},
|
||||
"after": {
|
||||
"type": "string",
|
||||
"description": "Offset identifier to start pagination from as returned by the 'next' field in the response body."
|
||||
},
|
||||
"offset": {
|
||||
"type": "integer",
|
||||
"description": "Numeric offset to start pagination based on the snapshots matching the request. Defaults to 0"
|
||||
},
|
||||
"slm_policy_filter": {
|
||||
"type": "string",
|
||||
"description": "Filter snapshots by a comma-separated list of SLM policy names that snapshots belong to. Accepts wildcards. Use the special pattern '_none' to match snapshots without an SLM policy"
|
||||
},
|
||||
"verbose":{
|
||||
"type":"boolean",
|
||||
"description":"Whether to show verbose snapshot info or only show the basic info found in the repository index blob"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,85 +0,0 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the "Elastic License
|
||||
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
|
||||
* Public License v 1"; you may not use this file except in compliance with, at
|
||||
* your election, the "Elastic License 2.0", the "GNU Affero General Public
|
||||
* License v3.0 only", or the "Server Side Public License, v 1".
|
||||
*/
|
||||
|
||||
const convertParams = require('./convert/params');
|
||||
const convertMethods = require('./convert/methods');
|
||||
const convertPaths = require('./convert/paths');
|
||||
const convertParts = require('./convert/parts');
|
||||
|
||||
module.exports = (spec) => {
|
||||
const result = {};
|
||||
/**
|
||||
* TODO:
|
||||
* Since https://github.com/elastic/elasticsearch/pull/42346 has been merged into ES master
|
||||
* the JSON doc specification has been updated. We need to update this script to take advantage
|
||||
* of the added information but it will also require updating console editor autocomplete.
|
||||
*
|
||||
* Note: for now we exclude all deprecated patterns from the generated spec to prevent them
|
||||
* from being used in autocompletion. It would be really nice if we could use this information
|
||||
* instead of just not including it.
|
||||
*/
|
||||
Object.keys(spec).forEach((api) => {
|
||||
const source = spec[api];
|
||||
|
||||
if (!source.url) {
|
||||
return result;
|
||||
}
|
||||
|
||||
if (source.url.path) {
|
||||
if (source.url.paths.every((path) => Boolean(path.deprecated))) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const convertedSpec = (result[api] = {});
|
||||
if (source.params) {
|
||||
const urlParams = convertParams(source.params);
|
||||
if (Object.keys(urlParams).length > 0) {
|
||||
convertedSpec.url_params = urlParams;
|
||||
}
|
||||
}
|
||||
|
||||
const methodSet = new Set();
|
||||
let patterns;
|
||||
const urlComponents = {};
|
||||
|
||||
if (source.url.paths) {
|
||||
// We filter out all deprecated url patterns here.
|
||||
const paths = source.url.paths.filter((path) => !path.deprecated);
|
||||
patterns = convertPaths(paths);
|
||||
paths.forEach((pathsObject) => {
|
||||
pathsObject.methods.forEach((method) => methodSet.add(method));
|
||||
if (pathsObject.parts) {
|
||||
for (const partName of Object.keys(pathsObject.parts)) {
|
||||
urlComponents[partName] = pathsObject.parts[partName];
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
convertedSpec.methods = convertMethods(Array.from(methodSet));
|
||||
convertedSpec.patterns = patterns;
|
||||
|
||||
if (Object.keys(urlComponents).length) {
|
||||
const components = convertParts(urlComponents);
|
||||
const hasComponents =
|
||||
Object.keys(components).filter((c) => {
|
||||
return Boolean(components[c]);
|
||||
}).length > 0;
|
||||
if (hasComponents) {
|
||||
convertedSpec.url_components = convertParts(urlComponents);
|
||||
}
|
||||
}
|
||||
if (source.documentation && source.documentation.url) {
|
||||
convertedSpec.documentation = source.documentation.url;
|
||||
}
|
||||
});
|
||||
|
||||
return result;
|
||||
};
|
|
@ -1,21 +0,0 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the "Elastic License
|
||||
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
|
||||
* Public License v 1"; you may not use this file except in compliance with, at
|
||||
* your election, the "Elastic License 2.0", the "GNU Affero General Public
|
||||
* License v3.0 only", or the "Server Side Public License, v 1".
|
||||
*/
|
||||
|
||||
const convert = require('./convert');
|
||||
|
||||
const clusterHealthSpec = require('./__fixtures__/cluster_health_spec.json');
|
||||
const clusterHealthAutocomplete = require('./__fixtures__/cluster_health_autocomplete.json');
|
||||
|
||||
const snapshotGetSpec = require('./__fixtures__/snapshot_get_spec.json');
|
||||
const snapshotGetAutocomplete = require('./__fixtures__/snapshot_get_autocomplete.json');
|
||||
|
||||
test('convert', () => {
|
||||
expect(convert(clusterHealthSpec)).toEqual(clusterHealthAutocomplete);
|
||||
expect(convert(snapshotGetSpec)).toEqual(snapshotGetAutocomplete);
|
||||
});
|
|
@ -1,12 +0,0 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the "Elastic License
|
||||
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
|
||||
* Public License v 1"; you may not use this file except in compliance with, at
|
||||
* your election, the "Elastic License 2.0", the "GNU Affero General Public
|
||||
* License v3.0 only", or the "Server Side Public License, v 1".
|
||||
*/
|
||||
|
||||
module.exports = (methods) => {
|
||||
return methods;
|
||||
};
|
|
@ -1,53 +0,0 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the "Elastic License
|
||||
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
|
||||
* Public License v 1"; you may not use this file except in compliance with, at
|
||||
* your election, the "Elastic License 2.0", the "GNU Affero General Public
|
||||
* License v3.0 only", or the "Server Side Public License, v 1".
|
||||
*/
|
||||
|
||||
module.exports = (params) => {
|
||||
const result = {};
|
||||
Object.keys(params).forEach((param) => {
|
||||
const { type, description = '', options = [] } = params[param];
|
||||
const [, defaultValue] = description.match(/\(default: (.*)\)/) || [];
|
||||
switch (type) {
|
||||
case undefined:
|
||||
// { description: 'TODO: ?' }
|
||||
break;
|
||||
case 'int':
|
||||
case 'integer':
|
||||
result[param] = 0;
|
||||
break;
|
||||
case 'double':
|
||||
result[param] = 0.0;
|
||||
break;
|
||||
case 'enum':
|
||||
// This is to clean up entries like: "d (Days)". We only want the "d" part.
|
||||
if (param === 'time') {
|
||||
result[param] = options.map((option) => option.split(' ')[0]);
|
||||
} else {
|
||||
result[param] = options;
|
||||
}
|
||||
break;
|
||||
case 'boolean':
|
||||
result[param] = '__flag__';
|
||||
break;
|
||||
case 'time':
|
||||
case 'date':
|
||||
case 'string':
|
||||
case 'number':
|
||||
case 'number|string':
|
||||
case 'boolean|long':
|
||||
result[param] = defaultValue || '';
|
||||
break;
|
||||
case 'list':
|
||||
result[param] = [];
|
||||
break;
|
||||
default:
|
||||
throw new Error(`Unexpected type ${type}`);
|
||||
}
|
||||
});
|
||||
return result;
|
||||
};
|
|
@ -1,24 +0,0 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the "Elastic License
|
||||
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
|
||||
* Public License v 1"; you may not use this file except in compliance with, at
|
||||
* your election, the "Elastic License 2.0", the "GNU Affero General Public
|
||||
* License v3.0 only", or the "Server Side Public License, v 1".
|
||||
*/
|
||||
|
||||
const replacePattern = require('../replace_pattern');
|
||||
|
||||
module.exports = (parts) => {
|
||||
const result = {};
|
||||
Object.keys(parts).forEach((part) => {
|
||||
const key = replacePattern(part);
|
||||
const options = parts[part].options;
|
||||
if (options && options.length) {
|
||||
result[key] = options.sort();
|
||||
} else {
|
||||
result[key] = null;
|
||||
}
|
||||
});
|
||||
return result;
|
||||
};
|
|
@ -1,16 +0,0 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the "Elastic License
|
||||
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
|
||||
* Public License v 1"; you may not use this file except in compliance with, at
|
||||
* your election, the "Elastic License 2.0", the "GNU Affero General Public
|
||||
* License v3.0 only", or the "Server Side Public License, v 1".
|
||||
*/
|
||||
|
||||
const replacePattern = require('../replace_pattern');
|
||||
|
||||
module.exports = (patterns) => {
|
||||
return patterns.map((patternObject) => {
|
||||
return replacePattern(patternObject.path);
|
||||
});
|
||||
};
|
|
@ -1,12 +0,0 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the "Elastic License
|
||||
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
|
||||
* Public License v 1"; you may not use this file except in compliance with, at
|
||||
* your election, the "Elastic License 2.0", the "GNU Affero General Public
|
||||
* License v3.0 only", or the "Server Side Public License, v 1".
|
||||
*/
|
||||
|
||||
module.exports = (pattern) => {
|
||||
return pattern.replace(/^\//, '');
|
||||
};
|
|
@ -1,19 +0,0 @@
|
|||
{
|
||||
"name": "@kbn/spec-to-console",
|
||||
"version": "1.0.0",
|
||||
"description": "ES REST spec -> Console autocomplete",
|
||||
"main": "index.js",
|
||||
"directories": {
|
||||
"lib": "lib"
|
||||
},
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"format": "../../node_modules/.bin/prettier **/*.js --write"
|
||||
},
|
||||
"author": "",
|
||||
"license": "Elastic License 2.0 OR AGPL-3.0-only OR SSPL-1.0",
|
||||
"bugs": {
|
||||
"url": "https://github.com/jbudz/spec-to-console/issues"
|
||||
},
|
||||
"homepage": "https://github.com/jbudz/spec-to-console#readme"
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the "Elastic License
|
||||
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
|
||||
* Public License v 1"; you may not use this file except in compliance with, at
|
||||
* your election, the "Elastic License 2.0", the "GNU Affero General Public
|
||||
* License v3.0 only", or the "Server Side Public License, v 1".
|
||||
*/
|
||||
|
||||
require('@kbn/spec-to-console/bin/spec_to_console');
|
|
@ -1790,8 +1790,6 @@
|
|||
"@kbn/spaces-plugin/*": ["x-pack/plugins/spaces/*"],
|
||||
"@kbn/spaces-test-plugin": ["x-pack/test/spaces_api_integration/common/plugins/spaces_test_plugin"],
|
||||
"@kbn/spaces-test-plugin/*": ["x-pack/test/spaces_api_integration/common/plugins/spaces_test_plugin/*"],
|
||||
"@kbn/spec-to-console": ["packages/kbn-spec-to-console"],
|
||||
"@kbn/spec-to-console/*": ["packages/kbn-spec-to-console/*"],
|
||||
"@kbn/sse-utils": ["packages/kbn-sse-utils"],
|
||||
"@kbn/sse-utils/*": ["packages/kbn-sse-utils/*"],
|
||||
"@kbn/sse-utils-client": ["packages/kbn-sse-utils-client"],
|
||||
|
|
|
@ -6875,10 +6875,6 @@
|
|||
version "0.0.0"
|
||||
uid ""
|
||||
|
||||
"@kbn/spec-to-console@link:packages/kbn-spec-to-console":
|
||||
version "0.0.0"
|
||||
uid ""
|
||||
|
||||
"@kbn/sse-utils-client@link:packages/kbn-sse-utils-client":
|
||||
version "0.0.0"
|
||||
uid ""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue