Skip to content

fix(from_file): convert registered vocabularies in the browser; keep quoted labels - #31

Merged
jstet merged 1 commit into
mainfrom
fix/browser-from-file
Sep 24, 2026
Merged

jstet merged 1 commit into
mainfrom
fix/browser-from-file

Conversation

@jstet

@jstet jstet commented Sep 24, 2026 •

Copy link
Copy Markdown
Member

Closes #24.

Browser conversion of select_*_from_file

Registered vocabularies now ship as generated data (src/generated/VocabularyOptions.ts, emitted by codegen from registry/vocab/*.csv), and XLSFormToTSVConverter.convert() inlines them by default. So the browser entry converts select_one_from_file iso_3166_1.csv with no filesystem access.

  • fileChoices (4th arg) still works: it adds an unregistered CSV or overrides a registered one.
  • XLSFormParser.convertXLSFileToTSV / convertXLSDataToTSV take fileChoices too.
  • parseVocabCsv is exported from the package root, for vocabularies the caller loads themselves.
  • src/fileChoices.ts stays node-only; the CLI uses it for CSVs beside a form.

Bug fixed along the way: quoted labels

The old parseVocabCsv split on every comma. 14 ISO 3166-1 labels were cut at the comma, e.g. "Korea, Republic of" → "Korea, and the blessed snapshots had frozen that. parseVocabCsv now uses the RFC 4180 tokenizer from responseFile.ts, and codegen parses the CSVs with Python's csv. The two *_long_list/tsv.tsv snapshots are re-blessed: the 14 labels per file are the only diff.

Also

  • The bless script and the TSV snapshot contract test no longer pass file choices, so they cover the built-in path.
  • The generated skill (skills/cdl-survey-types/references/question-types.md) told authors to define from_file options on the choices sheet. It now points to the registered-vocabulary table.

Tests

  • tests/ts/unit/vocab.test.ts: quoted labels, BOM/CRLF, column order, missing columns, registered vs. unregistered files, override, and an unknown file still throwing.
  • tests/ts/integration/browserBundle.test.ts: the esbuild browser bundle converts the select_one_long_list fixture.

npm run validate is clean. vitest: 55 files, 808 tests. pytest tests/validation: 35 passed.

Downstream

formtransform-app's e2e suite marks the two TSV cases test.fail with a link to #24. Once it pins a release containing this, those markers will fail and should be removed.

🤖 Generated with Claude Code

…quoted labels

select_*_from_file only converted to LimeSurvey TSV when a Node caller read
registry/vocab/<file>.csv from disk and passed it in, so the browser entry threw
"Unimplemented XLSForm type" for a type the registry lists as supported.

- codegen emits src/generated/VocabularyOptions.ts: every registered
  vocabulary's options, parsed with Python's csv module.
- src/vocab.ts (browser-safe): registeredFileChoices() and parseVocabCsv(),
  now on the RFC 4180 tokenizer from responseFile.ts. parseVocabCsv is
  exported from the package root.
- XLSFormToTSVConverter.convert() inlines registered vocabularies by default;
  an explicit fileChoices entry adds an unregistered file or overrides a
  registered one. XLSFormParser.convertXLS{File,Data}ToTSV take fileChoices.
- fileChoices.ts (node-only) keeps only the from-disk lookup the CLI uses for
  CSVs beside a form.

The old parseVocabCsv split on every comma, so 14 ISO 3166-1 labels such as
"Korea, Republic of" were emitted as '"Korea'. The two long_list TSV
snapshots are re-blessed; that is their only change. The bless script and the
snapshot contract test no longer pass file choices, so they exercise the
built-in path.

The generated skill told authors to put from_file options on the choices
sheet; it now points them to the registered-vocabulary table instead.

Closes #24

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@jstet
jstet merged commit 66d03f6 into main Sep 24, 2026
4 checks passed
@jstet
jstet deleted the fix/browser-from-file branch September 24, 2026 12:55
jstet added a commit that referenced this pull request Sep 25, 2026
…ns issues (#49)

Every work item moved into a self-contained cdl-wp-eins issue, rechecked
against its main:

- #27 (rewritten): the formtransform library entry on /tools (id distinct
  from the app's), drop xlsform2lstsv; its open questions answered
- #26 (rewritten): survey2ddi references, still gated on survey2ddi's final
  release, except the broken /tools/survey2ddi link, which can be fixed now;
  API pull → platform export, reader → examples/python/ddi_reader.py
- #28: methodology-only llm endpoint, so formulaid can drop its heading strip
- #29: mark unsupported/partly supported XLSForm features (rank, calculate,
  external CSV; from_file with registered vocabularies only; range bounds
  without step)
- #30: registry slugs as question-type example ids, with the mapping to
  qwacback's example ids
- #31: CI link check and toc.json ↔ snippet check (the repo has no CI yet)

Each carries the rules (snippet paths other apps fetch, llm headings as an
interface, link to the subset instead of restating it).

No HANDOVER_*.md is left in this repo.

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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.

Browser entry cannot convert select_*_from_file (registered long-list types) to TSV

1 participant