-
Notifications
You must be signed in to change notification settings - Fork 3
Proof of concept: cel-box web components #225
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
base: main
Are you sure you want to change the base?
Conversation
d6b88a9 to
5efbde1
Compare
packages/cel-box/src/split.ts
Outdated
| function toJsonCompatibleValue( | ||
| value: CEL.CelValue, | ||
| ): ReturnType<(typeof JSON)["parse"]> { | ||
| if (CEL.isCelMap(value)) { | ||
| return Object.fromEntries( | ||
| [...value.entries()].map( | ||
| ([k, v]): [string, ReturnType<(typeof JSON)["parse"]>] => [ | ||
| k.toString(), | ||
| toJsonCompatibleValue(v), | ||
| ], | ||
| ), | ||
| ); | ||
| } | ||
|
|
||
| if (CEL.isCelList(value)) { | ||
| return [...value].map( | ||
| (v): ReturnType<(typeof JSON)["parse"]> => toJsonCompatibleValue(v), | ||
| ); | ||
| } | ||
|
|
||
| return value; |
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.
I think we also need to handle CelUint, bigint, Uint8Array, maybe also CelType and ReflectMessage: https://github.com/bufbuild/cel-es/tree/main/packages/cel#types
This could be a replacer: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#the_replacer_parameter
YAML stringify supports it too.
Or it could be a function in @bufbuild/cel - but then we need to be very certain about it.
Or we could just have a comment here to clarify that this function doesn't handle all possible CEL values.
69ed6ac to
46c7047
Compare
f38ff20 to
6aa69cf
Compare
No description provided.