|
| 1 | +# Storage Finder CSV Importer: Maintainer Guide |
| 2 | + |
| 3 | +This approach aims to balance user-friendliness (content editors update the Google Sheet) with functionality (developers tune `config.ts` so the JSON stays in sync). |
| 4 | + |
| 5 | +## What the CLI does |
| 6 | + |
| 7 | +- Reads a CSV export of the shared Google Sheet (either via `STORAGE_FINDER_SHEET_URL` or `--csv <path>`). |
| 8 | +- Applies the questions/choices/matchers defined in `scripts/storage-finder-data-generator/config.ts`. |
| 9 | +- Generates `facet-tree.json` and `service-list.json` with slug-based IDs. |
| 10 | + |
| 11 | +## How to regenerate data |
| 12 | + |
| 13 | +```sh |
| 14 | +bun scripts/storage-finder-data-generator/generate.ts \ |
| 15 | + --csv "Datafinder Data - Sheet1.csv" \ |
| 16 | + --output src/data/storage-finder |
| 17 | +``` |
| 18 | + |
| 19 | +- Omit `--csv` to download from `STORAGE_FINDER_SHEET_URL`. |
| 20 | +- Use `--output` to write elsewhere (defaults to `src/data/storage-finder/generated` in the code). |
| 21 | +- If you do not have Bun, install it from [https://bun.sh/](https://bun.sh/) or run with `pnpm dlx tsx scripts/storage-finder-data-generator/generate.ts ...`. Node does not run TypeScript by default; `tsx` provides the TypeScript loader. |
| 22 | + |
| 23 | +## How to add or change a question |
| 24 | + |
| 25 | +1. Add a column to the sheet that contains the signals you want to match. |
| 26 | +2. In `scripts/storage-finder-data-generator/config.ts`, add a new facet entry to `FACET_CONFIGS`: |
| 27 | +- Set `id` (slug), `name`, `controlType` (`radio` or `checkbox`), `column` (sheet column name), and `choices` (labels the app should show). |
| 28 | +- Add `matchers`: regex patterns that map cell text to choice IDs. Include `allowMultipleMatches: true` if a radio question legitimately matches more than one choice. |
| 29 | +- If no regex matches, `fallback: "all"` keeps the service visible; otherwise supply an explicit array of choice IDs. |
| 30 | +3. Regenerate with the CLI and verify in the app. |
| 31 | + |
| 32 | +## Service fields |
| 33 | + |
| 34 | +Field definitions live in `scripts/storage-finder-data-generator/config.ts` (`FIELD_DEFINITIONS`). They map sheet columns to service detail rows (Links, Use Case, Limitations, Permission Settings, Eligibility, Synchronous Access, Alumni Access, Backup). Adjust labels or formatters there if the sheet schema changes. |
| 35 | + |
| 36 | +## Naming and IDs |
| 37 | + |
| 38 | +- Services are slugged from the `Title` column; duplicates get `-2`, `-3`, etc. |
| 39 | +- Facet and choice IDs are slugs defined in `config.ts`; keep them stable to avoid breaking references. |
| 40 | + |
| 41 | +## Validation rules |
| 42 | + |
| 43 | +- Radio facets throw if more than one choice matches unless `allowMultipleMatches` is set. |
| 44 | +- Blank cells render as “Not Available” in service fields. |
| 45 | +- Regexes match against raw cell text; use clear keywords in the sheet for deterministic mapping. |
0 commit comments