Skip to content
This repository was archived by the owner on Jan 8, 2026. It is now read-only.

Commit bf71b7b

Browse files
committed
feat: allow inline link definitions for kinded unions
e.g. ``` type Foo union { | &Blip link | Blop string } representation kinded ``` rather than having to `type BlipLink &Blip` before using it in a kinded union.
1 parent 9bab36f commit bf71b7b

2 files changed

Lines changed: 19 additions & 2 deletions

File tree

schemas/schema-schema.ipldsch

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,15 @@ type UnionRepresentation union {
378378
##
379379
## The referenced type must of course produce the RepresentationKind it's
380380
## matched with!
381-
type UnionRepresentation_Kinded {RepresentationKind:TypeName}
381+
type UnionRepresentation_Kinded {RepresentationKind:KindedType}
382+
383+
## "KindedType" is used to allow inline link definitions within a kinded union
384+
## as a shorthand rather than requiring all links be defined as a separate type
385+
## before used within a kinded union.
386+
type KindedType union {
387+
| TypeName "string"
388+
| TypeLink "link"
389+
} representation kinded
382390

383391
## "Keyed" union representations will encode as a map, where the map has
384392
## exactly one entry, the key string of which will be used to look up the name

schemas/schema-schema.ipldsch.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,16 @@
308308
"UnionRepresentation_Kinded": {
309309
"kind": "map",
310310
"keyType": "RepresentationKind",
311-
"valueType": "TypeName"
311+
"valueType": "KindedType"
312+
},
313+
"KindedType": {
314+
"kind": "union",
315+
"representation": {
316+
"kinded": {
317+
"string": "TypeName",
318+
"link": "TypeLink"
319+
}
320+
}
312321
},
313322
"UnionRepresentation_Keyed": {
314323
"kind": "map",

0 commit comments

Comments
 (0)