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

Create common and api types packages for the savedObjects domain #136722

Merged
Merged
Show file tree
Hide file tree
Changes from 47 commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
51f097e
Creating empty @kbn/core-saved-objects-common package
pgayvallet Jul 20, 2022
8f5f18a
start moving types around
pgayvallet Jul 20, 2022
ef4da90
start fixing imports
pgayvallet Jul 20, 2022
9ea6b70
fix entrypoint exports
pgayvallet Jul 20, 2022
715621c
fix external import
pgayvallet Jul 20, 2022
ea107a8
create explicit ISavedObjectsRepository interface
pgayvallet Jul 20, 2022
5b45973
fix another external usage
pgayvallet Jul 20, 2022
db0a2eb
rewrite browser exports
pgayvallet Jul 20, 2022
cfa2a71
create explicit SavedObjectsClientContract interface
pgayvallet Jul 21, 2022
62a7fd8
move client/repository types to @kbn/core-saved-objects-api-server
pgayvallet Jul 21, 2022
be595bb
start fixing imports
pgayvallet Jul 21, 2022
bf313f0
one more
pgayvallet Jul 21, 2022
f58e58e
fix global re-exports
pgayvallet Jul 21, 2022
487915f
fix some browser-side imports
pgayvallet Jul 21, 2022
8a59dff
fix more violations
pgayvallet Jul 21, 2022
f77ed4d
prepare the browser-side client
pgayvallet Jul 21, 2022
a769255
fix one more usage
pgayvallet Jul 21, 2022
80d2ba3
fix external usage
pgayvallet Jul 21, 2022
c39687a
fix more external usages
pgayvallet Jul 21, 2022
7eaf4a7
one more
pgayvallet Jul 21, 2022
8ed9e5b
Create @kbn/core-saved-objects-api-browser package
pgayvallet Jul 21, 2022
b4289e0
fix more usages of error helper
pgayvallet Jul 21, 2022
4138fb6
fix more internal imports
pgayvallet Jul 21, 2022
6240fc8
use interface for SSO
pgayvallet Jul 21, 2022
1fefac4
adapt more imports
pgayvallet Jul 21, 2022
567de0a
damn those types were a mess
pgayvallet Jul 21, 2022
07a12e5
fix more usages of SSO
pgayvallet Jul 21, 2022
7ee9822
Revert "fix more usages of SSO"
pgayvallet Jul 21, 2022
878c14d
Revert "use interface for SSO"
pgayvallet Jul 21, 2022
ef08ef5
export the interface with the old name instead.
pgayvallet Jul 21, 2022
14dd79f
adapt tests concrete usages of SSO
pgayvallet Jul 21, 2022
70a82e4
export reference type, more fixes
pgayvallet Jul 21, 2022
ded32bf
this gonna be long
pgayvallet Jul 21, 2022
167d5d8
one more
pgayvallet Jul 21, 2022
3b3b77c
other resolve type change
pgayvallet Jul 21, 2022
5923980
more usages
pgayvallet Jul 21, 2022
8ea77f3
Am I getting close?
pgayvallet Jul 21, 2022
53de32e
yet more fixes
pgayvallet Jul 21, 2022
a4e554f
back to client impl
pgayvallet Jul 21, 2022
51435a0
fix bulkGetting undefined
pgayvallet Jul 21, 2022
f98fffb
fix SS mock
pgayvallet Jul 21, 2022
a0d7ed0
Merge remote-tracking branch 'upstream/main' into kbn-135820-so-commo…
pgayvallet Jul 21, 2022
2e23ec4
Merge remote-tracking branch 'upstream/main' into kbn-135820-so-commo…
pgayvallet Jul 22, 2022
252159e
some cleanup
pgayvallet Jul 22, 2022
3aacfd5
self-review
pgayvallet Jul 22, 2022
8451d9b
Merge remote-tracking branch 'upstream/main' into kbn-135820-so-commo…
pgayvallet Jul 25, 2022
42caa24
fix new usages
pgayvallet Jul 25, 2022
99f9735
Merge remote-tracking branch 'upstream/main' into kbn-135820-so-commo…
pgayvallet Jul 25, 2022
148d702
Merge remote-tracking branch 'upstream/main' into kbn-135820-so-commo…
pgayvallet Jul 26, 2022
b81bb0b
fix typo
pgayvallet Jul 26, 2022
0650e7a
fix new usage
pgayvallet Jul 26, 2022
256ad85
Merge remote-tracking branch 'upstream/main' into kbn-135820-so-commo…
pgayvallet Jul 26, 2022
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
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,9 @@
"@kbn/core-preboot-server": "link:bazel-bin/packages/core/preboot/core-preboot-server",
"@kbn/core-preboot-server-internal": "link:bazel-bin/packages/core/preboot/core-preboot-server-internal",
"@kbn/core-preboot-server-mocks": "link:bazel-bin/packages/core/preboot/core-preboot-server-mocks",
"@kbn/core-saved-objects-api-browser": "link:bazel-bin/packages/core/saved-objects/core-saved-objects-api-browser",
"@kbn/core-saved-objects-api-server": "link:bazel-bin/packages/core/saved-objects/core-saved-objects-api-server",
"@kbn/core-saved-objects-common": "link:bazel-bin/packages/core/saved-objects/core-saved-objects-common",
"@kbn/core-test-helpers-http-setup-browser": "link:bazel-bin/packages/core/test-helpers/core-test-helpers-http-setup-browser",
"@kbn/core-theme-browser": "link:bazel-bin/packages/core/theme/core-theme-browser",
"@kbn/core-theme-browser-internal": "link:bazel-bin/packages/core/theme/core-theme-browser-internal",
Expand Down Expand Up @@ -807,6 +810,9 @@
"@types/kbn__core-preboot-server-internal": "link:bazel-bin/packages/core/preboot/core-preboot-server-internal/npm_module_types",
"@types/kbn__core-preboot-server-mocks": "link:bazel-bin/packages/core/preboot/core-preboot-server-mocks/npm_module_types",
"@types/kbn__core-public-internal-base": "link:bazel-bin/packages/core/public/internal-base/npm_module_types",
"@types/kbn__core-saved-objects-api-browser": "link:bazel-bin/packages/core/saved-objects/core-saved-objects-api-browser/npm_module_types",
"@types/kbn__core-saved-objects-api-server": "link:bazel-bin/packages/core/saved-objects/core-saved-objects-api-server/npm_module_types",
"@types/kbn__core-saved-objects-common": "link:bazel-bin/packages/core/saved-objects/core-saved-objects-common/npm_module_types",
"@types/kbn__core-server-internal-base": "link:bazel-bin/packages/core/server/internal-base/npm_module_types",
"@types/kbn__core-test-helpers-http-setup-browser": "link:bazel-bin/packages/core/test-helpers/core-test-helpers-http-setup-browser/npm_module_types",
"@types/kbn__core-theme-browser": "link:bazel-bin/packages/core/theme/core-theme-browser/npm_module_types",
Expand Down
6 changes: 6 additions & 0 deletions packages/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ filegroup(
"//packages/core/preboot/core-preboot-server-internal:build",
"//packages/core/preboot/core-preboot-server-mocks:build",
"//packages/core/preboot/core-preboot-server:build",
"//packages/core/saved-objects/core-saved-objects-api-browser:build",
"//packages/core/saved-objects/core-saved-objects-api-server:build",
"//packages/core/saved-objects/core-saved-objects-common:build",
"//packages/core/test-helpers/core-test-helpers-http-setup-browser:build",
"//packages/core/theme/core-theme-browser-internal:build",
"//packages/core/theme/core-theme-browser-mocks:build",
Expand Down Expand Up @@ -299,6 +302,9 @@ filegroup(
"//packages/core/preboot/core-preboot-server-internal:build_types",
"//packages/core/preboot/core-preboot-server-mocks:build_types",
"//packages/core/preboot/core-preboot-server:build_types",
"//packages/core/saved-objects/core-saved-objects-api-browser:build_types",
"//packages/core/saved-objects/core-saved-objects-api-server:build_types",
"//packages/core/saved-objects/core-saved-objects-common:build_types",
"//packages/core/test-helpers/core-test-helpers-http-setup-browser:build_types",
"//packages/core/theme/core-theme-browser-internal:build_types",
"//packages/core/theme/core-theme-browser-mocks:build_types",
Expand Down
108 changes: 108 additions & 0 deletions packages/core/saved-objects/core-saved-objects-api-browser/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
load("@npm//@bazel/typescript:index.bzl", "ts_config")
load("@build_bazel_rules_nodejs//:index.bzl", "js_library")
load("//src/dev/bazel:index.bzl", "jsts_transpiler", "pkg_npm", "pkg_npm_types", "ts_project")

PKG_DIRNAME = "core-saved-objects-api-browser"
PKG_REQUIRE_NAME = "@kbn/core-saved-objects-api-browser"

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

SRCS = SOURCE_FILES

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

NPM_MODULE_EXTRA_FILES = [
"package.json",
]

RUNTIME_DEPS = [
"@npm//react"
]

TYPES_DEPS = [
"@npm//@types/node",
"@npm//@types/jest",
"//packages/core/saved-objects/core-saved-objects-common:npm_module_types",
"//packages/core/saved-objects/core-saved-objects-api-server:npm_module_types",
]

jsts_transpiler(
name = "target_node",
srcs = SRCS,
build_pkg_name = package_name(),
)

jsts_transpiler(
name = "target_web",
srcs = SRCS,
build_pkg_name = package_name(),
web = True,
)

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

ts_project(
name = "tsc_types",
args = ['--pretty'],
srcs = SRCS,
deps = TYPES_DEPS,
declaration = True,
declaration_map = True,
emit_declaration_only = True,
out_dir = "target_types",
root_dir = "src",
tsconfig = ":tsconfig",
)

js_library(
name = PKG_DIRNAME,
srcs = NPM_MODULE_EXTRA_FILES,
deps = RUNTIME_DEPS + [":target_node", ":target_web"],
package_name = PKG_REQUIRE_NAME,
visibility = ["//visibility:public"],
)

pkg_npm(
name = "npm_module",
deps = [":" + PKG_DIRNAME],
)

filegroup(
name = "build",
srcs = [":npm_module"],
visibility = ["//visibility:public"],
)

pkg_npm_types(
name = "npm_module_types",
srcs = SRCS,
deps = [":tsc_types"],
package_name = PKG_REQUIRE_NAME,
tsconfig = ":tsconfig",
visibility = ["//visibility:public"],
)

filegroup(
name = "build_types",
srcs = [":npm_module_types"],
visibility = ["//visibility:public"],
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# @kbn/core-saved-objects-api-browser

This package contains the public types for core's browser-side savedObjects client APIs.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* 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 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.
*/

module.exports = {
preset: '@kbn/test',
rootDir: '../../../..',
roots: ['<rootDir>/packages/core/saved-objects/core-saved-objects-api-browser'],
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "@kbn/core-saved-objects-api-browser",
"private": true,
"version": "1.0.0",
"main": "./target_node/index.js",
"browser": "./target_web/index.js",
"license": "SSPL-1.0 OR Elastic License 2.0"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* 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 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 { SimpleSavedObject } from '../simple_saved_object';

/** @public */
export interface SavedObjectsBatchResponse<T = unknown> {
savedObjects: Array<SimpleSavedObject<T>>;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* 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 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 { SavedObjectsCreateOptions } from './create';

/**
* @param type - Create a SavedObject of the given type
* @param attributes - Create a SavedObject with the given attributes
*
* @public
*/
export interface SavedObjectsBulkCreateObject<T = unknown> extends SavedObjectsCreateOptions {
type: string;
attributes: T;
}

/** @public */
export interface SavedObjectsBulkCreateOptions {
/** If a document with the given `id` already exists, overwrite it's contents (default=false). */
overwrite?: boolean;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* 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 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 { ResolvedSimpleSavedObject } from './resolve';

/** @public */
export interface SavedObjectsBulkResolveResponse<T = unknown> {
resolved_objects: Array<ResolvedSimpleSavedObject<T>>;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* 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 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 { SavedObjectReference } from '@kbn/core-saved-objects-common';

/** @public */
export interface SavedObjectsBulkUpdateObject<T = unknown> {
type: string;
id: string;
attributes: T;
version?: string;
references?: SavedObjectReference[];
}

/** @public */
export interface SavedObjectsBulkUpdateOptions {
namespace?: string;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* 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 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 {
SavedObjectReference,
SavedObjectsMigrationVersion,
} from '@kbn/core-saved-objects-common';

/** @public */
export interface SavedObjectsCreateOptions {
/**
* (Not recommended) Specify an id instead of having the saved objects service generate one for you.
*/
id?: string;
/** If a document with the given `id` already exists, overwrite it's contents (default=false). */
overwrite?: boolean;
/** {@inheritDoc SavedObjectsMigrationVersion} */
migrationVersion?: SavedObjectsMigrationVersion;
/** A semver value that is used when upgrading objects between Kibana versions. */
coreMigrationVersion?: string;
references?: SavedObjectReference[];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* 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 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.
*/

/** @public */
export interface SavedObjectsDeleteOptions {
/** Force deletion of an object that exists in multiple namespaces */
force?: boolean;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* 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 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 { SavedObjectsFindOptions as SavedObjectFindOptionsServer } from '@kbn/core-saved-objects-api-server';
import type { SavedObjectsBatchResponse } from './base';

/**
* @public
*/
export type SavedObjectsFindOptions = Omit<
SavedObjectFindOptionsServer,
'pit' | 'rootSearchFields' | 'searchAfter' | 'sortOrder' | 'typeToNamespacesMap'
>;

/**
* Return type of the Saved Objects `find()` method.
*
* @public
*/
export interface SavedObjectsFindResponse<T = unknown, A = unknown>
extends SavedObjectsBatchResponse<T> {
aggregations?: A;
total: number;
perPage: number;
page: number;
}

/**
* @public
*/
export interface SavedObjectsFindOptionsReference {
type: string;
id: string;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* 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 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.
*/

export type { SavedObjectsBatchResponse } from './base';
export type { SavedObjectsBulkCreateObject, SavedObjectsBulkCreateOptions } from './bulk_create';
export type { SavedObjectsBulkResolveResponse } from './bulk_resolve';
export type { SavedObjectsBulkUpdateObject, SavedObjectsBulkUpdateOptions } from './bulk_update';
export type { SavedObjectsCreateOptions } from './create';
export type { SavedObjectsDeleteOptions } from './delete';
export type {
SavedObjectsFindResponse,
SavedObjectsFindOptions,
SavedObjectsFindOptionsReference,
} from './find';
export type { ResolvedSimpleSavedObject } from './resolve';
export type { SavedObjectsUpdateOptions } from './update';
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
* Side Public License, v 1.
*/

import type { SavedObjectsResolveResponse } from '../../server';
import { SimpleSavedObject } from './simple_saved_object';
import type { SavedObjectsResolveResponse } from '@kbn/core-saved-objects-api-server';
import { SimpleSavedObject } from '../simple_saved_object';

/**
* This interface is a very simple wrapper for SavedObjects resolved from the server
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* 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 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 { SavedObjectReference } from '@kbn/core-saved-objects-common';

/** @public */
export interface SavedObjectsUpdateOptions<Attributes = unknown> {
version?: string;
upsert?: Attributes;
references?: SavedObjectReference[];
}
Loading