a copy with meta applied to the references a selector picks
( meta: TypeMeta.MappableInput.Internal, selector: NodeSelector = "references" )
| 1554 | |
| 1555 | /** a copy with meta applied to the references a selector picks */ |
| 1556 | configureRefs( |
| 1557 | meta: TypeMeta.MappableInput.Internal, |
| 1558 | selector: NodeSelector = "references" |
| 1559 | ): this { |
| 1560 | const normalized = NodeSelector.normalize(selector) |
| 1561 | |
| 1562 | // a cast or JavaScript can pass anything, which spreading would drop |
| 1563 | if ( |
| 1564 | typeof meta !== "string" && |
| 1565 | typeof meta !== "function" && |
| 1566 | (typeof meta !== "object" || meta === null || Array.isArray(meta)) |
| 1567 | ) |
| 1568 | throwParseError(writeInvalidMetaMessage(printable(meta))) |
| 1569 | |
| 1570 | // 2.x's slot, which a cast or JavaScript still passes |
| 1571 | if (typeof meta === "object" && "problem" in meta) |
| 1572 | throwParseError(removedProblemMessage) |
| 1573 | |
| 1574 | // a JSON Schema describes the node it's configured on, not its references |
| 1575 | if ( |
| 1576 | typeof meta === "object" && |
| 1577 | meta.jsonSchema && |
| 1578 | normalized.boundary !== "self" && |
| 1579 | !normalized.kind && |
| 1580 | !normalized.where |
| 1581 | ) { |
| 1582 | const { jsonSchema, ...rest } = meta |
| 1583 | return this.configureRefs(rest, selector).configureRefs( |
| 1584 | { jsonSchema }, |
| 1585 | "self" |
| 1586 | ) |
| 1587 | } |
| 1588 | |
| 1589 | const mapper = ( |
| 1590 | typeof meta === "string" ? |
| 1591 | (kind, inner) => ({ |
| 1592 | ...inner, |
| 1593 | meta: withoutReplacedKeyword(inner.meta, { |
| 1594 | ...inner.meta, |
| 1595 | description: meta |
| 1596 | }) |
| 1597 | }) |
| 1598 | : typeof meta === "function" ? |
| 1599 | (kind, inner) => ({ |
| 1600 | ...inner, |
| 1601 | meta: withoutReplacedKeyword(inner.meta, meta(inner.meta)) |
| 1602 | }) |
| 1603 | : (kind, inner) => ({ |
| 1604 | ...inner, |
| 1605 | meta: withoutReplacedKeyword(inner.meta, { ...inner.meta, ...meta }) |
| 1606 | })) satisfies DeepNodeTransformation |
| 1607 | |
| 1608 | if (normalized.boundary === "self") { |
| 1609 | const configured = this.$.node( |
| 1610 | this.kind, |
| 1611 | mapper(this.kind, { ...this.inner, meta: this.meta }) as never |
| 1612 | ) |
| 1613 | return ( |
nothing calls this directly
no test coverage detected