Download mods/telemetry/hooks/entries/checked-fields.ts from SaylorTwift/claude-code: direct link, hf CLI and curl.
- Browser
- Download file 1.04 kB
-
https://huggingface.co/SaylorTwift/claude-code/resolve/main/mods/telemetry/hooks/entries/checked-fields.ts
- Command line
-
hf download hf://SaylorTwift/claude-code/mods/telemetry/hooks/entries/checked-fields.ts
-
curl -L -o checked-fields.ts https://huggingface.co/SaylorTwift/claude-code/resolve/main/mods/telemetry/hooks/entries/checked-fields.ts
1.04 kB
| import { checkedProps } from './checked-props' | |
| import type { Fields } from './fields' | |
| import { fieldsOf } from './fields-of' | |
| import { isRecord } from './is-record' | |
| import { refusal } from './refusal' | |
| import { TOKEN } from './token' | |
| /** | |
| * The row's fields from one entry, or a refusal naming the first thing | |
| * wrong: the entry's shape, the event, then each property in turn. | |
| * | |
| * Nothing is sent from an entry refused here: the row reaches the ingest as | |
| * written, so this check is the gate between the argument and the wire. | |
| * | |
| * @param entry the event's name and properties as the caller passed them | |
| * @returns the entry's checked event name and properties, as `Fields` | |
| */ | |
| export function checkedFields(entry: unknown): Fields { | |
| if (!isRecord(entry)) { | |
| throw refusal('takes one entry, { event, props? }') | |
| } | |
| const { event, props = {} } = entry | |
| if (typeof event !== 'string' || !TOKEN.test(event)) { | |
| throw refusal('takes an event name, a snake_case token') | |
| } | |
| return fieldsOf(event, checkedProps(props, 'log')) | |
| } | |