| 31 | * @publicApi 22.0 |
| 32 | */ |
| 33 | export function metadata< |
| 34 | TValue, |
| 35 | TKey extends MetadataKey<any, any, any>, |
| 36 | TPathKind extends PathKind = PathKind.Root, |
| 37 | >( |
| 38 | path: SchemaPath<TValue, SchemaPathRules.Supported, TPathKind>, |
| 39 | key: TKey, |
| 40 | logic: NoInfer< |
| 41 | LogicFn< |
| 42 | TValue, |
| 43 | TKey extends LimitSelectionKey ? LimitKey<TValue> : MetadataSetterType<TKey>, |
| 44 | TPathKind |
| 45 | > |
| 46 | >, |
| 47 | ): TKey { |
| 48 | assertPathIsCurrent(path); |
| 49 | |
| 50 | const pathNode = FieldPathNode.unwrapFieldPath(path); |
| 51 | pathNode.builder.addMetadataRule(key, logic); |
| 52 | return key; |
| 53 | } |
| 54 | |
| 55 | /** |
| 56 | * A reducer that determines the accumulated value for a metadata key by reducing the individual |