From c593b1f33f4a3b81da8d719677e3a87fc714e87c Mon Sep 17 00:00:00 2001 From: Luke Elmers Date: Mon, 13 Dec 2021 15:07:52 -0700 Subject: [PATCH] Update generated docs. --- .../core/server/kibana-plugin-core-server.md | 2 +- .../kibana-plugin-core-server.savedobjectstype.md | 4 ++-- ...-plugin-core-server.savedobjectstype.schemas.md | 2 +- ...n-core-server.savedobjectsvalidationfunction.md | 12 ++++++++---- ...plugin-core-server.savedobjectsvalidationmap.md | 10 +++++----- ...lugin-core-server.savedobjectsvalidationspec.md | 2 +- src/core/server/server.api.md | 14 ++++++++------ 7 files changed, 26 insertions(+), 20 deletions(-) diff --git a/docs/development/core/server/kibana-plugin-core-server.md b/docs/development/core/server/kibana-plugin-core-server.md index 667d056af0a554..59e63eab323134 100644 --- a/docs/development/core/server/kibana-plugin-core-server.md +++ b/docs/development/core/server/kibana-plugin-core-server.md @@ -322,7 +322,7 @@ The plugin integrates with the core system via lifecycle events: `setup` | [SavedObjectsImportHook](./kibana-plugin-core-server.savedobjectsimporthook.md) | A hook associated with a specific saved object type, that will be invoked during the import process. The hook will have access to the objects of the registered type.Currently, the only supported feature for import hooks is to return warnings to be displayed in the UI when the import succeeds. The only interactions the hook can have with the import process is via the hook's response. Mutating the objects inside the hook's code will have no effect. | | [SavedObjectsImportWarning](./kibana-plugin-core-server.savedobjectsimportwarning.md) | Composite type of all the possible types of import warnings.See [SavedObjectsImportSimpleWarning](./kibana-plugin-core-server.savedobjectsimportsimplewarning.md) and [SavedObjectsImportActionRequiredWarning](./kibana-plugin-core-server.savedobjectsimportactionrequiredwarning.md) for more details. | | [SavedObjectsNamespaceType](./kibana-plugin-core-server.savedobjectsnamespacetype.md) | The namespace type dictates how a saved object can be interacted in relation to namespaces. Each type is mutually exclusive: \* single (default): This type of saved object is namespace-isolated, e.g., it exists in only one namespace. \* multiple: This type of saved object is shareable, e.g., it can exist in one or more namespaces. \* multiple-isolated: This type of saved object is namespace-isolated, e.g., it exists in only one namespace, but object IDs must be unique across all namespaces. This is intended to be an intermediate step when objects with a "single" namespace type are being converted to a "multiple" namespace type. In other words, objects with a "multiple-isolated" namespace type will be \*share-capable\*, but will not actually be shareable until the namespace type is changed to "multiple". \* agnostic: This type of saved object is global. | -| [SavedObjectsValidationFunction](./kibana-plugin-core-server.savedobjectsvalidationfunction.md) | The custom validation function if @kbn/config-schema is not a valid solution for your specific plugin requirements. | +| [SavedObjectsValidationFunction](./kibana-plugin-core-server.savedobjectsvalidationfunction.md) | The custom validation function if @kbn/config-schema is not a valid solution for your specific plugin requirements.Be careful not to mutate the provided attributes. | | [SavedObjectsValidationSpec](./kibana-plugin-core-server.savedobjectsvalidationspec.md) | Allowed property validation options: either @kbn/config-schema validations or custom validation functions.See [SavedObjectsValidationFunction](./kibana-plugin-core-server.savedobjectsvalidationfunction.md) for custom validation. | | [SavedObjectTypeExcludeFromUpgradeFilterHook](./kibana-plugin-core-server.savedobjecttypeexcludefromupgradefilterhook.md) | If defined, allows a type to run a search query and return a query filter that may match any documents which may be excluded from the next migration upgrade process. Useful for cleaning up large numbers of old documents which are no longer needed and may slow the migration process.If this hook fails, the migration will proceed without these documents having been filtered out, so this should not be used as a guarantee that these documents have been deleted.Experimental and subject to change | | [SavedObjectUnsanitizedDoc](./kibana-plugin-core-server.savedobjectunsanitizeddoc.md) | Describes Saved Object documents from Kibana < 7.0.0 which don't have a references root property defined. This type should only be used in migrations. | diff --git a/docs/development/core/server/kibana-plugin-core-server.savedobjectstype.md b/docs/development/core/server/kibana-plugin-core-server.savedobjectstype.md index be26649dd50acc..cd6e724685777a 100644 --- a/docs/development/core/server/kibana-plugin-core-server.savedobjectstype.md +++ b/docs/development/core/server/kibana-plugin-core-server.savedobjectstype.md @@ -8,7 +8,7 @@ Signature: ```typescript -export interface SavedObjectsType +export interface SavedObjectsType ``` ## Properties @@ -54,5 +54,5 @@ Note: migration function(s) can be optionally specified for any of these version | [migrations?](./kibana-plugin-core-server.savedobjectstype.migrations.md) | SavedObjectMigrationMap \| (() => SavedObjectMigrationMap) | (Optional) An optional map of [migrations](./kibana-plugin-core-server.savedobjectmigrationfn.md) or a function returning a map of [migrations](./kibana-plugin-core-server.savedobjectmigrationfn.md) to be used to migrate the type. | | [name](./kibana-plugin-core-server.savedobjectstype.name.md) | string | The name of the type, which is also used as the internal id. | | [namespaceType](./kibana-plugin-core-server.savedobjectstype.namespacetype.md) | SavedObjectsNamespaceType | The [namespace type](./kibana-plugin-core-server.savedobjectsnamespacetype.md) for the type. | -| [schemas?](./kibana-plugin-core-server.savedobjectstype.schemas.md) | SavedObjectsValidationMap<Attributes> \| (() => SavedObjectsValidationMap<Attributes>) | (Optional) An optional schema that can be used to validate the attributes of the type.When provided, calls to [create](./kibana-plugin-core-server.savedobjectsclient.create.md) will be validated against this schema.See [SavedObjectsValidationMap](./kibana-plugin-core-server.savedobjectsvalidationmap.md) for more details. | +| [schemas?](./kibana-plugin-core-server.savedobjectstype.schemas.md) | SavedObjectsValidationMap \| (() => SavedObjectsValidationMap) | (Optional) An optional schema that can be used to validate the attributes of the type.When provided, calls to [create](./kibana-plugin-core-server.savedobjectsclient.create.md) will be validated against this schema.See [SavedObjectsValidationMap](./kibana-plugin-core-server.savedobjectsvalidationmap.md) for more details. | diff --git a/docs/development/core/server/kibana-plugin-core-server.savedobjectstype.schemas.md b/docs/development/core/server/kibana-plugin-core-server.savedobjectstype.schemas.md index 78fb3d033b2ef0..466d8e361f9953 100644 --- a/docs/development/core/server/kibana-plugin-core-server.savedobjectstype.schemas.md +++ b/docs/development/core/server/kibana-plugin-core-server.savedobjectstype.schemas.md @@ -13,5 +13,5 @@ See [SavedObjectsValidationMap](./kibana-plugin-core-server.savedobjectsvalidati Signature: ```typescript -schemas?: SavedObjectsValidationMap | (() => SavedObjectsValidationMap); +schemas?: SavedObjectsValidationMap | (() => SavedObjectsValidationMap); ``` diff --git a/docs/development/core/server/kibana-plugin-core-server.savedobjectsvalidationfunction.md b/docs/development/core/server/kibana-plugin-core-server.savedobjectsvalidationfunction.md index 7fef39f7971f06..58fda4f141f25f 100644 --- a/docs/development/core/server/kibana-plugin-core-server.savedobjectsvalidationfunction.md +++ b/docs/development/core/server/kibana-plugin-core-server.savedobjectsvalidationfunction.md @@ -6,10 +6,14 @@ The custom validation function if @kbn/config-schema is not a valid solution for your specific plugin requirements. +Be careful not to mutate the provided attributes. + Signature: ```typescript -export declare type SavedObjectsValidationFunction = (data: A) => void; +export declare type SavedObjectsValidationFunction = (data: { + attributes: unknown; +}) => void; ``` ## Example @@ -17,9 +21,9 @@ export declare type SavedObjectsValidationFunction { - if (typeof data.bar !== 'string') { - throw new Error(`[bar]: expected value of type [string] but got [${typeof data.bar}]`); +const myAttributesValidation: SavedObjectsValidationFunction = ({ attributes }) => { + if (typeof attributes.bar !== 'string') { + throw new Error(`[bar]: expected value of type [string] but got [${typeof attributes.bar}]`); } } ``` diff --git a/docs/development/core/server/kibana-plugin-core-server.savedobjectsvalidationmap.md b/docs/development/core/server/kibana-plugin-core-server.savedobjectsvalidationmap.md index 508fcca97019e4..bb3e2b4c7c71e9 100644 --- a/docs/development/core/server/kibana-plugin-core-server.savedobjectsvalidationmap.md +++ b/docs/development/core/server/kibana-plugin-core-server.savedobjectsvalidationmap.md @@ -11,7 +11,7 @@ Any time you change the schema of a [SavedObjectsType](./kibana-plugin-core-serv Signature: ```typescript -export interface SavedObjectsValidationMap +export interface SavedObjectsValidationMap ``` ## Example @@ -25,12 +25,12 @@ const validationMap: SavedObjectValidationMap = { '1.1.0': schema.object({ foo: schema.oneOf([schema.string(), schema.boolean()]), }), - '2.1.0': (data) => { - if (typeof data.bar !== 'string') { + '2.1.0': ({ attributes }) => { + if (typeof attributes.bar !== 'string') { throw new Error(`[bar]: expected value of type [string] but got [${typeof data.bar}]`); } - if (typeof data.foo !== 'string' && typeof data.foo !== 'boolean') { - throw new Error(`[foo]: expected value of type [string,boolean] but got [${typeof data.foo}]`); + if (typeof attributes.foo !== 'string' && typeof attributes.foo !== 'boolean') { + throw new Error(`[foo]: expected value of type [string,boolean] but got [${typeof attributes.foo}]`); } } } diff --git a/docs/development/core/server/kibana-plugin-core-server.savedobjectsvalidationspec.md b/docs/development/core/server/kibana-plugin-core-server.savedobjectsvalidationspec.md index b69867d5939e78..00a098aa1076f1 100644 --- a/docs/development/core/server/kibana-plugin-core-server.savedobjectsvalidationspec.md +++ b/docs/development/core/server/kibana-plugin-core-server.savedobjectsvalidationspec.md @@ -11,5 +11,5 @@ See [SavedObjectsValidationFunction](./kibana-plugin-core-server.savedobjectsval Signature: ```typescript -export declare type SavedObjectsValidationSpec = ObjectType | SavedObjectsValidationFunction; +export declare type SavedObjectsValidationSpec = ObjectType | SavedObjectsValidationFunction; ``` diff --git a/src/core/server/server.api.md b/src/core/server/server.api.md index 198a21aa15f260..798a29b6022680 100644 --- a/src/core/server/server.api.md +++ b/src/core/server/server.api.md @@ -2771,7 +2771,7 @@ export interface SavedObjectStatusMeta { } // @public (undocumented) -export interface SavedObjectsType { +export interface SavedObjectsType { convertToAliasScript?: string; convertToMultiNamespaceTypeVersion?: string; excludeOnUpgrade?: SavedObjectTypeExcludeFromUpgradeFilterHook; @@ -2782,7 +2782,7 @@ export interface SavedObjectsType SavedObjectMigrationMap); name: string; namespaceType: SavedObjectsNamespaceType; - schemas?: SavedObjectsValidationMap | (() => SavedObjectsValidationMap); + schemas?: SavedObjectsValidationMap | (() => SavedObjectsValidationMap); } // @public @@ -2871,16 +2871,18 @@ export class SavedObjectsValidationError extends SchemaTypeError { } // @public -export type SavedObjectsValidationFunction = (data: A) => void; +export type SavedObjectsValidationFunction = (data: { + attributes: unknown; +}) => void; // @public -export interface SavedObjectsValidationMap { +export interface SavedObjectsValidationMap { // (undocumented) - [version: string]: SavedObjectsValidationSpec; + [version: string]: SavedObjectsValidationSpec; } // @public -export type SavedObjectsValidationSpec = ObjectType | SavedObjectsValidationFunction; +export type SavedObjectsValidationSpec = ObjectType | SavedObjectsValidationFunction; // Warning: (ae-extra-release-tag) The doc comment should not contain more than one release tag //