Conversation
- 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.
…ving unnecessary coordinate handling
…date method signatures
- 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.
…, province, regency, and village
- 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.
…tion in actual data
…ta and improve validation logic
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>
There was a problem hiding this comment.
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-datav3.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.
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.
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: N/A
The current API version (v6) uses:
3201, district:320101, village:3201012001)JAWA BARAT,KABUPATEN BOGOR)idn-area-datav3.1.2 packageWhat is the new behavior?
This PR introduces version 7 of the API, which includes breaking changes:
🔄 Restored Dotted Notation for Area Codes
3201→32.01320101→32.01.013201012001→32.01.01.2001320140001→32.01.40001Context: The underlying
idn-area-datahas 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
idn-area-datav3.1.2 to v4.0.0🎨 Improved Name Formatting
JAWA BARAT→Jawa BaratKABUPATEN BOGOR→Kabupaten BogorDI YOGYAKARTA→Daerah 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
IsAreaCodedecorator for validating dotted format codes📚 Documentation
docs/upgrading/upgrade-to-v7.mdOther information
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-datav4.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.