Skip to content

refactor: drop the duplicated SCREAMING_CASE enum aliases - #59

Merged
mpicciolli merged 1 commit into
mainfrom
chore/dedupe-enum-aliases
Aug 17, 2026
Merged

refactor: drop the duplicated SCREAMING_CASE enum aliases#59
mpicciolli merged 1 commit into
mainfrom
chore/dedupe-enum-aliases

Conversation

@mpicciolli

@mpicciolli mpicciolli commented Aug 17, 2026

Copy link
Copy Markdown
Collaborator

Why

CHUNK_TYPE, DATA_TYPE and MAGIC were plain re-exports of the ChunkType, DataType and Magic enums declared in types.ts:

export const CHUNK_TYPE = ChunkType;
export const DATA_TYPE = DataType;
export const MAGIC = Magic;

Both spellings were public, so the API exposed every CDB constant twice — and dist/index.d.ts shipped both. While the package is still on 0.x this costs nothing to fix; after 1.0.0 it 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: DataType in ColumnInfo, chunkType: ChunkType in ChunkHeader), which a const alias cannot express.

  • Removed the three aliases.
  • Renamed their ~150 internal usages across src/ and test/ to the enum names.
  • Those files now import from ./types directly instead of routing through ./tableMetadata.
  • tableMetadata.ts is 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_TYPE and MAGIC exports are removed. Callers use ChunkType, DataType and Magic instead, which are unchanged and were already exported alongside them:

-import { DATA_TYPE } from "cdb-converter";
-if (col.type === DATA_TYPE.STRING) { /* … */ }
+import { DataType } from "cdb-converter";
+if (col.type === DataType.STRING) { /* … */ }

`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>
Copilot AI lite review requested due to automatic review settings August 17, 2026 12:52

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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, and MAGIC constant re-exports and updated consumers to use ChunkType, DataType, and Magic.
  • Updated internal modules to import enums directly from ./types rather 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.

@mpicciolli
mpicciolli merged commit 15be253 into main Aug 17, 2026
7 checks passed
@mpicciolli
mpicciolli deleted the chore/dedupe-enum-aliases branch August 17, 2026 13:19
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.

2 participants