Skip to content

feat(geoutils): tree-shakeable getAdministrativeRegions function#130

Merged
tsevdos merged 4 commits intomainfrom
feat/getAdministrativeRegions
Mar 13, 2026
Merged

feat(geoutils): tree-shakeable getAdministrativeRegions function#130
tsevdos merged 4 commits intomainfrom
feat/getAdministrativeRegions

Conversation

@tsevdos
Copy link
Owner

@tsevdos tsevdos commented Mar 12, 2026

feat(geoutils): tree-shakeable getAdministrativeRegions function.

@changeset-bot
Copy link

changeset-bot bot commented Mar 12, 2026

⚠️ No Changeset found

Latest commit: 46de83d

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@tsevdos tsevdos added the enhancement New feature or request label Mar 12, 2026
@tsevdos tsevdos requested a review from Copilot March 12, 2026 12:25
Copy link

Copilot AI left a comment

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 extracts getAdministrativeRegions into its own module to improve tree-shaking and updates exports/tests accordingly.

Changes:

  • Added standalone src/getAdministrativeRegions.ts (and tests) with Mount Athos filtering + level selection.
  • Updated src/index.ts to re-export getAdministrativeRegions from the new module.
  • Refactored src/geoUtils.ts to consume the extracted function and removed the inlined implementation.

Reviewed changes

Copilot reviewed 6 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/types.ts Introduces shared geo options/types and a Locale alias used by exported option types.
src/index.ts Re-exports getAdministrativeRegions from its own entry point for better tree-shaking.
src/getAdministrativeRegions.ts New extracted implementation + data wiring.
src/getAdministrativeRegions.test.ts New focused unit tests for getAdministrativeRegions.
src/geoUtils.ts Removes embedded regions data/implementation; delegates to the extracted module.
src/data/administrative-regions-en.json Adds/updates the English administrative regions dataset under src/ for module import.
src/tests/geoUtils.test.ts Removes getAdministrativeRegions tests and updates admin-regions JSON import paths.

You can also share your feedback on Copilot code review. Take the survey.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 8 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (1)

src/geoUtils.ts:17

  • Now that AdministrativeRegionsOptions is exported from src/types.ts and geoUtils.ts imports getAdministrativeRegions, geoUtils.ts still defines its own local Locale/AdministrativeRegionsOptions types. This duplication can drift; consider importing and reusing the shared types instead of redefining them locally.
import { getAdministrativeRegions } from "./getAdministrativeRegions";
import type {
  City,
  Country,
  GeographicRegion,

You can also share your feedback on Copilot code review. Take the survey.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 8 changed files in this pull request and generated 4 comments.


You can also share your feedback on Copilot code review. Take the survey.

@tsevdos tsevdos requested a review from Copilot March 13, 2026 08:54
@sonarqubecloud
Copy link

@tsevdos tsevdos merged commit 2ad6907 into main Mar 13, 2026
14 checks passed
@tsevdos tsevdos deleted the feat/getAdministrativeRegions branch March 13, 2026 08:57
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 8 changed files in this pull request and generated 4 comments.


You can also share your feedback on Copilot code review. Take the survey.

Comment on lines +1 to 3
// Geo utilities
export { getAdministrativeRegions } from "./getAdministrativeRegions";
export {
Comment on lines +5 to +15
export const MOUNT_ATHOS_REGION_ID = 14;

const administrativeRegions = {
el: administrativeRegionsEl,
en: administrativeRegionsEn,
} as const;

const administrativeRegionsWithoutMountAthos = {
el: administrativeRegions.el.filter(({ id }) => id !== MOUNT_ATHOS_REGION_ID),
en: administrativeRegions.en.filter(({ id }) => id !== MOUNT_ATHOS_REGION_ID),
};
Comment on lines 51 to 57
type Locale = "el" | "en";

type AdministrativeRegionsOptions = {
locale?: Locale;
includeMountAthos?: boolean;
level?: "region" | "unit" | "municipality";
};
Comment on lines +377 to +382
it("returns same reference for municipality level (performance optimization)", () => {
const result1 = getAdministrativeRegions();
const result2 = getAdministrativeRegions();

// Municipality level returns same reference for performance (documented as read-only)
expect(result1).toBe(result2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants