Skip to content

Commit

Permalink
Update generated docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeelmers committed Dec 13, 2021
1 parent cd78430 commit c593b1f
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 20 deletions.
2 changes: 1 addition & 1 deletion docs/development/core/server/kibana-plugin-core-server.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 &lt; 7.0.0 which don't have a <code>references</code> root property defined. This type should only be used in migrations. |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<b>Signature:</b>

```typescript
export interface SavedObjectsType<Attributes extends SavedObjectAttributes = any>
export interface SavedObjectsType<Attributes = any>
```

## Properties
Expand Down Expand Up @@ -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 \| (() =&gt; SavedObjectMigrationMap) | <i>(Optional)</i> 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&lt;Attributes&gt; \| (() =&gt; SavedObjectsValidationMap&lt;Attributes&gt;) | <i>(Optional)</i> 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 \| (() =&gt; SavedObjectsValidationMap) | <i>(Optional)</i> 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. |

Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ See [SavedObjectsValidationMap](./kibana-plugin-core-server.savedobjectsvalidati
<b>Signature:</b>

```typescript
schemas?: SavedObjectsValidationMap<Attributes> | (() => SavedObjectsValidationMap<Attributes>);
schemas?: SavedObjectsValidationMap | (() => SavedObjectsValidationMap);
```
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,24 @@

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.

<b>Signature:</b>

```typescript
export declare type SavedObjectsValidationFunction<A extends SavedObjectAttributes = SavedObjectAttributes> = (data: A) => void;
export declare type SavedObjectsValidationFunction = (data: {
attributes: unknown;
}) => void;
```

## Example

The validation should look something like:

```typescript
const myAttributesValidation: SavedObjectsValidationFunction = (data) => {
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}]`);
}
}
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Any time you change the schema of a [SavedObjectsType](./kibana-plugin-core-serv
<b>Signature:</b>

```typescript
export interface SavedObjectsValidationMap<A extends SavedObjectAttributes = SavedObjectAttributes>
export interface SavedObjectsValidationMap
```

## Example
Expand All @@ -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}]`);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ See [SavedObjectsValidationFunction](./kibana-plugin-core-server.savedobjectsval
<b>Signature:</b>

```typescript
export declare type SavedObjectsValidationSpec<A extends SavedObjectAttributes> = ObjectType | SavedObjectsValidationFunction<A>;
export declare type SavedObjectsValidationSpec = ObjectType | SavedObjectsValidationFunction;
```
14 changes: 8 additions & 6 deletions src/core/server/server.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2771,7 +2771,7 @@ export interface SavedObjectStatusMeta {
}

// @public (undocumented)
export interface SavedObjectsType<Attributes extends SavedObjectAttributes = any> {
export interface SavedObjectsType<Attributes = any> {
convertToAliasScript?: string;
convertToMultiNamespaceTypeVersion?: string;
excludeOnUpgrade?: SavedObjectTypeExcludeFromUpgradeFilterHook;
Expand All @@ -2782,7 +2782,7 @@ export interface SavedObjectsType<Attributes extends SavedObjectAttributes = any
migrations?: SavedObjectMigrationMap | (() => SavedObjectMigrationMap);
name: string;
namespaceType: SavedObjectsNamespaceType;
schemas?: SavedObjectsValidationMap<Attributes> | (() => SavedObjectsValidationMap<Attributes>);
schemas?: SavedObjectsValidationMap | (() => SavedObjectsValidationMap);
}

// @public
Expand Down Expand Up @@ -2871,16 +2871,18 @@ export class SavedObjectsValidationError extends SchemaTypeError {
}

// @public
export type SavedObjectsValidationFunction<A extends SavedObjectAttributes = SavedObjectAttributes> = (data: A) => void;
export type SavedObjectsValidationFunction = (data: {
attributes: unknown;
}) => void;

// @public
export interface SavedObjectsValidationMap<A extends SavedObjectAttributes = SavedObjectAttributes> {
export interface SavedObjectsValidationMap {
// (undocumented)
[version: string]: SavedObjectsValidationSpec<A>;
[version: string]: SavedObjectsValidationSpec;
}

// @public
export type SavedObjectsValidationSpec<A extends SavedObjectAttributes> = ObjectType | SavedObjectsValidationFunction<A>;
export type SavedObjectsValidationSpec = ObjectType | SavedObjectsValidationFunction;

// Warning: (ae-extra-release-tag) The doc comment should not contain more than one release tag
//
Expand Down

0 comments on commit c593b1f

Please sign in to comment.