You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ewd now handles two kinds of container, with the right decoder picked
by reading the file's magic bytes:
- compressed-xml (.ewprj, .ms10..ms19): existing PKWare path, writes
`<file>.xml`.
- mdb (.prj, .usr): Jet 3 / Jet 4 Access database read via mdb-reader,
writes `<file>.json` containing every table as `{ columns, rows }`
with rows as objects. Dates become ISO 8601 strings; OLE/binary
columns become `{ "_bytes": "base64", "value": "..." }` envelopes
so the data survives a round-trip.
Mechanism:
- `src/formats.ts` gained a `kind: 'compressed-xml' | 'mdb'` field on
each entry, plus a `detectFileFormat(filename)` that opens the file
briefly and reads the magic bytes.
- The `mdb` entry's header is `\x00\x01\x00\x00Standard Jet DB` so
`detectFormatByHeader` matches by content; non-printable bytes are
escaped in `knownFormatsList()` output.
- `src/ewd.ts` now dispatches on `format.kind` after detection.
- `src/decode.ts` adds a defensive kind check (rejects non-cxml).
- `src/encode.ts` throws a clear "not implemented yet" error when
asked to encode an mdb format. In-place-edit-only encoding is the
planned follow-up.
Tests:
- +18 new tests (61 total) covering Jet magic detection (including
both Jet 3 and Jet 4 version bytes), on-disk `detectFileFormat`,
`.prj`/`.usr` extension mapping, the new `kind` discriminator, and
`normalizeValue` for Date / Uint8Array / Buffer / Buffer-like /
bigint inputs.
Verified end-to-end on a real `Stocked.prj` (NI Cpcomp_s.prj derivative,
241 components, 37 tables) — decode succeeds and writes a 7 MB JSON.
Adds `mdb-reader` (~106 KB unpacked).
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
0 commit comments