Skip to content

feat: canonical export-name converter for GeoPackage columns (MAPCO-10823)#212

Open
razbroc wants to merge 5 commits into
alphafrom
feat/export-name-converter
Open

feat: canonical export-name converter for GeoPackage columns (MAPCO-10823)#212
razbroc wants to merge 5 commits into
alphafrom
feat/export-name-converter

Conversation

@razbroc

@razbroc razbroc commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

What

Adds a shared canonical export-name converter for deriving snake_case GeoPackage export column names.

  • toExportColumnName / convertKeysToExportColumnschange-case snakeCase for the general rule.
  • EXPORT_COLUMN_NAME_OVERRIDES — the single place naming exceptions live; one entry today: resolutionDegree → resolution_deg (the aggregate side already uses maxResolutionDeg/minResolutionDeg).
  • Null-prototype accumulator so the helper is safe to reuse on arbitrary key sets.

This is the single source of truth for export column names, consumed by polygon-parts-worker (Layer Parts) and overseer (Layer Metadata).

Why

Both repos independently snake_cased export columns; this unifies the naming (incl. the resolution_deg exception) so the two GeoPackage tables stay consistent.

Tests

9 unit tests: general conversion, CE90/UTC acronym handling, every override entry, null-value preservation, null-prototype guarantee.

Closes #211

🤖 Generated with Claude Code

Adds toExportColumnName / convertKeysToExportColumns and the EXPORT_COLUMN_NAME_OVERRIDES
table (change-case snakeCase with a single resolutionDegree -> resolution_deg override).
This is the single source of truth for deriving snake_case export column names, to be shared
by polygon-parts-worker (Layer Parts) and overseer (Layer Metadata).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@razbroc razbroc changed the title feat: canonical export-name converter for GeoPackage columns (#211) feat: canonical export-name converter for GeoPackage columns (MAPCO-10823) Jun 29, 2026
razbroc and others added 3 commits June 29, 2026 16:11
…ertions

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Replaces the file-wide eslint-disable with a block-scoped disable around the single
toEqual whose keys are export column names, keeping the rule active elsewhere.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Comment thread src/utils/export.utils.ts
};

/** Maps a camelCase property to its GeoPackage export column name: an override if present, else `snakeCase`. */
export const toExportColumnName = (propertyName: string): string => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
export const toExportColumnName = (propertyName: string): string => {
export const toGpkgColumnName = (propertyName: string): string => {

Comment thread src/utils/export.utils.ts
};

/** Renames an object's keys to their export column names, preserving values (incl. `null`). */
export const convertKeysToExportColumns = (obj: Record<string, unknown>): Record<string, unknown> => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
export const convertKeysToExportColumns = (obj: Record<string, unknown>): Record<string, unknown> => {
export const convertKeysToGpkgColumns = (obj: Record<string, unknown>): Record<string, unknown> => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

you can avoid testing the toGpkgColumnName as you already tested it within the convertKeysToGpkgColumns tests

Comment thread src/utils/export.utils.ts
import { snakeCase } from 'change-case';

/** Export column names that differ from plain `snakeCase` (e.g. `resolution_degree` -> `resolution_deg`). */
export const EXPORT_COLUMN_NAME_OVERRIDES: Record<string, string> = {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
export const EXPORT_COLUMN_NAME_OVERRIDES: Record<string, string> = {
export const GPKG_COLUMN_NAME_OVERRIDES: Record<string, string> = {

Drops the redundant toExportColumnName block (covered transitively) and folds the per-key
cases into a single object-level assertion.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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