Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import { IRouter, SavedObjectsClient } from '@kbn/core/server';
import { API_BASE_PATH } from '../../common';
import { findAllGuides } from '../helpers';
import { guideStateSavedObjectsType } from '../saved_objects';

export const registerGetGuideStateRoute = (router: IRouter) => {
// Fetch all guides state
Expand All @@ -19,7 +20,9 @@ export const registerGetGuideStateRoute = (router: IRouter) => {
},
async (context, request, response) => {
const coreContext = await context.core;
const soClient = coreContext.savedObjects.client as SavedObjectsClient;
const soClient = coreContext.savedObjects.getClient({
includedHiddenTypes: [guideStateSavedObjectsType],
}) as SavedObjectsClient;

const existingGuides = await findAllGuides(soClient);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import { IRouter, SavedObjectsClient } from '@kbn/core/server';
import { schema } from '@kbn/config-schema';
import { GuideState } from '@kbn/guided-onboarding';
import { guideStateSavedObjectsType, pluginStateSavedObjectsType } from '../saved_objects';
import { getPluginState, updatePluginStatus } from '../helpers/plugin_state_utils';
import { API_BASE_PATH } from '../../common';
import { updateGuideState } from '../helpers';
Expand All @@ -21,7 +22,9 @@ export const registerGetPluginStateRoute = (router: IRouter) => {
},
async (context, request, response) => {
const coreContext = await context.core;
const savedObjectsClient = coreContext.savedObjects.client as SavedObjectsClient;
const savedObjectsClient = coreContext.savedObjects.getClient({
includedHiddenTypes: [pluginStateSavedObjectsType, guideStateSavedObjectsType],
}) as SavedObjectsClient;
const pluginState = await getPluginState(savedObjectsClient);
return response.ok({
body: {
Expand Down Expand Up @@ -59,7 +62,9 @@ export const registerPutPluginStateRoute = (router: IRouter) => {
const { status, guide } = request.body as { status?: string; guide?: GuideState };

const coreContext = await context.core;
const savedObjectsClient = coreContext.savedObjects.client as SavedObjectsClient;
const savedObjectsClient = coreContext.savedObjects.getClient({
includedHiddenTypes: [pluginStateSavedObjectsType, guideStateSavedObjectsType],
}) as SavedObjectsClient;

if (status) {
await updatePluginStatus(savedObjectsClient, status);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ export const guideStateSavedObjectsType = 'guided-onboarding-guide-state';

export const guideStateSavedObjects: SavedObjectsType = {
name: guideStateSavedObjectsType,
hidden: false,
// hidden SO can't be changed by the SO client except when explicitly declared
hidden: true,
// make it available in all spaces for now https://github.com/elastic/kibana/issues/144227
namespaceType: 'agnostic',
mappings: {
Expand All @@ -33,7 +34,8 @@ export const pluginStateSavedObjectsId = 'guided-onboarding-plugin-state-id';

export const pluginStateSavedObjects: SavedObjectsType = {
name: pluginStateSavedObjectsType,
hidden: false,
// hidden SO can't be changed by the SO client except when explicitly declared
hidden: true,
// make it available in all spaces for now https://github.com/elastic/kibana/issues/144227
namespaceType: 'agnostic',
mappings: {
Expand Down