Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add frontend http client #7000

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
81616ca
feat(http): create http frontend client
Desvelao Sep 19, 2024
9189e8e
fix: add VSCode settings file
Desvelao Sep 19, 2024
af7e812
chore: remove comment
Desvelao Sep 19, 2024
3fe48aa
feat: add suggestions of code review
Desvelao Sep 27, 2024
7b4ed5b
feat(core): add TableData and ServerTable components to core plugin
Desvelao Oct 2, 2024
54d3fc0
test(core): fix ExportTableCsv test
Desvelao Oct 2, 2024
2634eeb
chore(prettier): fix some code syntax
Desvelao Oct 2, 2024
1bde358
chore(prettier): fix some code syntax
Desvelao Oct 2, 2024
57f213c
chore: remove console.log
Desvelao Oct 2, 2024
aad9930
feat(core): enhance typing
Desvelao Oct 2, 2024
3121f61
Merge branch 'master' of https://github.com/wazuh/wazuh-kibana-app in…
Desvelao Nov 27, 2024
5c965f0
fix(http): move type definitions
Desvelao Nov 27, 2024
bfff8dd
fix: tests
Desvelao Nov 27, 2024
ff38af0
fix: move types
Desvelao Nov 28, 2024
cbd5584
chore(changelog): add entry)
Desvelao Nov 28, 2024
bbce7b1
Merge branch 'master' of https://github.com/wazuh/wazuh-kibana-app in…
Desvelao Dec 3, 2024
6dedffc
fix(lint): code lint
Desvelao Dec 3, 2024
85c331c
fix(prettier): code prettier
Desvelao Dec 3, 2024
2e8cfcc
fix(lint): code lint
Desvelao Dec 3, 2024
f61763f
fix(lint): code lint
Desvelao Dec 4, 2024
38bede6
Update plugins/wazuh-core/public/services/http/server-client.ts
Desvelao Dec 5, 2024
4e656ce
Merge branch 'master' of https://github.com/wazuh/wazuh-kibana-app in…
Desvelao Dec 5, 2024
f433f64
fix(http): review suggestions
Desvelao Dec 5, 2024
eb3516b
fix(http): review suggestions
Desvelao Dec 5, 2024
4fcad8f
fix(http): fix options paramenter in http client
Desvelao Dec 5, 2024
2dcdc10
fix(lint): simplify arrow-body-style configuration in ESLint settings
guidomodarelli Dec 5, 2024
a907cd8
fix(types): enhance SearchBarQueryLanguage and refine query language …
guidomodarelli Dec 5, 2024
b4819d2
fix(lint): update ESLint rules for unicorn and TypeScript to improve …
guidomodarelli Dec 5, 2024
8d99e41
fix(lint): refine ESLint rules and clean up code with consistent erro…
guidomodarelli Dec 5, 2024
0f8289e
fix(lint): add rule for optional chaining and update WazuhApiCtrl for…
guidomodarelli Dec 6, 2024
9525a4b
fix(lint): simplify state update with optional chaining and improve c…
guidomodarelli Dec 6, 2024
824b184
fix(lint): optimize settings update and clean up settings grouping lo…
guidomodarelli Dec 6, 2024
642d749
fix(lint): enhance rule for optional chaining to include empty Object…
guidomodarelli Dec 6, 2024
e089526
fix(lint): simplify array mapping in AQL tests for improved readabili…
guidomodarelli Dec 6, 2024
f489338
fix(lint): refactor object mapping in AQL component for improved read…
guidomodarelli Dec 6, 2024
65c9800
fix(lint): streamline object mapping in WQL for enhanced readability …
guidomodarelli Dec 6, 2024
f5706d8
fix(lint): simplify object mapping in TableData for improved readabil…
guidomodarelli Dec 6, 2024
ad97a40
fix(lint): refactor object mapping in ExportTableCsv for improved rea…
guidomodarelli Dec 6, 2024
13e44e1
fix(lint): refactor error handling in GenericRequest for improved rea…
guidomodarelli Dec 6, 2024
51cbf6f
fix(lint): streamline error message extraction in WzRequest for impro…
guidomodarelli Dec 6, 2024
02e31a6
fix(lint): add rule for optional chaining with empty array expression…
guidomodarelli Dec 6, 2024
8f0ac56
fix(lint): refactor token extraction using optional chaining for impr…
guidomodarelli Dec 6, 2024
b670544
fix(enum): remove redundant enum definition for plugin settings, impr…
guidomodarelli Dec 6, 2024
8deb71f
fix(lint): add rule for empty functions in test files to enhance code…
guidomodarelli Dec 6, 2024
f33d351
fix(refactor): optimize settings categorization logic for clarity and…
guidomodarelli Dec 6, 2024
38c2bb6
fix(lint): remove unused variable warnings and improve code readabili…
guidomodarelli Dec 6, 2024
86efe85
fix(lint): eliminate unnecessary eslint-disable comments and enhance …
guidomodarelli Dec 6, 2024
04bcf98
fix(refactor): enhance search bar query language structure and type s…
guidomodarelli Dec 6, 2024
d1e9e59
fix(lint): turn off 'default-param-last' rule and clean up related es…
guidomodarelli Dec 6, 2024
e99506e
fix(lint): remove unused variables and clean up eslint-disable commen…
guidomodarelli Dec 6, 2024
5211788
fix(lint): update enum formatting rules in eslint config for improved…
guidomodarelli Dec 6, 2024
3c0cd7d
fix(aql): refactor token types to use enums and constants for improve…
guidomodarelli Dec 6, 2024
1b4dc2b
fix(lint): expand ESLint variable rule to include boolean, number, an…
guidomodarelli Dec 6, 2024
51b5842
fix(types): update UseStateStorageHook to default type 'any' for impr…
guidomodarelli Dec 6, 2024
7c5baf0
fix(lint): add camelCase and PascalCase formats for object literal me…
guidomodarelli Dec 6, 2024
3a156f6
fix(lint): include camelCase and PascalCase formats for variable name…
guidomodarelli Dec 6, 2024
db7cde7
fix(lint): update unused variable handling in table-data component to…
guidomodarelli Dec 6, 2024
b831512
fix(lint): enhance withServices HOC to set displayName for better deb…
guidomodarelli Dec 6, 2024
19f57c4
fix(lint): remove unused eslint disables and update callback paramete…
guidomodarelli Dec 6, 2024
4d2fc70
fix(lint): remove unnecessary eslint-disable comment in server-table-…
guidomodarelli Dec 6, 2024
d34108d
fix(lint): clean up request-interceptor by removing unused eslint-dis…
guidomodarelli Dec 6, 2024
cd48318
fix(lint): remove unnecessary eslint-disable comment from configurati…
guidomodarelli Dec 6, 2024
a4c5a12
fix(lint): remove unnecessary eslint-disable comments from configurat…
guidomodarelli Dec 6, 2024
4a9e48c
fix(lint): remove unused eslint-disable comment from search-bar compo…
guidomodarelli Dec 6, 2024
16ceef7
fix(lint): remove unused eslint-disable comment from wql.test.tsx to …
guidomodarelli Dec 6, 2024
846200e
fix(code): replace WQL.id with WQL_ID in query language file for bett…
guidomodarelli Dec 6, 2024
ca83f01
fix(lint): remove unused eslint-disable comment from server-client.ts…
guidomodarelli Dec 6, 2024
649a2e7
fix(lint): eliminate unused eslint-disable comments in wql.tsx to enh…
guidomodarelli Dec 6, 2024
1df9aa7
fix(lint): remove unnecessary eslint-disable comment in wql.tsx to im…
guidomodarelli Dec 6, 2024
8159bd6
fix(types): replace hardcoded id with WQL_ID in ISearchBarModeWQL int…
guidomodarelli Dec 6, 2024
1c30b77
fix(lint): refactor conditional logic in wql.tsx to improve code clar…
guidomodarelli Dec 6, 2024
a93ff85
fix(api): use WAZUH_ERROR_DAEMONS_NOT_READY constant for error messag…
guidomodarelli Dec 6, 2024
bd24178
fix(api): update WazuhApiCtrl to use WAZUH_ERROR_CODES for consistent…
guidomodarelli Dec 6, 2024
d1c7581
fix(lint): update eslint config to enforce UPPER_CASE for enum and ad…
guidomodarelli Dec 6, 2024
e8fb587
fix(settings-validator): refactor class to object, update methods for…
guidomodarelli Dec 6, 2024
675ee00
fix(lint): enhance eslint config to allow UPPER_CASE, camelCase, and …
guidomodarelli Dec 6, 2024
3f3f9e6
fix(constants): update import path and refactor configuration constan…
guidomodarelli Dec 6, 2024
4db6b39
fix(wazuh-api): replace WAZUH_ERROR_CODES with WAZUH_ERROR_DAEMONS_NO…
guidomodarelli Dec 9, 2024
808d3be
fix(constants): rename pluginPlatformRequestHeaders to PLUGIN_PLATFOR…
guidomodarelli Dec 9, 2024
342f4ea
fix(constants): refactor query language constants and improve code co…
guidomodarelli Dec 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 71 additions & 11 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,20 @@ module.exports = {
message:
"Don't use arrow functions in class properties. Use a function instead.",
},
{
selector:
'MemberExpression > LogicalExpression[operator="||"]:has(Identifier):has(ObjectExpression[properties.length=0])',
message: 'Use optional chaining operator instead (?.).',
},
{
selector:
'MemberExpression > LogicalExpression[operator="||"]:has(Identifier):has(ArrayExpression[elements.length=0])',
message: 'Use optional chaining operator instead (?.).',
},
],
'prefer-arrow-callback': 'error',
'func-style': ['error', 'declaration', { allowArrowFunctions: true }],
'arrow-body-style': [
'error',
'as-needed',
{ requireReturnForObjectLiteral: true },
],
'arrow-body-style': ['error', 'as-needed'],
'no-unreachable': 'error',
'no-fallthrough': [
'error',
Expand All @@ -82,7 +88,7 @@ module.exports = {
'block-scoped-var': 'error',
'default-case': 'error',
'default-case-last': 'error',
'default-param-last': 'error',
'default-param-last': 'off',
eqeqeq: ['error', 'always'],
'no-var': 'error',
/* -------------------------------------------------------------------------- */
Expand Down Expand Up @@ -163,6 +169,7 @@ module.exports = {
/* -------------------------------------------------------------------------- */
/* unicorn */
/* -------------------------------------------------------------------------- */
'unicorn/prefer-module': 'off',
'unicorn/prefer-ternary': 'off',
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/custom-error-definition.md
'unicorn/custom-error-definition': 'error',
Expand Down Expand Up @@ -203,19 +210,43 @@ module.exports = {
/* -------------------------------------------------------------------------- */
/* @typescript-eslint */
/* -------------------------------------------------------------------------- */
'@typescript-eslint/no-dynamic-delete': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{
// Whether to check all, some, or no arguments.
args: 'after-used',
// Regular expressions of argument names to not check for usage.
argsIgnorePattern: '^_',
// Whether to check catch block arguments.
caughtErrors: 'all',
// Regular expressions of catch block argument names to not check for usage.
caughtErrorsIgnorePattern: '^_',
// Regular expressions of destructured array variable names to not check for usage.
destructuredArrayIgnorePattern: '^_',
// Whether to ignore classes with at least one static initialization block.
ignoreClassWithStaticInitBlock: false,
// Whether to ignore sibling properties in `...` destructurings.
ignoreRestSiblings: false,
// Whether to report variables that match any of the valid ignore pattern options if they have been used.
reportUsedIgnorePattern: true,
// Whether to check all variables or only locally-declared variables.
vars: 'all',
// Regular expressions of variable names to not check for usage.
varsIgnorePattern: '[iI]gnored$',
},
],
'@typescript-eslint/prefer-readonly': 'error',
'@typescript-eslint/no-extraneous-class': 'off',
'@typescript-eslint/method-signature-style': ['error', 'property'],
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/naming-convention': [
'error',
{ selector: 'default', format: ['camelCase'] },
{ selector: 'import', format: ['camelCase', 'PascalCase'] },
{
selector: 'variable',
types: ['function'],
selector: 'default',
format: ['camelCase', 'PascalCase'],
leadingUnderscore: 'allow',
},
{
selector: ['objectLiteralProperty', 'typeProperty'],
Expand All @@ -232,7 +263,12 @@ module.exports = {
{
selector: ['variable'],
modifiers: ['global'],
types: ['number', 'string'],
format: ['UPPER_CASE', 'camelCase', 'PascalCase'],
},
{
selector: ['variable'],
modifiers: ['global'],
types: ['boolean', 'number', 'string'],
format: ['UPPER_CASE'],
},
{
Expand Down Expand Up @@ -316,5 +352,29 @@ module.exports = {
],
},
},
{
// constants files
files: ['plugins/**/constants.{ts,js}'],
rules: {
'@typescript-eslint/naming-convention': [
'error',
{
selector: 'variable',
modifiers: ['global'],
format: ['UPPER_CASE'],
},
],
},
},
{
files: ['plugins/**/*.test.{js,jsx,ts,tsx}'],
rules: {
'@typescript-eslint/no-empty-function': [
'error',
{ allow: ['arrowFunctions'] },
],
'@typescript-eslint/no-unused-vars': 'off',
},
},
],
};
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ All notable changes to the Wazuh app project will be documented in this file.

- Support for Wazuh 5.0.0
- Added creation of report definition when creating dashboard by reference and the button to reset the report [#7091](https://github.com/wazuh/wazuh-dashboard-plugins/pull/7091)
- Added a frontend http client to core plugin [#7000](https://github.com/wazuh/wazuh-dashboard-plugins/pull/7000)
- Added an initilization service to core plugin to run the initilization tasks related to user scope [#7145](https://github.com/wazuh/wazuh-dashboard-plugins/pull/7145)

### Removed
Expand Down
68 changes: 47 additions & 21 deletions plugins/main/public/components/search-bar/query-language/index.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,58 @@
import { suggestItem } from '../../wz-search-bar';
import { AQL } from './aql';
import { WQL } from './wql';

type SearchBarQueryLanguage = {
description: string;
documentationLink?: string;
interface SearchBarProps {
suggestions: suggestItem[];
onItemClick: (currentInput: string) => (item: suggestItem) => void;
prepend?: React.ReactNode;
disableFocusTrap?: boolean;
isInvalid?: boolean;
onKeyPress?: (event: React.KeyboardEvent<HTMLInputElement>) => void;
}

interface SearchBarQueryLanguage {
id: string;
label: string;
description: string;
documentationLink?: string;
getConfiguration?: () => any;
run: (input: string | undefined, params: any) => Promise<{
searchBarProps: any,
run: (
input: string | undefined,
params: any,
) => Promise<{
filterButtons?: React.ReactElement | null;
searchBarProps: SearchBarProps;
output: {
language: string,
unifiedQuery: string,
query: string
}
language: string;
unifiedQuery?: string;
apiQuery?: {
q: string;
};
query: string;
};
}>;
transformInput: (unifiedQuery: string, options: {configuration: any, parameters: any}) => string;
};
transformInput?: (
unifiedQuery: string,
options: { configuration: any; parameters: any },
) => string;
transformUQLToQL?: (unifiedQuery: string) => string;
}

// Register the query languages
export const searchBarQueryLanguages: {
[key: string]: SearchBarQueryLanguage;
} = [AQL, WQL].reduce((accum, item) => {
if (accum[item.id]) {
throw new Error(`Query language with id: ${item.id} already registered.`);
function initializeSearchBarQueryLanguages() {
const languages = [AQL, WQL];
const result: Record<string, SearchBarQueryLanguage> = {};

for (const item of languages) {
if (result[item.id]) {
throw new Error(`Query language with id: ${item.id} already registered.`);
}

result[item.id] = item;
}
return {
...accum,
[item.id]: item,
};
}, {});

return result;
}

export const searchBarQueryLanguages = initializeSearchBarQueryLanguages();
Loading
Loading