-
Notifications
You must be signed in to change notification settings - Fork 8
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
feat: support external types with type widening #2010
Conversation
78a12d8
to
5e9b481
Compare
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.
Nice @worstell!
Does this need any integration tests or are the unit tests covering what we need?
type MetadataTypeMap struct { | ||
Pos Position `parser:"" protobuf:"1,optional"` | ||
|
||
Runtime string `parser:"'+' 'typemap' @('go' | 'kotlin')" protobuf:"2"` |
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.
We might do this in other places, but I wonder if it will be tough to know where we need to add new languages to FTL. Like maybe we need to have rust
in here too ? :)
typealias NonFtlType Any | ||
+typemap go "github.com/foo/bar.Type" | ||
+typemap kotlin "com.foo.bar.Type" |
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.
Nice!
// and the package is "baz". | ||
// | ||
// in this case, import has an alias with the real package name: `import baz "github.com/foo/bar"` | ||
im = fmt.Sprintf("%s %s", pkg, im) |
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.
This stuff is pretty hairy! ^
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 know 😬 lemme revisit or at least maybe clarify it with some more variable names
type ExtractedDecl struct { | ||
Decl schema.Decl |
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.
Is this type still useful now that it's just Decl
?
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.
yeah, it needs to be wrapped in a "fact"
@@ -193,7 +193,7 @@ func nodeToJSSchema(node Node, refs map[RefKey]*Ref) *jsonschema.Schema { | |||
*MetadataAlias, IngressPathComponent, *IngressPathLiteral, *IngressPathParameter, *Module, | |||
*Schema, Type, *Database, *Verb, *EnumVariant, *MetadataCronJob, Value, | |||
*StringValue, *IntValue, *TypeValue, *Config, *Secret, Symbol, Named, | |||
*FSM, *FSMTransition, *MetadataRetry, *Topic, *Subscription, *MetadataSubscriber: | |||
*FSM, *FSMTransition, *MetadataRetry, *Topic, *Subscription, *MetadataSubscriber, *MetadataTypeMap: |
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.
What should this do for jsonSchema
? Would we have all the type info we need to support widen types in jsonSchema?
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.
it will show up like an Any in jsonschema, which is the best we can do i think
there's one integration test! it deploys a verb that uses external types + calls it i'll actually add another one that uses external types on an ingress request as well |
13119a2
to
b03f194
Compare
b03f194
to
b073fb1
Compare
fixes #1296
external types can be declared using type aliases. they are widened to Any in the FTL schema, with metadata specifying the external type they will be serialized to/from (standard JSON serialization is used for external types)
=>