Skip to content

Commit e01475c

Browse files
committed
Add format validation and encrypted Gridset support
Introduces comprehensive format validation for OBF, Gridset, Snap, and TouchChat files, including CLI and API support. Adds support for encrypted Gridset archives (.gridsetx) with password handling, updates documentation and examples, and refactors relevant helpers and processors to support password-protected archives and validation workflows.
1 parent 232435a commit e01475c

40 files changed

Lines changed: 3513 additions & 69 deletions

CLA.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,13 @@ If any provision of this Agreement is unenforceable, the remaining provisions re
6767
(Optional) Signature Block
6868

6969
If your organization requires a signed record, include this in your PR (as cla-signature.txt or in the PR description).
70-
• Contributor Name: ******\*\*******\_\_******\*\*******
71-
• GitHub Username: ******\*\*******\_\_******\*\*******
72-
• Email: ********\*\*********\_\_\_********\*\*********
73-
• Employer/Entity (if any): ****\*\*****\_****\*\*****
70+
• Contributor Name: **\*\***\*\***\*\***\_\_**\*\***\*\***\*\***
71+
• GitHub Username: **\*\***\*\***\*\***\_\_**\*\***\*\***\*\***
72+
• Email: **\*\*\*\***\*\***\*\*\*\***\_\_\_**\*\*\*\***\*\***\*\*\*\***
73+
• Employer/Entity (if any): \***\*\*\*\*\***\_\***\*\*\*\*\***
7474
• I have authority to bind the entity (Y/N): **\_**
75-
• Date: ********\*\*\*\*********\_********\*\*\*\*********
76-
• Signature: ******\*\*\*\*******\_\_\_\_******\*\*\*\*******
75+
• Date: **\*\*\*\***\*\*\*\***\*\*\*\***\_**\*\*\*\***\*\*\*\***\*\*\*\***
76+
• Signature: **\*\***\*\*\*\***\*\***\_\_\_\_**\*\***\*\*\*\***\*\***
7777

7878
7979

README.md

