refactor: drop the duplicated SCREAMING_CASE enum aliases - #59
Merged
Conversation
`CHUNK_TYPE`, `DATA_TYPE` and `MAGIC` were plain re-exports of the `ChunkType`, `DataType` and `Magic` enums declared in `types.ts`. Both spellings were public, so the API exposed every CDB constant twice. The enums are the form that has to stay: they are used as types as well as values (`type: DataType` in `ColumnInfo`, `chunkType: ChunkType` in `ChunkHeader`), which an alias cannot express. So the aliases go, and their ~150 internal usages now reference the enums directly, importing from `./types` instead of routing through `./tableMetadata`. `tableMetadata.ts` is left with what its name promises: `TABLE_FLAGS_BY_ID`. BREAKING CHANGE: the `CHUNK_TYPE`, `DATA_TYPE` and `MAGIC` exports are removed. Use `ChunkType`, `DataType` and `Magic`, which are unchanged and were already exported alongside them. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR simplifies the library’s public API and internal imports by removing the duplicated SCREAMING_CASE enum aliases (CHUNK_TYPE, DATA_TYPE, MAGIC) in favor of the canonical ChunkType, DataType, and Magic enums from src/types.ts. This reduces duplicated exported constants/types in the published declaration files and keeps src/tableMetadata.ts focused on table-flag metadata.
Changes:
- Removed
CHUNK_TYPE,DATA_TYPE, andMAGICconstant re-exports and updated consumers to useChunkType,DataType, andMagic. - Updated internal modules to import enums directly from
./typesrather than via./tableMetadata. - Updated tests to use the enum exports directly from
src/types.ts.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| test/writer.test.ts | Switches test usage from CHUNK_TYPE alias to ChunkType enum. |
| test/reader.test.ts | Updates all constant references to ChunkType/DataType/Magic enums. |
| test/compression.test.ts | Replaces MAGIC alias usage with Magic enum. |
| src/writer.ts | Imports enums directly from ./types and replaces alias usages throughout writer logic. |
| src/tableMetadata.ts | Removes enum alias exports; leaves only TABLE_FLAGS_BY_ID. |
| src/sqlToCdb.ts | Updates imports and all references from aliases to enums for chunk/data/magic constants. |
| src/reader.ts | Updates imports and all references from aliases to enums for parsing/dispatch logic. |
| src/index.ts | Stops re-exporting removed aliases; keeps enums and TABLE_FLAGS_BY_ID as public exports. |
| src/compression.ts | Uses Magic.COMPRESSION_MAGIC directly instead of MAGIC alias. |
| src/cdbToSql.ts | Updates imports and all references from aliases to ChunkType/DataType. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
CHUNK_TYPE,DATA_TYPEandMAGICwere plain re-exports of theChunkType,DataTypeandMagicenums declared intypes.ts:Both spellings were public, so the API exposed every CDB constant twice — and
dist/index.d.tsshipped both. While the package is still on0.xthis costs nothing to fix; after1.0.0it would mean carrying both forms indefinitely.What
The enums are the form that has to stay: they are used as types as well as values (
type: DataTypeinColumnInfo,chunkType: ChunkTypeinChunkHeader), which aconstalias cannot express.src/andtest/to the enum names../typesdirectly instead of routing through./tableMetadata.tableMetadata.tsis left with what its name promises:TABLE_FLAGS_BY_ID.No behavior change — this is a rename plus a public-API removal.
Breaking change
The
CHUNK_TYPE,DATA_TYPEandMAGICexports are removed. Callers useChunkType,DataTypeandMagicinstead, which are unchanged and were already exported alongside them: