Skip to content
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

Visualize a type value as a string #1732

Merged
merged 2 commits into from
Jul 7, 2021
Merged

Visualize a type value as a string #1732

merged 2 commits into from
Jul 7, 2021

Conversation

jameskerr
Copy link
Member

This is a case where we are using a "type" as a "value". That means we need to visually represent a "type" in a cell in the viewer. I looked at what zq does for this and tried to copy.

{
    _path: "ssl",
    typeof: ({_path:string,ts:time,uid:bstring,id:{orig_h:ip,orig_p:port=(uint16),resp_h:ip,resp_p:port},version:bstring,cipher:bstring,curve:bstring,server_name:bstring,resumed:bool,last_alert:bstring,next_protocol:bstring,established:bool,cert_chain_fuids:[bstring],client_cert_chain_fuids:[bstring],subject:bstring,issuer:bstring,client_subject:bstring,client_issuer:bstring,validation_status:bstring,ja3:bstring,ja3s:bstring})
}

To implement this, I've added a toString() method to every zed type. I also created an abstract BasePrimitive<T> class to represent the expected interface of a primitive type, and to implement 2 methods that are the same for all primitives (toString() and serialize()).

image

fixes #1725

@jameskerr jameskerr requested a review from mason-fish July 6, 2021 22:17
Copy link
Contributor

@mason-fish mason-fish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, nice that extending instead of implementing the primitive ended up cleaning a lot of repeated code

@@ -31,6 +31,18 @@ export class TypeRecord implements ContainerTypeInterface {
return s
}

toString() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@jameskerr jameskerr merged commit 9bfabbe into main Jul 7, 2021
@jameskerr jameskerr deleted the types-to-string branch July 7, 2021 22:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Result of typeof(this) is presented as "[object Object]"
2 participants