-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create common and api types packages for the savedObjects domain (#13…
…6722) * Creating empty @kbn/core-saved-objects-common package * start moving types around * start fixing imports * fix entrypoint exports * fix external import * create explicit ISavedObjectsRepository interface * fix another external usage * rewrite browser exports * create explicit SavedObjectsClientContract interface * move client/repository types to @kbn/core-saved-objects-api-server * start fixing imports * one more * fix global re-exports * fix some browser-side imports * fix more violations * prepare the browser-side client * fix one more usage * fix external usage * fix more external usages * one more * Create @kbn/core-saved-objects-api-browser package * fix more usages of error helper * fix more internal imports * use interface for SSO * adapt more imports * damn those types were a mess * fix more usages of SSO * Revert "fix more usages of SSO" This reverts commit 07a12e5. * Revert "use interface for SSO" This reverts commit 6240fc8. * export the interface with the old name instead. * adapt tests concrete usages of SSO * export reference type, more fixes * this gonna be long * one more * other resolve type change * more usages * Am I getting close? * yet more fixes * back to client impl * fix bulkGetting undefined * fix SS mock * some cleanup * self-review * fix new usages
- Loading branch information
1 parent
b3d7d12
commit 0645a3b
Showing
198 changed files
with
3,627 additions
and
2,286 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
108 changes: 108 additions & 0 deletions
108
packages/core/saved-objects/core-saved-objects-api-browser/BUILD.bazel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"], | ||
) |
3 changes: 3 additions & 0 deletions
3
packages/core/saved-objects/core-saved-objects-api-browser/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
13 changes: 13 additions & 0 deletions
13
packages/core/saved-objects/core-saved-objects-api-browser/jest.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'], | ||
}; |
8 changes: 8 additions & 0 deletions
8
packages/core/saved-objects/core-saved-objects-api-browser/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} |
14 changes: 14 additions & 0 deletions
14
packages/core/saved-objects/core-saved-objects-api-browser/src/apis/base.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>>; | ||
} |
26 changes: 26 additions & 0 deletions
26
packages/core/saved-objects/core-saved-objects-api-browser/src/apis/bulk_create.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
14 changes: 14 additions & 0 deletions
14
packages/core/saved-objects/core-saved-objects-api-browser/src/apis/bulk_resolve.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>>; | ||
} |
23 changes: 23 additions & 0 deletions
23
packages/core/saved-objects/core-saved-objects-api-browser/src/apis/bulk_update.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
27 changes: 27 additions & 0 deletions
27
packages/core/saved-objects/core-saved-objects-api-browser/src/apis/create.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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[]; | ||
} |
13 changes: 13 additions & 0 deletions
13
packages/core/saved-objects/core-saved-objects-api-browser/src/apis/delete.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
39 changes: 39 additions & 0 deletions
39
packages/core/saved-objects/core-saved-objects-api-browser/src/apis/find.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
21 changes: 21 additions & 0 deletions
21
packages/core/saved-objects/core-saved-objects-api-browser/src/apis/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
packages/core/saved-objects/core-saved-objects-api-browser/src/apis/update.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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[]; | ||
} |
Oops, something went wrong.