kibana/packages/kbn-utility-types
Jean-Louis Leysens 3c7bf58405
[Versioned HTTP] Add response runtime and type-level validation (#153011)
## Summary

This PR restructures the `validation` object on the `.addVersion` method
by:

1. Adding an `in` object for the `body`, `params` and `query`
validations
2. Adding `out` so that we can have both runtime and TS type checking
our responses

To reviewers: easiest way to interpret these changes is to read the
`example.ts` file.

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
2023-03-13 10:54:42 -03:00
..
src @kbn/utility-types: DotObject and DedotObject (#139539) 2022-08-31 17:51:34 +02:00
index.ts [Versioned HTTP] Add response runtime and type-level validation (#153011) 2023-03-13 10:54:42 -03:00
kibana.jsonc Transpile packages on demand, validate all TS projects (#146212) 2022-12-22 19:00:29 -06:00
package.json Transpile packages on demand, validate all TS projects (#146212) 2022-12-22 19:00:29 -06:00
README.md @kbn/utility-types: DotObject and DedotObject (#139539) 2022-08-31 17:51:34 +02:00
tsconfig.json Transpile packages on demand, validate all TS projects (#146212) 2022-12-22 19:00:29 -06:00

@kbn/utility-types

TypeScript utility types for usage in Kibana.

  • This package re-exports a subset of the items in utility-types
  • You can also add more utility types here.

Usage

import { UnwrapObservable } from '@kbn/utility-types';

type A = Observable<string>;
type B = UnwrapObservable<A>; // string

Reference

  • Assign<T, U> — From U assign properties to T (just like object assign).
  • DotObject<T> — Convert type T to a flattened structure.
  • DedotObject<T> — The inverse of DotObject<T>: convert the flattened type T to a deeply-nested type.
  • Ensure<T, X> — Makes sure T is of type X.
  • ObservableLike<T> — Minimal interface for an object resembling an Observable.
  • PublicContract<T> — Returns an object with public keys only.
  • PublicKeys<T> — Returns public keys of an object.
  • RecursiveReadonly<T> — Like Readonly<T>, but freezes object recursively.
  • ShallowPromise<T> — Same as Promise type, but it flat maps the wrapped type.
  • UnionToIntersection<T> — Converts a union of types into an intersection.
  • UnwrapObservable<T> — Returns wrapped type of an observable.
  • Values<T> — Returns object or array value types.