Lines changed: 85 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ A comprehensive **TypeScript library** for processing AAC (Augmentative and Alte
2727
- 🌍 **Translation workflows** - Built-in i18n support with `processTexts()`
2828
- 🎨 **Comprehensive styling support** - Preserve visual appearance across formats
2929
- 🧪 **Property-based testing** - Robust validation with 140+ tests
30+
-**Format validation** - Spec-based validation for all supported formats
3031
-**Performance optimized** - Memory-efficient processing of large files
3132
- 🛡️ **Error recovery** - Graceful handling of corrupted data
3233
- 🔒 **Thread-safe** - Concurrent processing support
@@ -191,6 +192,78 @@ const translatedBuffer = processor.processTexts(
191192
console.log("Translation complete!");
192193
```
193194

195+
### Format Validation
196+
197+
Validate AAC files against format specifications to ensure data integrity:
198+
199+
```typescript
200+
import { ObfProcessor, GridsetProcessor } from "aac-processors";
201+
202+
// Validate OBF/OBZ files
203+
const obfProcessor = new ObfProcessor();
204+
const result = await obfProcessor.validate("board.obf");
205+
206+
console.log(`Valid: ${result.valid}`);
207+
console.log(`Errors: ${result.errors}`);
208+
console.log(`Warnings: ${result.warnings}`);
209+
210+
// Detailed validation results
211+
if (!result.valid) {
212+
result.results
213+
.filter((check) => !check.valid)
214+
.forEach((check) => {
215+
console.log(`✗ ${check.description}: ${check.error}`);
216+
});
217+
}
218+
219+
// Validate Gridset files (with optional password for encrypted files)
220+
const gridsetProcessor = new GridsetProcessor({
221+
gridsetPassword: "optional-password",
222+
});
223+
const gridsetResult = await gridsetProcessor.validate("vocab.gridsetx");
224+
```
225+
226+
#### Using the CLI
227+
228+
```bash
229+
# Validate a file
230+
aacprocessors validate board.obf
231+
232+
# JSON output
233+
aacprocessors validate board.obf --json
234+
235+
# Quiet mode (just valid/invalid)
236+
aacprocessors validate board.gridset --quiet
237+
238+
# Validate encrypted Gridset file
239+
aacprocessors validate board.gridsetx --gridset-password <password>
240+
```
241+
242+
#### What Gets Validated?
243+
244+
- **OBF/OBZ**: Spec compliance (Open Board Format)
245+
- Required fields (format, id, locale, buttons, grid, images, sounds)
246+
- Grid structure (rows, columns, order)
247+
- Button references (image_id, sound_id, load_board paths)
248+
- Color formats (RGB/RGBA)
249+
- Cross-reference validation
250+
251+
- **Gridset**: XML structure
252+
- Required elements (gridset, pages, cells)
253+
- FixedCellSize configuration
254+
- Page and cell attributes
255+
- Image references
256+
257+
- **Snap**: Package structure
258+
- ZIP package validity
259+
- Settings file format
260+
- Page/button configurations
261+
262+
- **TouchChat**: XML structure
263+
- PageSet hierarchy
264+
- Button definitions
265+
- Navigation links
266+
194267
### Cross-Format Conversion
195268

196269
Convert between any supported AAC formats:
@@ -506,6 +579,7 @@ npx aac-processors analyze examples/example.gridset --pretty
506579
- `--pretty` - Human-readable output (analyze command)
507580
- `--verbose` - Detailed output (extract command)
508581
- `--quiet` - Minimal output (extract command)
582+
- `--gridset-password <password>` - Password for encrypted Grid 3 archives (`.gridsetx`)
509583

510584
**Button Filtering Options:**
511585

@@ -594,17 +668,17 @@ interface AACButton {
594668

595669
### Supported Processors
596670

597-
| Processor | File Extensions | Description |
598-
| ----------------------- | --------------- | ----------------------------- |
599-
| `DotProcessor` | `.dot` | Graphviz DOT format |
600-
| `OpmlProcessor` | `.opml` | OPML hierarchical format |
601-
| `ObfProcessor` | `.obf`, `.obz` | Open Board Format (JSON/ZIP) |
602-
| `SnapProcessor` | `.sps`, `.spb` | Tobii Dynavox Snap format |
603-
| `GridsetProcessor` | `.gridset` | Smartbox Grid 3 format |
604-
| `TouchChatProcessor` | `.ce` | PRC-Saltillo TouchChat format |
605-
| `ApplePanelsProcessor` | `.plist` | iOS Apple Panels format |
606-
| `AstericsGridProcessor` | `.grd` | Asterics Grid native format |
607-
| `ExcelProcessor` | `.xlsx` | Microsoft Excel format |
671+
| Processor | File Extensions | Description |
672+
| ----------------------- | ----------------------- | ----------------------------- |
673+
| `DotProcessor` | `.dot` | Graphviz DOT format |
674+
| `OpmlProcessor` | `.opml` | OPML hierarchical format |
675+
| `ObfProcessor` | `.obf`, `.obz` | Open Board Format (JSON/ZIP) |
676+
| `SnapProcessor` | `.sps`, `.spb` | Tobii Dynavox Snap format |
677+
| `GridsetProcessor` | `.gridset`, `.gridsetx` | Smartbox Grid 3 format |
678+
| `TouchChatProcessor` | `.ce` | PRC-Saltillo TouchChat format |
679+
| `ApplePanelsProcessor` | `.plist` | iOS Apple Panels format |
680+
| `AstericsGridProcessor` | `.grd` | Asterics Grid native format |
681+
| `ExcelProcessor` | `.xlsx` | Microsoft Excel format |
608682

609683
---
610684

examples/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@ This directory contains example AAC pagesets in various formats used for testing
1919
- **example.obf** - OBF pageset (JSON-based)
2020
- **example.obz** - OBZ pageset (compressed)
2121

22+
**obf/** - Directory containing validation test samples from the obf-node project:
23+
- **simple.obf** - Simple, valid OBF file for basic validation tests
24+
- **aboutme.json** - Invalid OBF (missing locale field) for error testing
25+
- **hash.json** - Non-OBF JSON structure for format detection tests
26+
- **array.json** - JSON array (not object) for structure validation tests
27+
- **links.obz** - OBZ package with links for zip archive validation
28+
2229
### Asterics Grid Format (.grd)
2330
- **example.grd** - Asterics Grid pageset
2431
- **example2.grd** - Alternative Asterics Grid pageset

0 commit comments

Comments
 (0)