Skip to content

Commit

Permalink
Merge branch 'main' into cases-split-types-feature
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathan-buttner committed Apr 27, 2023
2 parents a108eb1 + f9d7655 commit 84a9741
Show file tree
Hide file tree
Showing 113 changed files with 10,986 additions and 1,727 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,7 @@
"@turf/distance": "6.0.1",
"@turf/helpers": "6.0.1",
"@turf/length": "^6.0.2",
"@xstate/react": "^3.0.2",
"@xstate/react": "^3.2.1",
"JSONStream": "1.3.5",
"abort-controller": "^3.0.0",
"adm-zip": "^0.5.9",
Expand Down Expand Up @@ -958,7 +958,7 @@
"vinyl": "^2.2.0",
"whatwg-fetch": "^3.0.0",
"xml2js": "^0.4.22",
"xstate": "^4.35.2",
"xstate": "^4.37.1",
"xterm": "^5.1.0",
"yauzl": "^2.10.0",
"yazl": "^2.5.1"
Expand Down
3 changes: 2 additions & 1 deletion packages/kbn-content-management-utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
* Side Public License, v 1.
*/

export * from './types';
export * from './src/types';
export * from './src/schema';
122 changes: 122 additions & 0 deletions packages/kbn-content-management-utils/src/schema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
/*
* 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 { schema, ObjectType } from '@kbn/config-schema';

export const apiError = schema.object({
error: schema.string(),
message: schema.string(),
statusCode: schema.number(),
metadata: schema.object({}, { unknowns: 'allow' }),
});

export const referenceSchema = schema.object(
{
name: schema.maybe(schema.string()),
type: schema.string(),
id: schema.string(),
},
{ unknowns: 'forbid' }
);

export const referencesSchema = schema.arrayOf(referenceSchema);

export const savedObjectSchema = (attributesSchema: ObjectType<any>) =>
schema.object(
{
id: schema.string(),
type: schema.string(),
version: schema.maybe(schema.string()),
createdAt: schema.maybe(schema.string()),
updatedAt: schema.maybe(schema.string()),
error: schema.maybe(apiError),
attributes: attributesSchema,
references: referencesSchema,
namespaces: schema.maybe(schema.arrayOf(schema.string())),
originId: schema.maybe(schema.string()),
},
{ unknowns: 'allow' }
);

export const objectTypeToGetResultSchema = (soSchema: ObjectType<any>) =>
schema.object(
{
item: soSchema,
meta: schema.object(
{
outcome: schema.oneOf([
schema.literal('exactMatch'),
schema.literal('aliasMatch'),
schema.literal('conflict'),
]),
aliasTargetId: schema.maybe(schema.string()),
aliasPurpose: schema.maybe(
schema.oneOf([
schema.literal('savedObjectConversion'),
schema.literal('savedObjectImport'),
])
),
},
{ unknowns: 'forbid' }
),
},
{ unknowns: 'forbid' }
);

// its recommended to create a subset of this schema for stricter validation
export const createOptionsSchemas = {
id: schema.maybe(schema.string()),
references: schema.maybe(referencesSchema),
overwrite: schema.maybe(schema.boolean()),
version: schema.maybe(schema.string()),
refresh: schema.maybe(schema.boolean()),
initialNamespaces: schema.maybe(schema.arrayOf(schema.string())),
};

export const schemaAndOr = schema.oneOf([schema.literal('AND'), schema.literal('OR')]);

// its recommended to create a subset of this schema for stricter validation
export const searchOptionsSchemas = {
page: schema.maybe(schema.number()),
perPage: schema.maybe(schema.number()),
sortField: schema.maybe(schema.string()),
sortOrder: schema.maybe(schema.oneOf([schema.literal('asc'), schema.literal('desc')])),
fields: schema.maybe(schema.arrayOf(schema.string())),
search: schema.maybe(schema.string()),
searchFields: schema.maybe(schema.oneOf([schema.string(), schema.arrayOf(schema.string())])),
rootSearchFields: schema.maybe(schema.arrayOf(schema.string())),

hasReference: schema.maybe(schema.oneOf([referenceSchema, schema.arrayOf(referenceSchema)])),
hasReferenceOperator: schema.maybe(schemaAndOr),
hasNoReference: schema.maybe(schema.oneOf([referenceSchema, schema.arrayOf(referenceSchema)])),
hasNoReferenceOperator: schema.maybe(schemaAndOr),
defaultSearchOperator: schema.maybe(schemaAndOr),
namespaces: schema.maybe(schema.arrayOf(schema.string())),
type: schema.maybe(schema.string()),

filter: schema.maybe(schema.string()),
pit: schema.maybe(
schema.object({ id: schema.string(), keepAlive: schema.maybe(schema.string()) })
),
};

// its recommended to create a subset of this schema for stricter validation
export const updateOptionsSchema = {
references: schema.maybe(referencesSchema),
version: schema.maybe(schema.string()),
refresh: schema.maybe(schema.oneOf([schema.boolean(), schema.literal('wait_for')])),
upsert: (attributesSchema: ObjectType<any>) => schema.maybe(savedObjectSchema(attributesSchema)),
retryOnConflict: schema.maybe(schema.number()),
};

export const createResultSchema = (soSchema: ObjectType<any>) =>
schema.object(
{
item: soSchema,
},
{ unknowns: 'forbid' }
);
1 change: 1 addition & 0 deletions packages/kbn-content-management-utils/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
],
"kbn_references": [
"@kbn/content-management-plugin",
"@kbn/config-schema",
"@kbn/core-saved-objects-api-server",
]
}
1 change: 1 addition & 0 deletions packages/kbn-doc-links/src/get_doc_links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ export const getDocLinks = ({ kibanaBranch }: GetDocLinkOptions): DocLinks => {
apiKeys: `${KIBANA_DOCS}api-keys.html`,
behavioralAnalytics: `${ENTERPRISE_SEARCH_DOCS}analytics-overview.html`,
behavioralAnalyticsEvents: `${ENTERPRISE_SEARCH_DOCS}analytics-events.html`,
buildConnector: `{$ENTERPRISE_SEARCH_DOCS}build-connector.html`,
bulkApi: `${ELASTICSEARCH_DOCS}docs-bulk.html`,
configuration: `${ENTERPRISE_SEARCH_DOCS}configuration.html`,
connectors: `${ENTERPRISE_SEARCH_DOCS}connectors.html`,
Expand Down
1 change: 1 addition & 0 deletions packages/kbn-doc-links/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ export interface DocLinks {
readonly apiKeys: string;
readonly behavioralAnalytics: string;
readonly behavioralAnalyticsEvents: string;
readonly buildConnector: string;
readonly bulkApi: string;
readonly configuration: string;
readonly connectors: string;
Expand Down
1 change: 0 additions & 1 deletion src/plugins/discover/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export const TRUNCATE_MAX_HEIGHT = 'truncate:maxHeight';
export const ROW_HEIGHT_OPTION = 'discover:rowHeightOption';
export const SEARCH_EMBEDDABLE_TYPE = 'search';
export const HIDE_ANNOUNCEMENTS = 'hideAnnouncements';
export const SHOW_LEGACY_FIELD_TOP_VALUES = 'discover:showLegacyFieldTopValues';
export const ENABLE_SQL = 'discover:enableSql';

export { DISCOVER_APP_LOCATOR, DiscoverAppLocatorDefinition } from './locator';
Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit 84a9741

Please sign in to comment.