From 1b7f4c6b65e036494463479db1d4a75d9f2f1f9d Mon Sep 17 00:00:00 2001 From: "Christiane (Tina) Heiligers" Date: Tue, 5 Nov 2024 12:10:51 -0700 Subject: [PATCH 1/2] Adds info about accessing hidden SO types --- dev_docs/tutorials/saved_objects.mdx | 7 +++++-- .../core-saved-objects-server/src/saved_objects_type.ts | 5 +++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/dev_docs/tutorials/saved_objects.mdx b/dev_docs/tutorials/saved_objects.mdx index f93d774e663f3..8d36ec4a6f058 100644 --- a/dev_docs/tutorials/saved_objects.mdx +++ b/dev_docs/tutorials/saved_objects.mdx @@ -18,7 +18,7 @@ import { SavedObjectsType } from 'src/core/server'; export const dashboardVisualization: SavedObjectsType = { name: 'dashboard_visualization', [1] - hidden: true, + hidden: true, [3] switchToModelVersionAt: '8.10.0', // this is the default, feel free to omit it unless you intend to switch to using model versions before 8.10.0 namespaceType: 'multiple-isolated', [2] mappings: { @@ -46,6 +46,9 @@ these should follow our API URL path convention and always be written in snake c that objects of this type can only exist in a single space. See for more information. +[3] This field determines whether repositories have access to the type by default. he hidden types will not be automatically exposed via the HTTP API. +Access a hidden type with a client that explicitly includes a list of hidden types `SavedObjectsClientProviderOptions[includedHiddenTypes]`. + **src/plugins/my_plugin/server/saved_objects/index.ts** ```ts @@ -301,4 +304,4 @@ export const foo: SavedObjectsType = { [1] Needs to be `false` to use the `hiddenFromHttpApis` option -[2] Set this to `true` to build your own HTTP API and have complete control over the route handler. \ No newline at end of file +[2] Set this to `true` to build your own HTTP API and have complete control over the route handler. diff --git a/packages/core/saved-objects/core-saved-objects-server/src/saved_objects_type.ts b/packages/core/saved-objects/core-saved-objects-server/src/saved_objects_type.ts index 1912863b52703..5c980fc8a3a73 100644 --- a/packages/core/saved-objects/core-saved-objects-server/src/saved_objects_type.ts +++ b/packages/core/saved-objects/core-saved-objects-server/src/saved_objects_type.ts @@ -37,7 +37,12 @@ export interface SavedObjectsType { * The hidden types will not be automatically exposed via the HTTP API. * Therefore, that should prevent unexpected behavior in the client code, as all the interactions will be done via the plugin API. * + * Access a hidden type with a client that explicitly includes a list of hidden types + * + * (await context.core).savedObjects.getClient({ includeHiddenTypes: [MY_PLUGIN_HIDDEN_SAVED_OBJECT_TYPE] }) + * * See {@link SavedObjectsServiceStart.createInternalRepository | createInternalRepository}. + * */ hidden: boolean; /** From 8023e2b3b2f69f1e465170a3c8e9be3d7baf14f1 Mon Sep 17 00:00:00 2001 From: "Christiane (Tina) Heiligers" Date: Tue, 5 Nov 2024 17:06:55 -0700 Subject: [PATCH 2/2] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Alejandro Fernández Haro --- dev_docs/tutorials/saved_objects.mdx | 4 ++-- .../core-saved-objects-server/src/saved_objects_type.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dev_docs/tutorials/saved_objects.mdx b/dev_docs/tutorials/saved_objects.mdx index 8d36ec4a6f058..233795374f2e9 100644 --- a/dev_docs/tutorials/saved_objects.mdx +++ b/dev_docs/tutorials/saved_objects.mdx @@ -46,8 +46,8 @@ these should follow our API URL path convention and always be written in snake c that objects of this type can only exist in a single space. See for more information. -[3] This field determines whether repositories have access to the type by default. he hidden types will not be automatically exposed via the HTTP API. -Access a hidden type with a client that explicitly includes a list of hidden types `SavedObjectsClientProviderOptions[includedHiddenTypes]`. +[3] This field determines whether repositories have access to the type by default. Hidden types will not be automatically exposed via the Saved Objects Client APIs. +Hidden types must be listed in `SavedObjectsClientProviderOptions[includedHiddenTypes]` to be accessible by the client. **src/plugins/my_plugin/server/saved_objects/index.ts** diff --git a/packages/core/saved-objects/core-saved-objects-server/src/saved_objects_type.ts b/packages/core/saved-objects/core-saved-objects-server/src/saved_objects_type.ts index 5c980fc8a3a73..a29875a733d68 100644 --- a/packages/core/saved-objects/core-saved-objects-server/src/saved_objects_type.ts +++ b/packages/core/saved-objects/core-saved-objects-server/src/saved_objects_type.ts @@ -37,7 +37,7 @@ export interface SavedObjectsType { * The hidden types will not be automatically exposed via the HTTP API. * Therefore, that should prevent unexpected behavior in the client code, as all the interactions will be done via the plugin API. * - * Access a hidden type with a client that explicitly includes a list of hidden types + * Hidden types must be listed to be accessible by the client. * * (await context.core).savedObjects.getClient({ includeHiddenTypes: [MY_PLUGIN_HIDDEN_SAVED_OBJECT_TYPE] }) *