| 1138 | // Should be refactored to use transform |
| 1139 | // https://github.com/arktypeio/arktype/issues/1020 |
| 1140 | getIo(ioKind: "in" | "out"): BaseNode { |
| 1141 | if (!this.alters && !(isIoFinal() && this.tfs)) return this as never |
| 1142 | |
| 1143 | const ioInner: Record<any, unknown> = {} |
| 1144 | for (const k in this.inner) { |
| 1145 | const v = this.inner[k] |
| 1146 | const keySchemaImplementation = this.impl.keys[k] |
| 1147 | |
| 1148 | if (keySchemaImplementation.reduceIo) |
| 1149 | keySchemaImplementation.reduceIo(ioKind, ioInner, v, this) |
| 1150 | else if (keySchemaImplementation.child) { |
| 1151 | const childValue = v as listable<BaseNode> |
| 1152 | |
| 1153 | ioInner[k] = |
| 1154 | isArray(childValue) ? |
| 1155 | childValue.map(child => ioOf(child, ioKind)) |
| 1156 | : ioOf(childValue, ioKind) |
| 1157 | } else ioInner[k] = v |
| 1158 | } |
| 1159 | |
| 1160 | // an open alias stands for its input and output alike, so the union reduces once final |
| 1161 | return this.$.node(this.kind, ioInner as never, { |
| 1162 | reduced: this.is("union") && this.hasAlias && !isIoFinal() |
| 1163 | }) |
| 1164 | } |
| 1165 | |
| 1166 | get innerJson(): JsonStructure { |
| 1167 | return (this.c.innerJson ??= possiblyCollapse( |