-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: correctly access types from "to" function #32691
Conversation
Pinging @elastic/kibana-canvas |
@chrisdavies it occurred to me that we may need to check the environment to get the right registry, since we (I think incorrectly) have two different ones. I think without this, we'd end up bundling the wrong registry in the browser... diff --git a/x-pack/plugins/canvas/common/functions/to.js b/x-pack/plugins/canvas/common/functions/to.js
index 9344265f59..cf47606a6a 100644
--- a/x-pack/plugins/canvas/common/functions/to.js
+++ b/x-pack/plugins/canvas/common/functions/to.js
@@ -5,7 +5,8 @@
*/
import { castProvider } from '@kbn/interpreter/common';
-import { registries } from '@kbn/interpreter/server';
+import { registries as serverRegistries } from '@kbn/interpreter/server';
+import { registries as browserRegistries } from '@kbn/interpreter/public';
export const to = () => ({
name: 'to',
@@ -20,11 +21,13 @@ export const to = () => ({
multi: true,
},
},
- fn: (context, args) => {
+ fn: (context, args, { environment }) => {
if (!args.type) {
throw new Error('Must specify a casting type');
}
+ const registries = environment === 'client' ? browserRegistries : serverRegistries;
+
return castProvider(registries.types.toJS())(context, args.type);
},
}); Thoughts? |
💚 Build Succeeded |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
they are not exposed on the handlers object, they must be imported from @kbn/interpreter
OK, no need to handle the browser registries stuff, the server function is always used thanks to #33039. |
7925cbe
to
dd912c5
Compare
types can be accessed in the browser now, and a common function makes no sense right now. also elastic#33039 prevents having the same function in both places anyway
dd912c5
to
213d510
Compare
I've updated the PR to make the |
💚 Build Succeeded |
* fix: correctly access types they are not exposed on the handlers object, they must be imported from @kbn/interpreter * chore: move to function to browser types can be accessed in the browser now, and a common function makes no sense right now. also elastic#33039 prevents having the same function in both places anyway
* fix: correctly access types they are not exposed on the handlers object, they must be imported from @kbn/interpreter * chore: move to function to browser types can be accessed in the browser now, and a common function makes no sense right now. also elastic#33039 prevents having the same function in both places anyway
* fix: correctly access types they are not exposed on the handlers object, they must be imported from @kbn/interpreter * chore: move to function to browser types can be accessed in the browser now, and a common function makes no sense right now. also elastic#33039 prevents having the same function in both places anyway
* fix: correctly access types they are not exposed on the handlers object, they must be imported from @kbn/interpreter * chore: move to function to browser types can be accessed in the browser now, and a common function makes no sense right now. also #33039 prevents having the same function in both places anyway
* fix: correctly access types they are not exposed on the handlers object, they must be imported from @kbn/interpreter * chore: move to function to browser types can be accessed in the browser now, and a common function makes no sense right now. also #33039 prevents having the same function in both places anyway
* fix: correctly access types they are not exposed on the handlers object, they must be imported from @kbn/interpreter * chore: move to function to browser types can be accessed in the browser now, and a common function makes no sense right now. also #33039 prevents having the same function in both places anyway
Closes #32597
Blocked by #32600 (mostly for verification reasons)mergedTypes were being pulled from the handlers object, but they are not exposed this way anymore. They must be imported from
@kbn/interpreter
now.This PR also makes the
to
function a browser-only function. Common functions were being registered in both places, but thanks to #33039, it was only ever run on the server, which there is no longer any need for.This PR makes the following expression
demodata | to type="null"
go from this:To this:
To test, you'll need to need to merge/rebase with #32600, otherwise you're going to see other error messages (specifically, "See server logs for details" and "Function to did not return anything.").