kibana/x-pack/plugins/graph/public/helpers
Spencer 2e314db2ce
Wrap rison-node to improve types (#146649)
@maximpn brought up the issues caused by the types required by the
rison-node package, which attempted to communicate that "encoded values
must be primitive values, or recursive arrays/object of primitive
values". This isn't actually expressible in TypeScript, which lead to
many instances of `rison.encode(value as unknown as RisonValue)` which
is useless. Additionally, the rison-node library actually supports any
value and will either produce valid rison or `undefined` for that value.

To address this I'm adding a wrapper function which accepts `any` and
returns a `string`. If rison-node is totally unable to produce any rison
for the value (because the value is `undefined` or some other type like
Symbol or BigInt) the `encode()` function will throw. If you're
accepting arbitrary input you can use the `encodeUnknown()` function,
which will return a string or undefined, if the value you provided has
zero rison representation.

Like JSON.stringify() any non-circular primitive, object, or array can
be encoded with either function. If the values within those objects are
not encodable (functions, RegExps, etc) then they will be skipped. Any
object/array with the `toJSON()` method will be converted to JSON first,
and if the prototype of the object has the `encode_rison()` method it
will be used to convert he value into rison.

The changes in this PR are mostly updating usage of rison-node to use
`@kbn/rison` (which is also enforced by eslint). There are also several
changes which remove unnecessary casting.
2022-12-01 08:33:56 -07:00
..
as_observable.ts [Graph] Deangularize graph app controller (#106587) 2021-08-31 19:26:45 +03:00
format_http_error.ts Migrate types to packages: Client-side HTTP service (#135562) 2022-07-11 12:25:55 -07:00
kql_encoder.test.ts [DX] Upgrade prettier to v2.4.0 (#112359) 2021-09-19 22:34:30 -07:00
kql_encoder.ts Wrap rison-node to improve types (#146649) 2022-12-01 08:33:56 -07:00
outlink_encoders.ts Wrap rison-node to improve types (#146649) 2022-12-01 08:33:56 -07:00
saved_workspace_utils.test.ts [Graph] Fix guidance panel appearing for a moment when saving Graph (#141228) 2022-09-22 10:22:18 -03:00
saved_workspace_utils.ts [Graph] Fix guidance panel appearing for a moment when saving Graph (#141228) 2022-09-22 10:22:18 -03:00
style_choices.ts
url_template.ts
use_graph_loader.ts [Graph] Align Inspect requests experience with common approach (#141222) 2022-09-29 11:19:58 +03:00
use_inspector.ts [Graph] Align Inspect requests experience with common approach (#141222) 2022-09-29 11:19:58 +03:00
use_workspace_loader.test.tsx [Graph] Migrate from savedObjectsClient to dataViews and fix the displayed data view name (#135142) 2022-06-28 17:00:23 +02:00
use_workspace_loader.ts Create common and api types packages for the savedObjects domain (#136722) 2022-07-26 04:01:33 -07:00