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

[7.x] Adds two more packages and moves files into the packages (#100375) #100418

Merged
merged 1 commit into from
May 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions docs/developer/getting-started/monorepo-packages.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ yarn kbn watch-bazel
- kbn/securitysolution-io-ts-list-types
- kbn/securitysolution-io-ts-types
- @kbn/securitysolution-io-ts-utils
- @kbn/securitysolution-list-api
- @kbn/securitysolution-list-hooks
- @kbn/securitysolution-list-utils
- @kbn/securitysolution-utils
- @kbn/server-http-tools
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@
"@kbn/securitysolution-io-ts-alerting-types": "link:bazel-bin/packages/kbn-securitysolution-io-ts-alerting-types/npm_module",
"@kbn/securitysolution-io-ts-list-types": "link:bazel-bin/packages/kbn-securitysolution-io-ts-list-types/npm_module",
"@kbn/securitysolution-io-ts-utils": "link:bazel-bin/packages/kbn-securitysolution-io-ts-utils/npm_module",
"@kbn/securitysolution-list-api": "link:bazel-bin/packages/kbn-securitysolution-list-api/npm_module",
"@kbn/securitysolution-list-hooks": "link:bazel-bin/packages/kbn-securitysolution-list-hooks/npm_module",
"@kbn/securitysolution-list-utils": "link:bazel-bin/packages/kbn-securitysolution-list-utils/npm_module",
"@kbn/securitysolution-utils": "link:bazel-bin/packages/kbn-securitysolution-utils/npm_module",
"@kbn/server-http-tools": "link:bazel-bin/packages/kbn-server-http-tools/npm_module",
Expand Down
4 changes: 3 additions & 1 deletion packages/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@ filegroup(
"//packages/kbn-logging:build",
"//packages/kbn-plugin-generator:build",
"//packages/kbn-securitysolution-constants:build",
"//packages/kbn-securitysolution-list-utils:build",
"//packages/kbn-securitysolution-io-ts-types:build",
"//packages/kbn-securitysolution-io-ts-alerting-types:build",
"//packages/kbn-securitysolution-io-ts-list-types:build",
"//packages/kbn-securitysolution-io-ts-utils:build",
"//packages/kbn-securitysolution-list-api:build",
"//packages/kbn-securitysolution-list-hooks:build",
"//packages/kbn-securitysolution-list-utils:build",
"//packages/kbn-securitysolution-utils:build",
"//packages/kbn-securitysolution-es-utils:build",
"//packages/kbn-server-http-tools:build",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ export * from './common';
export * from './constants';
export * from './request';
export * from './response';
export * from './typescript_types';
Original file line number Diff line number Diff line change
@@ -1,51 +1,47 @@
/*
* 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; you may not use this file except in compliance with the Elastic License
* 2.0.
* 2.0 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 or the Server
* Side Public License, v 1.
*/

import type {
CreateExceptionListItemSchema,
CreateExceptionListSchema,
ExceptionListItemSchema,
ExceptionListSchema,
ExceptionListType,
NamespaceType,
Page,
PerPage,
TotalOrUndefined,
UpdateExceptionListItemSchema,
UpdateExceptionListSchema,
} from '@kbn/securitysolution-io-ts-list-types';

import { HttpStart, NotificationsStart } from '../../../../../src/core/public';
import { NamespaceType } from '../common/default_namespace';
import { ExceptionListType } from '../common/exception_list';
import { Page } from '../common/page';
import { PerPage } from '../common/per_page';
import { TotalOrUndefined } from '../common/total';
import { CreateExceptionListItemSchema } from '../request/create_exception_list_item_schema';
import { CreateExceptionListSchema } from '../request/create_exception_list_schema';
import { UpdateExceptionListItemSchema } from '../request/update_exception_list_item_schema';
import { UpdateExceptionListSchema } from '../request/update_exception_list_schema';
import { ExceptionListItemSchema } from '../response/exception_list_item_schema';
import { ExceptionListSchema } from '../response/exception_list_schema';

// TODO: Replace these with kbn packaged versions once we have those available to us
// These originally came from this location below before moving them to this hacked "any" types:
// import { HttpStart, NotificationsStart } from '../../../../../src/core/public';
interface HttpStart {
fetch: <T>(...args: any) => any;
}
type NotificationsStart = any;

export interface FilterExceptionsOptions {
filter: string;
tags: string[];
}

export interface Pagination {
page: Page;
perPage: PerPage;
total: TotalOrUndefined;
export interface ExceptionListFilter {
name?: string | null;
list_id?: string | null;
created_by?: string | null;
type?: string | null;
tags?: string | null;
}

export type AddExceptionList = UpdateExceptionListSchema | CreateExceptionListSchema;

export interface PersistHookProps {
export interface UseExceptionListsProps {
errorMessage: string;
filterOptions?: ExceptionListFilter;
http: HttpStart;
onError: (arg: Error) => void;
}

export interface ExceptionList extends ExceptionListSchema {
totalItems: number;
}

export interface UseExceptionListItemsSuccess {
exceptions: ExceptionListItemSchema[];
pagination: Pagination;
namespaceTypes: NamespaceType[];
notifications: NotificationsStart;
pagination?: Pagination;
showTrustedApps: boolean;
}

export interface UseExceptionListProps {
Expand All @@ -60,27 +56,9 @@ export interface UseExceptionListProps {
onSuccess?: (arg: UseExceptionListItemsSuccess) => void;
}

export interface ExceptionListIdentifiers {
id: string;
listId: string;
namespaceType: NamespaceType;
type: ExceptionListType;
}

export interface ApiCallByListIdProps {
http: HttpStart;
listIds: string[];
namespaceTypes: NamespaceType[];
filterOptions: FilterExceptionsOptions[];
pagination: Partial<Pagination>;
signal: AbortSignal;
}

export interface ApiCallByIdProps {
http: HttpStart;
id: string;
namespaceType: NamespaceType;
signal: AbortSignal;
export interface FilterExceptionsOptions {
filter: string;
tags: string[];
}

export interface ApiCallMemoProps {
Expand All @@ -101,6 +79,24 @@ export interface ApiListExportProps {
onSuccess: (blob: Blob) => void;
}

export interface Pagination {
page: Page;
perPage: PerPage;
total: TotalOrUndefined;
}

export interface UseExceptionListItemsSuccess {
exceptions: ExceptionListItemSchema[];
pagination: Pagination;
}

export interface ExceptionListIdentifiers {
id: string;
listId: string;
namespaceType: NamespaceType;
type: ExceptionListType;
}

export interface ApiCallFindListsItemsMemoProps {
lists: ExceptionListIdentifiers[];
filterOptions: FilterExceptionsOptions[];
Expand All @@ -110,40 +106,29 @@ export interface ApiCallFindListsItemsMemoProps {
onError: (arg: string[]) => void;
onSuccess: (arg: UseExceptionListItemsSuccess) => void;
}
export interface ApiCallFetchExceptionListsProps {

export interface ExportExceptionListProps {
http: HttpStart;
namespaceTypes: string;
pagination: Partial<Pagination>;
filters: string;
id: string;
listId: string;
namespaceType: NamespaceType;
signal: AbortSignal;
}

export interface UseExceptionListsSuccess {
exceptions: ExceptionListSchema[];
pagination: Pagination;
}

export interface ExceptionListFilter {
name?: string | null;
list_id?: string | null;
created_by?: string | null;
type?: string | null;
tags?: string | null;
export interface AddEndpointExceptionListProps {
http: HttpStart;
signal: AbortSignal;
}

export interface UseExceptionListsProps {
errorMessage: string;
filterOptions?: ExceptionListFilter;
export interface UpdateExceptionListItemProps {
http: HttpStart;
namespaceTypes: NamespaceType[];
notifications: NotificationsStart;
pagination?: Pagination;
showTrustedApps: boolean;
listItem: UpdateExceptionListItemSchema;
signal: AbortSignal;
}

export interface AddExceptionListProps {
export interface UpdateExceptionListProps {
http: HttpStart;
list: CreateExceptionListSchema;
list: UpdateExceptionListSchema;
signal: AbortSignal;
}

Expand All @@ -153,27 +138,48 @@ export interface AddExceptionListItemProps {
signal: AbortSignal;
}

export interface UpdateExceptionListProps {
export interface AddExceptionListProps {
http: HttpStart;
list: UpdateExceptionListSchema;
list: CreateExceptionListSchema;
signal: AbortSignal;
}

export interface UpdateExceptionListItemProps {
http: HttpStart;
listItem: UpdateExceptionListItemSchema;
signal: AbortSignal;
export interface UseExceptionListsSuccess {
exceptions: ExceptionListSchema[];
pagination: Pagination;
}

export interface AddEndpointExceptionListProps {
export interface ApiCallFetchExceptionListsProps {
http: HttpStart;
namespaceTypes: string;
pagination: Partial<Pagination>;
filters: string;
signal: AbortSignal;
}

export interface ExportExceptionListProps {
export interface ApiCallByIdProps {
http: HttpStart;
id: string;
listId: string;
namespaceType: NamespaceType;
signal: AbortSignal;
}

export interface ApiCallByListIdProps {
http: HttpStart;
listIds: string[];
namespaceTypes: NamespaceType[];
filterOptions: FilterExceptionsOptions[];
pagination: Partial<Pagination>;
signal: AbortSignal;
}

export type AddExceptionList = UpdateExceptionListSchema | CreateExceptionListSchema;

export interface PersistHookProps {
http: HttpStart;
onError: (arg: Error) => void;
}

export interface ExceptionList extends ExceptionListSchema {
totalItems: number;
}
88 changes: 88 additions & 0 deletions packages/kbn-securitysolution-list-api/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
load("@npm//@bazel/typescript:index.bzl", "ts_config", "ts_project")
load("@build_bazel_rules_nodejs//:index.bzl", "js_library", "pkg_npm")

PKG_BASE_NAME = "kbn-securitysolution-list-api"

PKG_REQUIRE_NAME = "@kbn/securitysolution-list-api"

SOURCE_FILES = glob(
[
"src/**/*.ts",
],
exclude = [
"**/*.test.*",
"**/*.mock.*",
],
)

SRCS = SOURCE_FILES

filegroup(
name = "srcs",
srcs = SRCS,
)

NPM_MODULE_EXTRA_FILES = [
"package.json",
"README.md",
]

SRC_DEPS = [
"//packages/kbn-securitysolution-io-ts-utils",
"//packages/kbn-securitysolution-io-ts-list-types",
"@npm//fp-ts",
"@npm//io-ts",
"@npm//tslib",
]

TYPES_DEPS = [
"@npm//@types/jest",
"@npm//@types/node",
]

DEPS = SRC_DEPS + TYPES_DEPS

ts_config(
name = "tsconfig",
src = "tsconfig.json",
deps = [
"//:tsconfig.base.json",
],
)

ts_project(
name = "tsc",
srcs = SRCS,
args = ["--pretty"],
declaration = True,
declaration_map = True,
incremental = True,
out_dir = "target",
root_dir = "src",
source_map = True,
tsconfig = ":tsconfig",
deps = DEPS,
)

js_library(
name = PKG_BASE_NAME,
package_name = PKG_REQUIRE_NAME,
srcs = NPM_MODULE_EXTRA_FILES,
visibility = ["//visibility:public"],
deps = [":tsc"] + DEPS,
)

pkg_npm(
name = "npm_module",
deps = [
":%s" % PKG_BASE_NAME,
],
)

filegroup(
name = "build",
srcs = [
":npm_module",
],
visibility = ["//visibility:public"],
)
4 changes: 4 additions & 0 deletions packages/kbn-securitysolution-list-api/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# kbn-securitysolution-list-api

This is where the REST API for the list plugin lives

Loading