Skip to content

Commit

Permalink
[Move @kbn/config-schema to server] data_views
Browse files Browse the repository at this point in the history
  • Loading branch information
afharo committed Aug 27, 2024
1 parent 2441e9a commit 8d1dcbf
Show file tree
Hide file tree
Showing 23 changed files with 57 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Side Public License, v 1.
*/

import { DATA_VIEW_SAVED_OBJECT_TYPE as DataViewSOType } from '../..';
import { DATA_VIEW_SAVED_OBJECT_TYPE as DataViewSOType } from '..';
export { DataViewSOType };

/**
Expand Down
8 changes: 7 additions & 1 deletion src/plugins/data_views/common/content_management/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,10 @@
* Side Public License, v 1.
*/

export * from './v1';
export { LATEST_VERSION } from './constants';

export type { DataViewCrudTypes } from '../../server/content_management/schemas/v1/types';

export type { DataViewContentType } from './constants';

export { DataViewSOType } from './constants';
2 changes: 1 addition & 1 deletion src/plugins/data_views/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export {
MAX_DATA_VIEW_FIELD_DESCRIPTION_LENGTH,
} from './constants';

export { LATEST_VERSION } from './content_management/v1/constants';
export { LATEST_VERSION } from './content_management/constants';

export type { ToSpecConfig } from './fields';
export type { IIndexPatternFieldList } from './fields';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
SavedObjectsClientCommonFindArgs,
} from '../common/types';

import type { DataViewCrudTypes } from '../common/content_management';
import type { DataViewCrudTypes } from '../server/content_management/schemas';

import { DataViewSOType } from '../common/content_management';

Expand Down
2 changes: 1 addition & 1 deletion src/plugins/data_views/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { getIndices, HasData } from './services';
import { debounceByKey } from './debounce_by_key';

import { DATA_VIEW_SAVED_OBJECT_TYPE } from '../common/constants';
import { LATEST_VERSION } from '../common/content_management/v1/constants';
import { LATEST_VERSION } from '../common/content_management/constants';

export class DataViewsPublicPlugin
implements
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
import { SOContentStorage } from '@kbn/content-management-utils';
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 './schemas/cm_services';
import type { DataViewCrudTypes } from './schemas';
import { DataViewSOType } from './schemas';

export class DataViewsStorage extends SOContentStorage<DataViewCrudTypes> {
constructor({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import type {
Version,
} from '@kbn/object-versioning';

// We export the versionned service definition from this file and not the barrel to avoid adding
// We export the versioned service definition from this file and not the barrel to avoid adding
// the schemas in the "public" js bundle

import { serviceDefinition as v1 } from './v1/cm_services';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
* 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 * from './v1';
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 '../../../rest_api_routes/schemas';

const dataViewAttributesSchema = schema.object(
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* 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 { DATA_VIEW_SAVED_OBJECT_TYPE as DataViewSOType } from '../../../../common';
export { DataViewSOType };

/**
* Data view saved object version.
*/
export const LATEST_VERSION = 1;

export type DataViewContentType = typeof DataViewSOType;
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import type {
SavedObjectSearchOptions,
SavedObjectUpdateOptions,
} from '@kbn/content-management-utils';
import { DataViewAttributes } from '../../types';
import { DataViewAttributes } from '../../../../common/types';
import { DataViewContentType } from './constants';

interface DataViewCreateOptions {
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

0 comments on commit 8d1dcbf

Please sign in to comment.