Skip to content

refactor(lstsv): single source for the TSV column list - #72

Merged
jstet merged 1 commit into
mainfrom
refactor/65-tsv-columns
Sep 25, 2026
Merged

jstet merged 1 commit into
mainfrom
refactor/65-tsv-columns

Conversation

@jstet

@jstet jstet commented Sep 25, 2026

Copy link
Copy Markdown
Member

Closes #65.

The TSV columns were listed in four places: the TSVRow interface, the fixed headers, the attribute-column array, and a duplicate TSVRowData interface in xlsform2lstsv/constants.ts. They're now in one: src/lstsv/columns.ts.

  • BASE_COLUMNS and ATTRIBUTE_COLUMNS are as const, with each attribute's source documented.
  • TSVRow is derived from them, and TSVRowData is now an alias of it.
  • The serializer builds its header from the two lists.

The dead typeof value !== 'string' check in escapeForTSV is removed.

On codegen emitting the attribute list: I didn't do this.

  • The column order is part of every snapshot.
  • cssclass and hide_tip aren't registry-driven.

Instead, tests/ts/unit/lstsv/columns.test.ts checks that every LimeSurvey attribute the registry names (dateFormat, parameterAttributes, integerOnly, exclusiveChoice) is in ATTRIBUTE_COLUMNS. A new registry attribute fails the build instead of being dropped silently.

Output: unchanged. Every TSV snapshot is byte-identical after re-blessing.

Tests: vitest 881 passed. npm run validate is clean.

🤖 Generated with Claude Code

The columns were listed four times: the TSVRow interface, generateTSV()'s
fixed headers, its attribute-column array, and a duplicate TSVRowData
interface in xlsform2lstsv/constants.ts.

src/lstsv/columns.ts now holds BASE_COLUMNS and ATTRIBUTE_COLUMNS (as const,
with each attribute's source documented). TSVRow is derived from them, the
serializer builds its header from them, and TSVRowData is an alias of TSVRow.
The dead `typeof value !== 'string'` check in escapeForTSV is gone.

On the issue's codegen idea: the column order is part of the snapshots, and
two attributes (cssclass, hide_tip) aren't registry-driven. So a test checks
instead that every LimeSurvey attribute the registry names (dateFormat,
parameterAttributes, integerOnly, exclusiveChoice) is in ATTRIBUTE_COLUMNS,
and a new one fails the build rather than being dropped silently.

Output unchanged: every TSV snapshot is byte-identical.

Closes #65

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@jstet
jstet merged commit e19f1c7 into main Sep 25, 2026
4 checks passed
@jstet
jstet deleted the refactor/65-tsv-columns branch September 25, 2026 11:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor(lstsv): single source for TSV column definitions

1 participant