Skip to content

Commit

Permalink
[Move @kbn/config-schema to server] @kbn/content-management-utils (
Browse files Browse the repository at this point in the history
  • Loading branch information
afharo authored Aug 28, 2024
1 parent 02a3992 commit 15deafa
Show file tree
Hide file tree
Showing 43 changed files with 67 additions and 51 deletions.
2 changes: 1 addition & 1 deletion packages/kbn-content-management-utils/kibana.jsonc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"type": "shared-common",
"type": "shared-server",
"id": "@kbn/content-management-utils",
"owner": "@elastic/kibana-data-discovery"
}
7 changes: 0 additions & 7 deletions src/plugins/dashboard/common/content_management/v1/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,3 @@ export type {
DashboardAttributes,
SavedDashboardPanel,
} from './types';

export {
serviceDefinition,
dashboardSavedObjectSchema,
controlGroupInputSchema,
dashboardAttributesSchema,
} from './cm_services';
6 changes: 0 additions & 6 deletions src/plugins/dashboard/common/content_management/v2/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,5 @@
* Side Public License, v 1.
*/

export {
serviceDefinition,
dashboardSavedObjectSchema,
dashboardAttributesSchema,
} from './cm_services';

export type { GridData, DashboardItem, SavedDashboardPanel } from '../v1/types'; // no changes made to types from v1 to v2
export type { DashboardCrudTypes, DashboardAttributes } from './types';
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Side Public License, v 1.
*/

