import { DescMessage, Registry, MessageShape, DescFile, DescField } from '@bufbuild/protobuf'; /** * Lexical tokens and source positions for PXF (Proto eXpressive Format). * Mirrors `protowire/encoding/pxf/token.go`. */ declare const enum TokenKind { EOF = 0, ILLEGAL = 1, NEWLINE = 2, COMMENT = 3, IDENT = 4, STRING = 5, INT = 6, FLOAT = 7, BOOL = 8, NULL = 9, BYTES = 10, TIMESTAMP = 11, DURATION = 12, LBRACE = 13, RBRACE = 14, LBRACKET = 15, RBRACKET = 16, LPAREN = 17, RPAREN = 18, EQUALS = 19, COLON = 20, COMMA = 21, AT_TYPE = 22, /** Generic `@` where ident is none of the spec-reserved * directive names. Token.value holds the bare name (no leading `@`); * the parser uses it as the directive's name. */ AT_DIRECTIVE = 23, /** `@dataset` — row-oriented bulk-data directive (draft §3.4.4). */ AT_DATASET = 24, /** `@proto` — embedded protobuf schema directive (draft §3.4.5). */ AT_PROTO = 25 } declare function tokenKindName(k: TokenKind): string; interface Position { readonly line: number; readonly column: number; /** Byte offset into the lexer's input. Used by directive body * extraction to slice the raw bytes between `{` and `}`; line/column * remain the primary user-facing identifier. Zero is the start of * input. */ readonly offset: number; } declare function positionString(p: Position): string; interface Token { readonly kind: TokenKind; readonly value: string; readonly pos: Position; } /** * Position-aware errors for PXF parse / decode. * Mirrors `protowire/encoding/pxf/errors.go`. */ declare class PxfError extends Error { readonly pos: Position; constructor(pos: Position, msg: string); } /** * Tokenizer for PXF (Proto eXpressive Format). * Mirrors `protowire/encoding/pxf/lexer.go`. * * Recognizes: * - Comments: `# ...`, `// ...`, `/* ... *\/` * - Strings: `"..."` (with `\"`, `\\`, `\n`, `\t`, `\r` escapes) and * `"""..."""` triple-quoted with closing-line indent dedent * - Bytes: `b""` (standard or raw, validated at lex time) * - Integers, floats (with optional sign and exponent) * - RFC 3339 timestamps: 4 digits + `-` triggers timestamp lex; validated * - Go-style durations: digits + a unit letter (h/m/s/ns/us/ms); validated * - Identifiers (with `.` allowed for dotted package names), `true` / * `false` / `null` keywords, `@type` directive * - Punctuation: `{ } [ ] = : ,` */ interface LexerState { readonly pos: number; readonly line: number; readonly col: number; } declare class Lexer { private readonly input; private pos; private line; private col; constructor(input: string); /** Snapshot the lexer's position. Used by the parser to peek the * next token without consuming it. */ snapshot(): LexerState; restore(s: LexerState): void; /** Returns the next token. Returns an EOF token at end-of-input forever. */ next(): Token; /** Iterate until EOF, useful for tests and consumers that want everything up front. */ tokens(): Generator; private peek; private peekAt; private advance; private currentPos; /** Raw input view — used by parseDirective to slice the body bytes * between `{` and `}` once the matching brace has been located. */ inputView(): string; /** * Reposition the lexer to `target` (a char index into the input), * recomputing line/col by scanning forward from the current position. * Used by parseProtoDirective to skip past an `@proto` brace-body * whose interior is protobuf source rather than PXF. */ repositionTo(target: number): void; private skipSpaces; private lexLineComment; private lexBlockComment; private lexString; /** Reads exactly 2 hex digits from the current position. */ private readHexByte; /** Reads exactly N hex digits from the current position. */ private readHexRune; /** Reads two more octal digits after the leading one already consumed * (as part of `\nnn` — exactly 3 octal digits total). The caller has * restricted `first` to 0–3 so the value can't exceed 0xFF. */ private readOctRest; private lexTripleString; private lexBytes; private lexDirective; private lexNumber; private lexFloat; private lexTimestamp; private lexDuration; private lexIdent; } /** * PXF AST types. Mirrors `protowire/encoding/pxf/ast.go` but uses TS * discriminated unions instead of Go's interface-with-marker pattern. * * Timestamps and durations are kept as their raw lexeme on the AST. A * downstream consumer (decoder, formatter) parses them when needed — * `Date.parse(raw)` for timestamps, or a custom Go-style parser for * durations (TS has no native duration type). */ interface Comment { readonly pos: Position; /** Raw text including the comment prefix (`#`, `//`, or block-comment delimiters). */ readonly text: string; } interface Document { /** Empty when there is no `@type` directive. */ readonly typeUrl: string; /** `@ *(prefix) [{ ... }]` blocks in source order; excludes the * spec-defined directives (`@type`, `@dataset`, `@proto`, `@entry`), * which have their own accessors. */ readonly directives: Directive[]; /** `@dataset TYPE ( cols ) row*` directives in source order. Per draft * §3.4.4 a document with any `@dataset` MUST NOT also have `@type` or * top-level field entries — the parser enforces this. */ readonly datasets: DatasetDirective[]; /** `@proto ` directives in source order (draft §3.4.5). */ readonly protos: ProtoDirective[]; /** Byte offset where the schema-typed body begins (after all leading * directives). Zero when there are no directives, so chameleon hashes * from byte 0. */ readonly bodyOffset: number; readonly entries: Entry[]; /** Comments before the first entry (or before `@type`). */ readonly leadingComments: Comment[]; } /** * A top-of-document `@ *() [{ ... }]` entry. Side-channel * metadata that sits alongside the schema-typed body — e.g. chameleon's * `@header chameleon.v1.LayerHeader { id = "x" }`. The grammar is open- * ended: any name except `type` / `table` is parsed as a generic * `Directive`. Prefix identifiers are positional and per-directive: * * - One prefix (v0.72.0 conventional shape) — the identifier names the * inner block's message type, dotted. Used by `@header` and similar. * - `@entry` (draft §3.4.3) — zero, one, or two prefix identifiers * (label, type); a single prefix is disambiguated by the presence of * a `.` (dotted ⇒ type; bare ⇒ label). * * `body` holds the raw bytes between `{` and `}` (both exclusive), * suitable for handing back to a follow-up `unmarshal` against the * consumer's chosen message. `body` is empty and `hasBody` is false when * the directive has no inline block. */ interface Directive { readonly pos: Position; /** e.g. "header"; never "type" / "table". */ readonly name: string; /** Identifiers between `@` and the optional `{ ... }`, in source order. */ readonly prefixes: string[]; /** Back-compat for v0.72.0-era consumers: when exactly one prefix * identifier was supplied, `type` holds it. For zero / two-plus * prefixes, `type` is empty and callers MUST read `prefixes` directly. */ readonly type: string; /** Raw inner bytes of the block (UTF-8 substring of the lexer input); * empty when `hasBody` is false. */ readonly body: string; readonly hasBody: boolean; readonly leadingComments: Comment[]; } /** * `@dataset ( col1, col2, ... ) row*` directive at document root * (draft §3.4.4). Carries many instances of one message type in a single * document — the protowire-native CSV replacement. * * Cells are scalar-shaped in v1 (no list, no block). A nullish cell * (see `DatasetRow.cells`) denotes an absent field; a `NullVal` cell * denotes a present-but-null field; any other cell denotes a present * field with that value. * * A document with any `DatasetDirective` MUST NOT have a `@type` directive * or any top-level field entries: the `@dataset` header IS the document's * type declaration. The parser enforces this. * * `type` MAY be empty when an anonymous `@proto` directive (draft §3.4.5) * precedes the dataset in document order; the anonymous schema is consumed * as the row message type. */ interface DatasetDirective { readonly pos: Position; /** Row message type, e.g. "trades.v1.Trade"; empty if bound to a * preceding anonymous `@proto`. */ readonly type: string; /** Top-level field names on `type`; length >= 1. */ readonly columns: string[]; readonly rows: DatasetRow[]; readonly leadingComments: Comment[]; } /** * One parenthesized cell tuple in a `@dataset` directive. `cells` has the * same length as the containing `DatasetDirective.columns`. A `null` cell * denotes an absent field (the empty cell between two commas); a * `NullVal` denotes a present-but-null field; any other Value denotes a * present field with that value. */ interface DatasetRow { readonly pos: Position; readonly cells: (Value | null)[]; } /** Shape of a `ProtoDirective` body (draft §3.4.5). */ type ProtoShape = "anonymous" | "named" | "source" | "descriptor"; /** * `@proto ` directive at document root (draft §3.4.5). Carries an * embedded protobuf schema, making the PXF document self-describing. * * Four body shapes distinguished lexically: * * - `anonymous`: `@proto { }` — defines an unnamed * message used by the next typed directive in document order. * - `named`: `@proto { }` — sugar * for a single named message; `typeName` carries the dotted name. * - `source`: `@proto """"""` — complete `.proto` * source file; `body` is the UTF-8 string contents. * - `descriptor`: `@proto b""` — base64- * decoded `google.protobuf.FileDescriptorSet` bytes. * * `body` is raw bytes per shape. For the brace-bounded shapes, this * is the protobuf message-body source between `{` and `}` (exclusive). */ interface ProtoDirective { readonly pos: Position; readonly shape: ProtoShape; /** Non-empty only when `shape === "named"`. */ readonly typeName: string; readonly body: Uint8Array; readonly leadingComments: Comment[]; } type Entry = Assignment | MapEntry | Block; /** `key = value` — a field assignment in a message context. */ interface Assignment { readonly kind: "assignment"; readonly pos: Position; readonly key: string; readonly value: Value; readonly leadingComments: Comment[]; /** Inline comment after the value on the same source line, if any. */ readonly trailingComment: string; } /** `key: value` — a key-value pair in a map context. */ interface MapEntry { readonly kind: "mapEntry"; readonly pos: Position; readonly key: string; readonly value: Value; readonly leadingComments: Comment[]; readonly trailingComment: string; } /** `name { entries }` — a nested message. */ interface Block { readonly kind: "block"; readonly pos: Position; readonly name: string; readonly entries: Entry[]; readonly leadingComments: Comment[]; } type Value = StringVal | IntVal | FloatVal | BoolVal | BytesVal | NullVal | IdentVal | TimestampVal | DurationVal | ListVal | BlockVal; interface StringVal { readonly kind: "string"; readonly pos: Position; readonly value: string; } /** Integer literal, preserved as raw text — schema-bound decoder picks * the right numeric type (int32, int64 → bigint, etc). */ interface IntVal { readonly kind: "int"; readonly pos: Position; readonly raw: string; } /** Floating-point literal, raw text. */ interface FloatVal { readonly kind: "float"; readonly pos: Position; readonly raw: string; } interface BoolVal { readonly kind: "bool"; readonly pos: Position; readonly value: boolean; } /** Decoded base64 bytes (the wire-side representation). */ interface BytesVal { readonly kind: "bytes"; readonly pos: Position; readonly value: Uint8Array; } interface NullVal { readonly kind: "null"; readonly pos: Position; } /** Unquoted identifier used as a value — typically an enum name. */ interface IdentVal { readonly kind: "ident"; readonly pos: Position; readonly name: string; } /** RFC 3339 timestamp literal, raw text. */ interface TimestampVal { readonly kind: "timestamp"; readonly pos: Position; readonly raw: string; } /** Go-style duration literal, raw text. */ interface DurationVal { readonly kind: "duration"; readonly pos: Position; readonly raw: string; } /** `[ … ]` — a list of values. */ interface ListVal { readonly kind: "list"; readonly pos: Position; readonly elements: Value[]; } /** Anonymous `{ … }` block — used for map entries and inline messages in lists. */ interface BlockVal { readonly kind: "blockVal"; readonly pos: Position; readonly entries: Entry[]; } /** * Recursive-descent parser for PXF. * Mirrors `protowire/encoding/pxf/parser.go`. * * Newlines and comments are absorbed at the lexer-token boundary. Comments * accumulate in a pending buffer and are attached as `leadingComments` to * the next entry. Trailing inline comments are not yet captured (Go's parser * also leaves `TrailingComment` empty on the parser hot path; the * formatter populates it). */ declare function parse(input: string): Document; /** * Format an AST Document back to PXF source text, preserving comments. * Mirrors `protowire/encoding/pxf/format.go`. * * This is the "round-trip via AST" path used by the `protowire fmt` * subcommand. It is lossy in two ways the Go formatter is also lossy: * - List elements are always comma-separated on output (commas are * optional in input). * - The string quoter only re-emits the escape sequences the lexer * accepts (`\"`, `\\`, `\n`, `\t`, `\r`); all other characters, * including non-printable control chars, pass through verbatim. * Use a `bytes` field for arbitrary binary data. */ interface FormatOptions { /** Indent unit; default is two spaces. */ readonly indent?: string; } declare function format(doc: Document, options?: FormatOptions): string; /** * Field-level presence metadata from PXF decoding. * Mirrors `protowire/encoding/pxf/result.go`. * * Fields are identified by dotted paths (e.g., "name", "nested.value"). * * Result also surfaces the document-root directives the decoder saw: * - `directives()` — generic `@ *(prefix) [{ ... }]` blocks, * in source order, excluding the spec-defined directives * (`@type`, `@dataset`, `@proto`, `@entry`). * - `datasets()` — `@dataset ( cols ) row*` directives, in * source order. A document with any `@dataset` has no body entries, * so the rows are the document's payload — consumers walk * `DatasetDirective.rows` and bind each row's cells to a fresh * instance of `DatasetDirective.type` via their own schema. * - `protos()` — `@proto ` directives (draft §3.4.5), in * source order. Each carries one of four body shapes (anonymous, * named, source, descriptor). */ declare class Result { private readonly nullFields; private readonly presentFields; private readonly directivesList; private readonly datasetsList; private readonly protosList; markNull(path: string): void; markPresent(path: string): void; /** True if the field at `path` was explicitly set to null. */ isNull(path: string): boolean; /** True if the field at `path` was not mentioned in the input. */ isAbsent(path: string): boolean; /** True if the field at `path` was set to a concrete (non-null) value. */ isSet(path: string): boolean; /** Paths of all fields explicitly set to null. */ nullPaths(): string[]; directives(): readonly Directive[]; datasets(): readonly DatasetDirective[]; protos(): readonly ProtoDirective[]; addDirective(d: Directive): void; addDataset(t: DatasetDirective): void; addProto(p: ProtoDirective): void; } /** * Schema-bound PXF decoder. * Mirrors the AST-based path of `protowire/encoding/pxf/decode_fast.go`, * without the fused single-pass perf optimizations. * * Slice D4 scope: D3 plus `unmarshalFull` returning Result, `pxf.required` / * `pxf.default` annotations, and the `_null` FieldMask null-survival channel. */ /** * Resolves google.protobuf.Any type URLs to message descriptors. Mirrors the * Go interface of the same name. Pass a `Registry` directly (the URL prefix * is stripped automatically) or implement this interface for custom lookup * (e.g. lazy loading, alternative URL conventions). */ interface TypeResolver { findMessageByURL(url: string): DescMessage | undefined; } /** * Wrap a protobuf-es `Registry` as a `TypeResolver`. Strips the URL prefix * (everything up to and including the last `/`) before lookup, matching the * `type.googleapis.com/` convention used by `anyPack`. */ declare function registryAsTypeResolver(registry: Registry): TypeResolver; interface UnmarshalOptions { /** Silently skip fields not declared in the schema instead of erroring. */ discardUnknown?: boolean; /** * Resolves type URLs for `google.protobuf.Any` fields. When set, Any * fields use sugar syntax (`@type = "..."` plus inline fields). When * absent, Any fields decode as regular messages with `type_url` and * `value` fields. */ typeResolver?: TypeResolver; /** * Skip the per-call schema reserved-name check (draft §3.13). * Callers that have already validated their descriptors (typically * via `validateDescriptor` in a one-time codegen or registry-load * pass) can set this to bypass the per-call recheck. */ skipValidate?: boolean; } declare function unmarshal(data: string, schema: Desc, options?: UnmarshalOptions): MessageShape; /** * Decode PXF data into a fresh message and return field-presence metadata. * * Unlike `unmarshal`, this: * - tracks which fields were explicitly set, set to null, or absent; * - validates `(pxf.required) = true` fields and errors on absence; * - applies `(pxf.default) = "..."` defaults to absent (non-null) fields; * - mirrors null state into a top-level `_null` FieldMask field if present. */ declare function unmarshalFull(data: string, schema: Desc, options?: UnmarshalOptions): { message: MessageShape; result: Result; }; /** * Schema-bound PXF text encoder. * Mirrors `protowire/encoding/pxf/encode.go`. * * Handles scalars, enums, messages (block + WKT shortcuts), repeated lists, * maps (key-sorted), google.protobuf.Any sugar via a TypeResolver, and the * `_null` FieldMask channel for emitting `null` literals. */ interface MarshalOptions { /** Indentation string per level. Defaults to two spaces. */ indent?: string; /** Emit fields whose value is the proto3 default (zero) instead of skipping them. */ emitDefaults?: boolean; /** When set, prefix the output with `@type ` and a blank line. */ typeURL?: string; /** Required to encode `google.protobuf.Any` with sugar syntax. */ typeResolver?: TypeResolver; /** * Alternative null source for messages without a top-level `_null` * FieldMask. Paths in this Result that are marked null are emitted as * `null` literals. */ nullFields?: Result; /** * Strip trailing zero-valued h/m/s units from emitted Go-style * Duration literals (e.g. `720h0m0s` → `720h`, `1h30m0s` → `1h30m`). * * Default `false` preserves byte-equivalence with the canonical * Go reference's `time.Duration.String()` output. Set to `true` * when round-trip readability of the source file matters more * than wire-compatibility with the Go reference — typical for * config files maintained by humans (e.g. an `*.pxf` config a * maintainer edits via a UI, where seeing `720h` on disk is more * idiomatic than `720h0m0s`). * * Only emit-side: the parser accepts both forms regardless. * Sub-second durations (ns / µs / ms) already use a single unit * and are unaffected. Internal zero units between non-zero ones * (e.g. `1h0m30s` where the middle `0m` sits between non-zero h * and s) are preserved — the Go format requires them. */ compactDuration?: boolean; } declare function marshal(message: MessageShape, schema: Desc, options?: MarshalOptions): string; /** DurationParts mirrors the seconds/nanos split that * `google.protobuf.Duration` carries on the wire. Both fields share * the overall sign — negative durations have negative seconds AND * negative nanos (or zero on whichever doesn't contribute). */ interface DurationParts { seconds: bigint; nanos: number; } /** Options for `formatGoDuration`. */ interface FormatGoDurationOptions { /** * Strip trailing zero-valued h/m/s units from the emitted literal * (e.g. `720h0m0s` → `720h`, `1h30m0s` → `1h30m`). Internal zero * units between non-zero ones (`1h0m30s`) and sub-second forms * (`ns`, `µs`, `ms`) are preserved unchanged. The * canonical zero `0s` always passes through. * * Default `false` preserves byte-equivalence with Go's * `time.Duration.String()` (the property the v1.0 line guarantees * for `marshal` output). */ compact?: boolean; } /** * Parse a Go-style duration literal (e.g. `1h30m`, `-2.5s`, `100ms`) * into proto Duration `{seconds, nanos}`. Both parts share the * overall sign. * * Throws on syntax errors. Accepts a leading `+` or `-`; rejects an * empty string. The single-character literal `"0"` is treated as zero * even though it lacks a unit suffix (mirrors Go's `time.ParseDuration` * for the same edge case). * * Suitable for direct use as the init shape for `@bufbuild/protobuf`'s * `create(DurationSchema, ...)` — protobuf-es accepts a plain * `{seconds, nanos}` object there. */ declare function parseGoDuration(s: string): DurationParts; /** * Format a proto Duration `{seconds, nanos}` as a Go-style duration * string. Mirrors `time.Duration.String()`: leading-zero h/m units * are omitted, sub-second durations use the smallest unit * (ns / µs / ms) that gives a non-zero leading digit, and `0s` is the * canonical zero. * * Pass `{ compact: true }` to strip trailing zero h/m/s units * (`720h0m0s` → `720h`); the default is full Go-canonical output for * byte-equivalence with the Go reference. */ declare function formatGoDuration(d: DurationParts, options?: FormatGoDurationOptions): string; /** * PXF schema-level conformance check per draft §3.13. A protobuf schema * bound for PXF use MUST NOT declare a message field, oneof, or enum * value whose name is case-sensitively equal to a PXF value keyword * (`null` / `true` / `false`) — such a name lexes as the keyword, so * the declared element is unreachable from PXF surface syntax. * * Enforcement runs at descriptor-bind time inside `unmarshal` / * `unmarshalFull`. Callers that have already validated their * descriptors (typically via `validateDescriptor` in a one-time * codegen or registry-load pass) may set * `UnmarshalOptions.skipValidate` to bypass the per-call recheck. * * Mirrors `protowire/encoding/pxf/schema.go`. */ /** Which kind of schema element collides with a reserved PXF value keyword. */ type ViolationKind = "field" | "oneof" | "enumValue"; /** A schema element whose name collides with a reserved PXF keyword. */ interface Violation { /** .proto file path the offending element is declared in. */ readonly file: string; /** Fully-qualified protobuf name (e.g. "trades.v1.Side.null"). */ readonly element: string; /** Bare reserved identifier ("null" / "true" / "false"). */ readonly name: string; readonly kind: ViolationKind; } /** Human-readable one-line description of `v`. */ declare function violationString(v: Violation): string; /** * Walks the file containing `desc` and returns every reserved-name * collision among messages, oneofs, and enum values reachable from * that file. The returned array is sorted by element fully-qualified * name for stable output. An empty array means the schema is * conformant. * * The check is case-sensitive: identifiers such as "NULL" or "True" * lex as ordinary identifiers and are accepted. */ declare function validateDescriptor(desc: DescMessage | null | undefined): Violation[]; /** * Walks `fd` and returns every reserved-name collision in the file. * See {@link validateDescriptor} for the rule and semantics. */ declare function validateFile(fd: DescFile | null | undefined): Violation[]; /** * Streaming consumption for the `@dataset` directive (draft §3.4.4). * * `unmarshalFull` materializes every row of an `@dataset` directive into * `Result.datasets()`. That works for small datasets and breaks for the * CSV-replacement workload `@dataset` was designed for. `DatasetReader` * pulls one row at a time from the input string; per-row arity and the * v1 cell-grammar rule are enforced at consume time (not deferred to * end-of-input), and rows are yielded in source order — both * invariants the spec requires of streaming consumers. * * Convenience: `scan(schema)` reads the next row and binds its cells * to a fresh message of `schema`; `bindRow(schema, columns, row)` is * exported for callers iterating `Result.datasets()[i].rows` from the * materializing path. * * Mirrors the cpp port at `protowire-cpp/src/pxf/dataset_reader.cc`. */ /** * Default cap on the @dataset header (leading directives plus the * `@dataset TYPE ( cols )` declaration). Real headers are tiny — a few * hundred bytes at most. The cap exists to fail-fast on misuse: a * DatasetReader pointed at a multi-megabyte non-`@dataset` input * shouldn't run through the whole buffer looking for one. */ declare const DEFAULT_HEADER_MAX_BYTES: number; /** * Streaming row reader for a single `@dataset` directive. * * A DatasetReader is positioned at the first row after `fromString()` * returns. Iterate via standard `for ... of` (the reader implements * the iterator protocol) or call `next()` until it returns `null`. * * For documents containing multiple `@dataset` directives, call * `fromString()` again on the result of `tail()`. */ declare class DatasetReader implements IterableIterator { readonly type: string; readonly columns: readonly string[]; readonly directives: readonly Directive[]; /** True once the row sequence has been exhausted. */ done: boolean; private readonly input; /** Byte offset of the next position to scan in `input`. */ private offset; private constructor(); /** * Consume the leading directives and the `@dataset TYPE ( cols )` * header. Returns a reader positioned at the first row. * * Throws if the input contains no `@dataset` directive before EOF, on * a header parse error, or if the header byte budget is exceeded. */ static fromString(input: string): DatasetReader; /** * Read the next row. Returns `null` when the table's row sequence * is exhausted; once null is returned, subsequent calls return the * same null (`done` is set). */ next(): IteratorResult; [Symbol.iterator](): IterableIterator; /** * Read the next row and bind its cells to a fresh message of * `schema`. Returns the bound message, or `null` if the row * sequence is exhausted (in which case `done` is set). */ scan(schema: Desc, options?: { skipValidate?: boolean; }): MessageShape | null; /** * Returns the unconsumed bytes of the input, so callers can chain a * second `DatasetReader` for documents with multiple `@dataset` * directives: * * const tr1 = DatasetReader.fromString(src); * for (const row of tr1) { ... } * const tr2 = DatasetReader.fromString(tr1.tail()); * * Should only be called after iteration has exhausted (i.e. * `done === true`). Calling earlier returns bytes the current * reader still intends to consume. */ tail(): string; } /** * Bind a row's cells to fields of a fresh `schema` message by column * name. `columns` and `row.cells` MUST have the same length. * * Cell-state semantics: * - `null` cell — field absent. (pxf.default) applies if declared; * (pxf.required) errors if neither default nor value is present. * - `NullVal` cell — field cleared (draft §3.9). * - any other — field set to the cell's value. * * Strategy: render the row as a synthetic PXF body (` = ` * per non-null cell) and run it through `unmarshal`. This mirrors * `protowire-cpp`'s BindRow and reuses every branch of the existing * decoder — WKT timestamps / durations, wrapper-type nullability, * enum-by-name resolution, `pxf.required` / `pxf.default`, oneof — * instead of growing a parallel Value→FieldDescriptor switch. * * `skipValidate` defaults to `true`: descriptors were validated once * when the caller constructed the schema/registry, and re-running * the reserved-name check per row is wasteful in tight loops. */ declare function bindRow(schema: Desc, columns: readonly string[], row: DatasetRow, options?: { skipValidate?: boolean; }): MessageShape; /** * Tiny adapter helpers over `@bufbuild/protobuf` descriptors. * * protobuf-es v2 already exposes a clean discriminated-union DescField * (fieldKind: "scalar" | "list" | "message" | "enum" | "map") and ScalarType * enum, so we only need a few helpers. The most important one is lookup by * proto source name: DescMessage.field is keyed by JS-idiomatic localName, * but PXF text uses the proto source name (e.g. "string_field" not * "stringField"). */ /** * Find a field by its proto source name (e.g. "string_field"). * Returns undefined if no such field exists. */ declare function findFieldByProtoName(desc: DescMessage, name: string): DescField | undefined; declare function isWrapperType(desc: DescMessage): boolean; declare function isTimestamp(desc: DescMessage): boolean; declare function isDuration(desc: DescMessage): boolean; declare function isAny(desc: DescMessage): boolean; declare function isFieldMask(desc: DescMessage): boolean; type index_Assignment = Assignment; type index_Block = Block; type index_BlockVal = BlockVal; type index_BoolVal = BoolVal; type index_BytesVal = BytesVal; type index_Comment = Comment; declare const index_DEFAULT_HEADER_MAX_BYTES: typeof DEFAULT_HEADER_MAX_BYTES; type index_DatasetDirective = DatasetDirective; type index_DatasetReader = DatasetReader; declare const index_DatasetReader: typeof DatasetReader; type index_DatasetRow = DatasetRow; type index_Directive = Directive; type index_Document = Document; type index_DurationParts = DurationParts; type index_DurationVal = DurationVal; type index_Entry = Entry; type index_FloatVal = FloatVal; type index_FormatGoDurationOptions = FormatGoDurationOptions; type index_FormatOptions = FormatOptions; type index_IdentVal = IdentVal; type index_IntVal = IntVal; type index_Lexer = Lexer; declare const index_Lexer: typeof Lexer; type index_ListVal = ListVal; type index_MapEntry = MapEntry; type index_MarshalOptions = MarshalOptions; type index_NullVal = NullVal; type index_Position = Position; type index_PxfError = PxfError; declare const index_PxfError: typeof PxfError; type index_Result = Result; declare const index_Result: typeof Result; type index_StringVal = StringVal; type index_TimestampVal = TimestampVal; type index_Token = Token; type index_TokenKind = TokenKind; declare const index_TokenKind: typeof TokenKind; type index_TypeResolver = TypeResolver; type index_UnmarshalOptions = UnmarshalOptions; type index_Value = Value; type index_Violation = Violation; type index_ViolationKind = ViolationKind; declare const index_bindRow: typeof bindRow; declare const index_findFieldByProtoName: typeof findFieldByProtoName; declare const index_format: typeof format; declare const index_formatGoDuration: typeof formatGoDuration; declare const index_isAny: typeof isAny; declare const index_isDuration: typeof isDuration; declare const index_isFieldMask: typeof isFieldMask; declare const index_isTimestamp: typeof isTimestamp; declare const index_isWrapperType: typeof isWrapperType; declare const index_marshal: typeof marshal; declare const index_parse: typeof parse; declare const index_parseGoDuration: typeof parseGoDuration; declare const index_positionString: typeof positionString; declare const index_registryAsTypeResolver: typeof registryAsTypeResolver; declare const index_tokenKindName: typeof tokenKindName; declare const index_unmarshal: typeof unmarshal; declare const index_unmarshalFull: typeof unmarshalFull; declare const index_validateDescriptor: typeof validateDescriptor; declare const index_validateFile: typeof validateFile; declare const index_violationString: typeof violationString; declare namespace index { export { type index_Assignment as Assignment, type index_Block as Block, type index_BlockVal as BlockVal, type index_BoolVal as BoolVal, type index_BytesVal as BytesVal, type index_Comment as Comment, index_DEFAULT_HEADER_MAX_BYTES as DEFAULT_HEADER_MAX_BYTES, type index_DatasetDirective as DatasetDirective, index_DatasetReader as DatasetReader, type index_DatasetRow as DatasetRow, type index_Directive as Directive, type index_Document as Document, type index_DurationParts as DurationParts, type index_DurationVal as DurationVal, type index_Entry as Entry, type index_FloatVal as FloatVal, type index_FormatGoDurationOptions as FormatGoDurationOptions, type index_FormatOptions as FormatOptions, type index_IdentVal as IdentVal, type index_IntVal as IntVal, index_Lexer as Lexer, type index_ListVal as ListVal, type index_MapEntry as MapEntry, type index_MarshalOptions as MarshalOptions, type index_NullVal as NullVal, type index_Position as Position, index_PxfError as PxfError, index_Result as Result, type index_StringVal as StringVal, type index_TimestampVal as TimestampVal, type index_Token as Token, index_TokenKind as TokenKind, type index_TypeResolver as TypeResolver, type index_UnmarshalOptions as UnmarshalOptions, type index_Value as Value, type index_Violation as Violation, type index_ViolationKind as ViolationKind, index_bindRow as bindRow, index_findFieldByProtoName as findFieldByProtoName, index_format as format, index_formatGoDuration as formatGoDuration, index_isAny as isAny, index_isDuration as isDuration, index_isFieldMask as isFieldMask, index_isTimestamp as isTimestamp, index_isWrapperType as isWrapperType, index_marshal as marshal, index_parse as parse, index_parseGoDuration as parseGoDuration, index_positionString as positionString, index_registryAsTypeResolver as registryAsTypeResolver, index_tokenKindName as tokenKindName, index_unmarshal as unmarshal, index_unmarshalFull as unmarshalFull, index_validateDescriptor as validateDescriptor, index_validateFile as validateFile, index_violationString as violationString }; } export { unmarshal as $, type Assignment as A, type Block as B, type Comment as C, DEFAULT_HEADER_MAX_BYTES as D, type Entry as E, type FloatVal as F, isAny as G, isDuration as H, type IdentVal as I, isFieldMask as J, isTimestamp as K, Lexer as L, type MapEntry as M, type NullVal as N, isWrapperType as O, type Position as P, marshal as Q, Result as R, type StringVal as S, type TimestampVal as T, type UnmarshalOptions as U, type Value as V, parse as W, parseGoDuration as X, positionString as Y, registryAsTypeResolver as Z, tokenKindName as _, type BlockVal as a, unmarshalFull as a0, validateDescriptor as a1, validateFile as a2, violationString as a3, type BoolVal as b, type BytesVal as c, type DatasetDirective as d, DatasetReader as e, type DatasetRow as f, type Directive as g, type Document as h, index as i, type DurationParts as j, type DurationVal as k, type FormatGoDurationOptions as l, type FormatOptions as m, type IntVal as n, type ListVal as o, type MarshalOptions as p, PxfError as q, type Token as r, TokenKind as s, type TypeResolver as t, type Violation as u, type ViolationKind as v, bindRow as w, findFieldByProtoName as x, format as y, formatGoDuration as z };