summaryrefslogtreecommitdiffhomepage
path: root/packages/tui/sdk/internal/param
diff options
context:
space:
mode:
authoradamdottv <[email protected]>2025-07-03 11:49:15 -0500
committeradamdottv <[email protected]>2025-07-03 11:49:15 -0500
commit5a0910ea79b3f219c64f922fc775636b2bfdf07c (patch)
tree6f3288101eb3aa99fdc31cfaf5e07e4990cc8954 /packages/tui/sdk/internal/param
parent1dffabcfdaeefd3bc08a51b625047185bade3a4d (diff)
downloadopencode-5a0910ea79b3f219c64f922fc775636b2bfdf07c.tar.gz
opencode-5a0910ea79b3f219c64f922fc775636b2bfdf07c.zip
chore: better local dev with stainless script
Diffstat (limited to 'packages/tui/sdk/internal/param')
-rw-r--r--packages/tui/sdk/internal/param/field.go29
1 files changed, 29 insertions, 0 deletions
diff --git a/packages/tui/sdk/internal/param/field.go b/packages/tui/sdk/internal/param/field.go
new file mode 100644
index 000000000..4d0fd9c6f
--- /dev/null
+++ b/packages/tui/sdk/internal/param/field.go
@@ -0,0 +1,29 @@
+package param
+
+import (
+ "fmt"
+)
+
+type FieldLike interface{ field() }
+
+// Field is a wrapper used for all values sent to the API,
+// to distinguish zero values from null or omitted fields.
+//
+// It also allows sending arbitrary deserializable values.
+//
+// To instantiate a Field, use the helpers exported from
+// the package root: `F()`, `Null()`, `Raw()`, etc.
+type Field[T any] struct {
+ FieldLike
+ Value T
+ Null bool
+ Present bool
+ Raw any
+}
+
+func (f Field[T]) String() string {
+ if s, ok := any(f.Value).(fmt.Stringer); ok {
+ return s.String()
+ }
+ return fmt.Sprintf("%v", f.Value)
+}