import {
import type {
ContentManagementCrudTypes,
SavedObjectCreateOptions,
SavedObjectUpdateOptions,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { SavedObjectsFindOptions } from '@kbn/core-saved-objects-api-server';
import type { Logger } from '@kbn/logging';

import { CONTENT_ID } from '../../common/content_management';
import { cmServicesDefinition } from '../../common/content_management/cm_services';
import { cmServicesDefinition } from './schema/cm_services';
import type { DashboardCrudTypes } from '../../common/content_management';

const searchArgsToSOFindOptions = (
Expand Down
14 changes: 14 additions & 0 deletions src/plugins/dashboard/server/content_management/schema/v1/index.ts
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.
*/

export {
serviceDefinition,
dashboardSavedObjectSchema,
controlGroupInputSchema,
dashboardAttributesSchema,
} from './cm_services';
13 changes: 13 additions & 0 deletions src/plugins/dashboard/server/content_management/schema/v2/index.ts
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.
*/

export {
serviceDefinition,
dashboardSavedObjectSchema,
dashboardAttributesSchema,
} from './cm_services';
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
import { ANALYTICS_SAVED_OBJECT_INDEX } from '@kbn/core-saved-objects-server';
import { SavedObjectsType } from '@kbn/core/server';

import { dashboardAttributesSchema as dashboardAttributesSchemaV1 } from '../../common/content_management/v1';
import { dashboardAttributesSchema as dashboardAttributesSchemaV2 } from '../../common/content_management/v2';
import { dashboardAttributesSchema as dashboardAttributesSchemaV1 } from '../content_management/schema/v1';
import { dashboardAttributesSchema as dashboardAttributesSchemaV2 } from '../content_management/schema/v2';
import {
createDashboardSavedObjectTypeMigrations,
DashboardSavedObjectTypeMigrationsDeps,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import type { Logger } from '@kbn/logging';

import type { DataViewCrudTypes } from '../../common/content_management';
import { DataViewSOType } from '../../common/content_management';
import { cmServicesDefinition } from '../../common/content_management/cm_services';
import { cmServicesDefinition } from './schema/cm_services';

export class DataViewsStorage extends SOContentStorage<DataViewCrudTypes> {
constructor({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import {
createResultSchema,
searchOptionsSchemas,
} from '@kbn/content-management-utils';
import { DataViewType } from '../..';
import { MAX_DATA_VIEW_FIELD_DESCRIPTION_LENGTH } from '../../constants';
import { serializedFieldFormatSchema, fieldSpecSchema } from '../../schemas';
import { DataViewType } from '../../../../common';
import { MAX_DATA_VIEW_FIELD_DESCRIPTION_LENGTH } from '../../../../common/constants';
import { serializedFieldFormatSchema, fieldSpecSchema } from '../../../schemas';

const dataViewAttributesSchema = schema.object(
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { IRouter, StartServicesAccessor } from '@kbn/core/server';
import { SerializedFieldFormat } from '@kbn/field-formats-plugin/common';
import { DataViewsService } from '../../../../common';
import { handleErrors } from '../util/handle_errors';
import { serializedFieldFormatSchema } from '../../../../common/schemas';
import { serializedFieldFormatSchema } from '../../../schemas';
import { MAX_DATA_VIEW_FIELD_DESCRIPTION_LENGTH } from '../../../../common/constants';
import { dataViewSpecSchema } from '../../schema';
import { DataViewSpecRestResponse } from '../../route_types';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { IRouter, StartServicesAccessor } from '@kbn/core/server';
import { DataViewsService } from '../../../../common/data_views';
import { RuntimeField } from '../../../../common/types';
import { handleErrors } from '../util/handle_errors';
import { runtimeFieldSchema } from '../../../../common/schemas';
import { runtimeFieldSchema } from '../../../schemas';
import type {
DataViewsServerPluginStart,
DataViewsServerPluginStartDependencies,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { IRouter, StartServicesAccessor } from '@kbn/core/server';
import { DataViewsService } from '../../../../common/data_views';
import { RuntimeField } from '../../../../common/types';
import { handleErrors } from '../util/handle_errors';
import { runtimeFieldSchema } from '../../../../common/schemas';
import { runtimeFieldSchema } from '../../../schemas';
import type {
DataViewsServerPluginStart,
DataViewsServerPluginStartDependencies,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { DataViewsService } from '../../../../common/data_views';
import { RuntimeField } from '../../../../common/types';
import { ErrorIndexPatternFieldNotFound } from '../../../error';
import { handleErrors } from '../util/handle_errors';
import { runtimeFieldSchemaUpdate } from '../../../../common/schemas';
import { runtimeFieldSchemaUpdate } from '../../../schemas';
import type {
DataViewsServerPluginStart,
DataViewsServerPluginStartDependencies,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import { schema } from '@kbn/config-schema';
import { IRouter, StartServicesAccessor } from '@kbn/core/server';
import { handleErrors } from '../util/handle_errors';
import { fieldSpecSchema } from '../../../../common/schemas';
import { fieldSpecSchema } from '../../../schemas';
import type {
DataViewsServerPluginStart,
DataViewsServerPluginStartDependencies,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import type {
DataViewsServerPluginStartDependencies,
} from '../../../types';
import { INITIAL_REST_VERSION } from '../../../constants';
import { fieldSpecSchemaFields } from '../../../../common/schemas';
import { fieldSpecSchemaFields } from '../../../schemas';
import { FieldSpecRestResponse } from '../../route_types';

export const registerGetScriptedFieldRoute = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import { schema } from '@kbn/config-schema';
import { IRouter, StartServicesAccessor } from '@kbn/core/server';
import { handleErrors } from '../util/handle_errors';
import { fieldSpecSchema } from '../../../../common/schemas';
import { fieldSpecSchema } from '../../../schemas';
import type {
DataViewsServerPluginStart,
DataViewsServerPluginStartDependencies,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { IRouter, StartServicesAccessor } from '@kbn/core/server';
import { FieldSpec } from '../../../../common';
import { ErrorIndexPatternFieldNotFound } from '../../../error';
import { handleErrors } from '../util/handle_errors';
import { fieldSpecSchemaFields } from '../../../../common/schemas';
import { fieldSpecSchemaFields } from '../../../schemas';
import type {
DataViewsServerPluginStart,
DataViewsServerPluginStartDependencies,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@ import { DataViewSpecRestResponse } from '../route_types';
import { DataViewsService } from '../../../common/data_views';
import { DataViewSpec } from '../../../common/types';
import { handleErrors } from './util/handle_errors';
import {
fieldSpecSchema,
runtimeFieldSchema,
serializedFieldFormatSchema,
} from '../../../common/schemas';
import { fieldSpecSchema, runtimeFieldSchema, serializedFieldFormatSchema } from '../../schemas';
import { dataViewSpecSchema } from '../schema';
import type {
DataViewsServerPluginStartDependencies,
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/data_views/server/rest_api_routes/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
runtimeFieldSchema,
serializedFieldFormatSchema,
fieldSpecSchemaFields,
} from '../../common/schemas';
} from '../schemas';
import { MAX_DATA_VIEW_FIELD_DESCRIPTION_LENGTH } from '../../common/constants';

export const dataViewSpecSchema = schema.object({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
*/

import { schema, Type } from '@kbn/config-schema';
import { MAX_DATA_VIEW_FIELD_DESCRIPTION_LENGTH } from './constants';
import { RuntimeType } from '.';
import { MAX_DATA_VIEW_FIELD_DESCRIPTION_LENGTH } from '../common/constants';
import { RuntimeType } from '../common';

export const serializedFieldFormatSchema = schema.object({
id: schema.maybe(schema.string()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
CreateResult,
UpdateResult,
} from '@kbn/content-management-plugin/common';
import { ContentManagementCrudTypes } from '@kbn/content-management-utils';
import type { ContentManagementCrudTypes } from '@kbn/content-management-utils';

import type { DataViewSpec } from '@kbn/data-views-plugin/common';
import type { EventAnnotationConfig } from '@kbn/event-annotation-common';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { SOContentStorage } from '@kbn/content-management-utils';

import { EVENT_ANNOTATION_GROUP_TYPE } from '@kbn/event-annotation-common';
import { Logger } from '@kbn/logging';
import { cmServicesDefinition } from '../../common/content_management/cm_services';
import { cmServicesDefinition } from './schema/cm_services';
import type { EventAnnotationGroupCrudTypes } from '../../common/content_management';

export class EventAnnotationGroupStorage extends SOContentStorage<EventAnnotationGroupCrudTypes> {
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/links/common/persistable_state/references.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Side Public License, v 1.
*/

import { Reference } from '@kbn/content-management-utils';
import type { Reference } from '@kbn/content-management-utils';
import { omit } from 'lodash';
import { DASHBOARD_LINK_TYPE, LinksAttributes } from '../content_management';

Expand Down
2 changes: 1 addition & 1 deletion src/plugins/links/public/lib/deserialize_from_library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Side Public License, v 1.
*/

import { SOWithMetadata } from '@kbn/content-management-utils';
import type { SOWithMetadata } from '@kbn/content-management-utils';
import { LinksAttributes } from '../../common/content_management';
import { injectReferences } from '../../common/persistable_state';
import { LinksByReferenceSerializedState, LinksRuntimeState, LinksSerializedState } from '../types';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import type { Logger } from '@kbn/logging';
import { SOContentStorage } from '@kbn/content-management-utils';
import { CONTENT_ID } from '../../common';
import type { LinksCrudTypes } from '../../common/content_management';
import { cmServicesDefinition } from '../../common/content_management/cm_services';
import { cmServicesDefinition } from './schema/cm_services';

export class LinksStorage extends SOContentStorage<LinksCrudTypes> {
constructor({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@ import {
createOptionsSchemas,
objectTypeToGetResultSchema,
} from '@kbn/content-management-utils';
import { DASHBOARD_LINK_TYPE, EXTERNAL_LINK_TYPE } from '.';
import { LINKS_HORIZONTAL_LAYOUT, LINKS_VERTICAL_LAYOUT } from './constants';
import { DASHBOARD_LINK_TYPE, EXTERNAL_LINK_TYPE } from '../../../../common/content_management/v1';
import {
LINKS_HORIZONTAL_LAYOUT,
LINKS_VERTICAL_LAYOUT,
} from '../../../../common/content_management/v1/constants';

const baseLinkSchema = {
id: schema.string(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import type { Logger } from '@kbn/logging';

import type { SavedSearchCrudTypes } from '../../common/content_management';
import { SavedSearchType } from '../../common/content_management';
import { cmServicesDefinition } from '../../common/content_management/cm_services';
import { cmServicesDefinition } from './schema/cm_services';

export class SavedSearchStorage extends SOContentStorage<SavedSearchCrudTypes> {
constructor({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ import {
updateOptionsSchema,
createResultSchema,
} from '@kbn/content-management-utils';
import { MIN_SAVED_SEARCH_SAMPLE_SIZE, MAX_SAVED_SEARCH_SAMPLE_SIZE } from '../../constants';
import {
MIN_SAVED_SEARCH_SAMPLE_SIZE,
MAX_SAVED_SEARCH_SAMPLE_SIZE,
} from '../../../../common/constants';

const sortSchema = schema.arrayOf(schema.string(), { maxSize: 2 });

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
CreateResult,
UpdateResult,
} from '@kbn/content-management-plugin/common';
import { ContentManagementCrudTypes } from '@kbn/content-management-utils';
import type { ContentManagementCrudTypes } from '@kbn/content-management-utils';

import { VisualizationContentType } from '../types';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import { SearchQuery } from '@kbn/content-management-plugin/common';
import { ContentManagementPublicStart } from '@kbn/content-management-plugin/public';
import {
import type {
ContentManagementCrudTypes,
SavedObjectCreateOptions,
SavedObjectUpdateOptions,
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/graph/common/content_management/v1/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
CreateResult,
UpdateResult,
} from '@kbn/content-management-plugin/common';
import { ContentManagementCrudTypes } from '@kbn/content-management-utils';
import type { ContentManagementCrudTypes } from '@kbn/content-management-utils';

import { GraphContentType } from '../types';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { SOContentStorage, tagsToFindOptions } from '@kbn/content-management-uti
import { SavedObjectsFindOptions } from '@kbn/core-saved-objects-api-server';
import type { Logger } from '@kbn/logging';
import { CONTENT_ID } from '../../common/content_management';
import { cmServicesDefinition } from '../../common/content_management/cm_services';
import { cmServicesDefinition } from './schema/cm_services';
import type { MapCrudTypes } from '../../common/content_management';

const searchArgsToSOFindOptions = (args: MapCrudTypes['SearchIn']): SavedObjectsFindOptions => {
Expand Down

0 comments on commit 15deafa

Please sign in to comment.