Skip to content

Update data to v4#520

Merged
fityannugroho merged 21 commits intomainfrom
update-data-to-v4
Aug 18, 2025
Merged

Update data to v4#520
fityannugroho merged 21 commits intomainfrom
update-data-to-v4

Conversation

@fityannugroho
Copy link
Owner

@fityannugroho fityannugroho commented Aug 17, 2025

PR Checklist

Please check if your PR fulfills the following requirements:

Put [x] to check

  • The commit message follows our Contributing Guidelines
  • Tests for the changes have been added (optional, for bug fixes or features)
  • Docs have been added / updated (optional, for bug fixes or features)

PR Type

What kind of change does this PR introduce?

Please check any kind of changes that applies to this PR using [x]

  • Bug fix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Data update

What is the current behavior?

Please describe the current behavior that you are modifying, or link to a relevant issue.

Issue Number: N/A

The current API version (v6) uses:

  • Numeric-only area codes (e.g., regency: 3201, district: 320101, village: 3201012001)
  • ALL CAPS name formatting (e.g., JAWA BARAT, KABUPATEN BOGOR)
  • idn-area-data v3.1.2 package

What is the new behavior?

This PR introduces version 7 of the API, which includes breaking changes:

🔄 Restored Dotted Notation for Area Codes

  • Regency codes: 320132.01
  • District codes: 32010132.01.01
  • Village codes: 320101200132.01.01.2001
  • Island codes: 32014000132.01.40001

Context: The underlying idn-area-data has always used dotted notation, but previous API versions removed the dots. Version 7 preserves the original format to better represent hierarchical relationships.

📊 Updated Data Package

  • Upgraded from idn-area-data v3.1.2 to v4.0.0
  • Latest 2025 Indonesian administrative area data
  • Improved data consistency and validation

🎨 Improved Name Formatting

  • Changed from ALL CAPS to proper case formatting
  • JAWA BARATJawa Barat
  • KABUPATEN BOGORKabupaten Bogor
  • DI YOGYAKARTADaerah Istimewa Yogyakarta

🗄️ Database Schema Updates

Updated field lengths to accommodate dotted format:

  • regencies.code: VARCHAR(4) → VARCHAR(5)
  • districts.code: VARCHAR(6) → VARCHAR(8)
  • villages.code: VARCHAR(10) → VARCHAR(13)
  • islands.code: VARCHAR(9) → VARCHAR(11)

🔧 Technical Improvements

  • Added comprehensive test coverage for utilities, decorators, and interceptors
  • New IsAreaCode decorator for validating dotted format codes
  • Enhanced coordinate conversion utilities
  • Improved database configuration validation
  • Added upgrade documentation guide

📚 Documentation

  • Added complete upgrade guide: docs/upgrading/upgrade-to-v7.md
  • Detailed migration instructions and examples
  • Breaking changes documentation

Other information

⚠️ BREAKING CHANGES: This is version 7 and is NOT backward compatible with v6 due to:

  • Fundamental change in code formats (dotted notation)
  • Updated name capitalization
  • Database schema changes

Migration Required: Applications using v6 must be updated to handle the new dotted code format and proper case names.

Node.js Requirement: Requires Node.js ≥22.0.0 due to idn-area-data v4.0.0 dependency.

The API maintains the same endpoints and response structure while providing more accurate, hierarchical, and up-to-date Indonesian administrative area data.

- Changed the code formats for District, Island, Regency, and Village models in Prisma schema to accommodate new lengths and dotted formats.
- Implemented a custom validator `IsAreaCode` to validate area codes with dotted formats.
- Added utility functions to extract province, regency, and district codes from area codes.
- Updated service and controller tests to reflect the new area code formats.
- Modified regex patterns in tests to match the new dotted format for area codes.
- Ensured all relevant DTOs and validation decorators are updated to use the new area code format.
- Introduced a new fixture file for consistent mock data across tests.
- Replaced direct data fetching in tests with mock data from fixtures.
- Created a shared mock Prisma service to simplify test setup.
- Enhanced test readability by using helper functions for common assertions and mock setups.
- Updated all service tests (Province, Regency, Village) to utilize the new mock data and utilities.
- Deleted unused helper files: code-utils.ts, data-regex.ts, utils.ts, and test.helpers.ts.
- Refactored e2e tests for islands, provinces, regencies, and villages to use NestJS testing utilities directly.
- Updated test cases to validate response structures and handle error scenarios more effectively.
- Improved readability and maintainability of test code by removing redundant assertions and using consistent patterns.
- Added null and object checks in `isDataWrapped` function to improve data validation.
- Introduced unit tests for array utilities including `areArraysEqual`, `sortArray`, and `getValues`.
- Created tests for code extraction utilities: `extractProvinceCode`, `extractRegencyCode`, and `extractDistrictCode`.
- Implemented tests for coordinate utilities, validating DMS format and conversion to decimal.
- Developed tests for data utilities, ensuring correct API calls and transformations.
- Added tests for runner utilities to validate command execution and error handling.
- Created tests for timify utility to measure function execution time.
- Introduced tests for database error handling and configuration validation.
- Added tests for database provider utilities to ensure correct configuration and provider checks.
- Enhanced district, island, province, regency, and village services with insensitive filtering tests.
- Updated Vitest configuration to improve coverage reporting and exclude unnecessary files.
@fityannugroho fityannugroho added enhancement New feature or request dependencies Pull requests that update a dependency file breaking changes Changes that will break the current app labels Aug 17, 2025
@fityannugroho fityannugroho added this to the v7.0.0 milestone Aug 17, 2025
@fityannugroho fityannugroho requested a review from Copilot August 17, 2025 15:19

This comment was marked as outdated.

fityannugroho and others added 5 commits August 17, 2025 22:23
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
….ts`

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…spec.ts`

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…pec.ts`

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
….spec.ts`

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@fityannugroho fityannugroho requested a review from Copilot August 17, 2025 15:27
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 updates the data source to version 4.0.0 and introduces version 7 of the API with breaking changes. The main purpose is to restore dotted notation for area codes (e.g., 32.01 instead of 3201) and provide updated 2025 Indonesian administrative area data with improved formatting.

Key changes include:

  • Migration from idn-area-data v3.1.2 to v4.0.0
  • Restoration of dotted notation for area codes across all administrative levels
  • Comprehensive test suite refactoring to use modern testing patterns with fixtures and shared utilities

Reviewed Changes

Copilot reviewed 64 out of 65 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
vitest.config.mts Adds test coverage configuration with exclusions and thresholds
test/village.e2e-spec.ts Refactors e2e tests to use direct HTTP injection instead of helper classes
test/regency.e2e-spec.ts Updates e2e tests with simplified approach and dotted code validation
test/province.e2e-spec.ts Modernizes test structure with direct service mocking
test/mocks/prisma.mock.ts Introduces centralized Prisma service mocking utilities
test/island.e2e-spec.ts Simplifies e2e tests and removes complex validation logic
test/fixtures/data.fixtures.ts Adds comprehensive test data factory functions
src/village/village.dto.ts Updates validation to use new IsAreaCode decorator for dotted codes
src/village/village.service.spec.ts Refactors unit tests to use shared mock utilities
src/island/island.service.ts Improves coordinate handling and code extraction utilities
src/common/utils/data.ts Removes dot-removal logic to preserve original dotted format
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@fityannugroho fityannugroho merged commit 2ffaaf7 into main Aug 18, 2025
15 checks passed
@fityannugroho fityannugroho deleted the update-data-to-v4 branch August 18, 2025 07:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking changes Changes that will break the current app dependencies Pull requests that update a dependency file enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant