feat(package): modernize package metadata, exports, and typed country dataset coverage

This commit is contained in:
2026-05-01 22:10:01 +00:00
parent bea77e8672
commit 1aba288d2b
14 changed files with 7650 additions and 5000 deletions
+40
View File
@@ -0,0 +1,40 @@
{
"@ship.zone/szci": {
"npmGlobalTools": [],
"npmRegistryUrl": "registry.npmjs.org"
},
"@git.zone/cli": {
"projectType": "npm",
"module": {
"githost": "code.foss.global",
"gitscope": "push.rocks",
"gitrepo": "smarti18n",
"shortDescription": "Country code and phone prefix data",
"description": "A package for internationalization (i18n) that provides utilities for dealing with international phone number prefixes, country codes, and names.",
"npmPackagename": "@push.rocks/smarti18n",
"license": "MIT",
"keywords": [
"i18n",
"internationalization",
"country codes",
"phone prefixes",
"typescript",
"npm package",
"country names",
"language support",
"translation utilities",
"globalization"
]
},
"release": {
"registries": [
"https://verdaccio.lossless.digital",
"https://registry.npmjs.org"
],
"accessLevel": "public"
}
},
"@git.zone/tsdoc": {
"legal": "\n## License and Legal Information\n\nThis repository contains open-source code licensed under the MIT License. A copy of the license can be found in the [LICENSE](./LICENSE) file.\n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH or third parties, and are not included within the scope of the MIT license granted herein.\n\nUse of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines or the guidelines of the respective third-party owners, and any usage must be approved in writing. Third-party trademarks used herein are the property of their respective owners and used only in a descriptive manner, e.g. for an implementation of an API or similar.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District Court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n"
}
}
+32
View File
@@ -0,0 +1,32 @@
# Changelog
## 2026-05-01 - 1.1.0 - feat(package)
modernize package metadata, exports, and typed country dataset coverage
- add an exported ICountryCode interface and type the countryCodeArray dataset
- add meaningful tests for dataset size and Germany country metadata
- define package exports and refresh build, test, and documentation tooling configuration
- update README and project metadata for clearer package usage and release configuration
## 2024-05-29 - 1.0.4 - maintenance
Repository metadata and configuration updates.
- Updated package description
- Adjusted TypeScript configuration
- Updated npmextra.json git host settings
- Includes routine maintenance changes across 2024-03-30 to 2024-05-29
## 2023-10-21 - 1.0.3 - core
Core update fix release.
- Applied `fix(core): update`
## 2023-10-21 - 1.0.2 - core
Core update fix release.
- Applied `fix(core): update`
## 2023-10-21 - 1.0.1 - core
Core update fix release.
- Applied `fix(core): update`
+19
View File
@@ -0,0 +1,19 @@
Copyright (c) 2026 Task Venture Capital GmbH <hello@task.vc>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+16 -9
View File
@@ -1,14 +1,18 @@
{
"gitzone": {
"@ship.zone/szci": {
"npmGlobalTools": [],
"npmRegistryUrl": "registry.npmjs.org"
},
"@git.zone/cli": {
"projectType": "npm",
"module": {
"githost": "code.foss.global",
"gitscope": "push.rocks",
"gitrepo": "smarti18n",
"shortDescription": "Country code and phone prefix data",
"description": "A package for internationalization (i18n) that provides utilities for dealing with international phone number prefixes, country codes, and names.",
"npmPackagename": "@push.rocks/smarti18n",
"license": "MIT",
"projectDomain": "push.rocks",
"keywords": [
"i18n",
"internationalization",
@@ -21,13 +25,16 @@
"translation utilities",
"globalization"
]
},
"release": {
"registries": [
"https://verdaccio.lossless.digital",
"https://registry.npmjs.org"
],
"accessLevel": "public"
}
},
"npmci": {
"npmGlobalTools": [],
"npmAccessLevel": "public"
},
"tsdoc": {
"legal": "\n## License and Legal Information\n\nThis repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. \n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n"
"@git.zone/tsdoc": {
"legal": "\n## License and Legal Information\n\nThis repository contains open-source code licensed under the MIT License. A copy of the license can be found in the [LICENSE](./LICENSE) file.\n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH or third parties, and are not included within the scope of the MIT license granted herein.\n\nUse of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines or the guidelines of the respective third-party owners, and any usage must be approved in writing. Third-party trademarks used herein are the property of their respective owners and used only in a descriptive manner, e.g. for an implementation of an API or similar.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District Court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n"
}
}
}
+15 -12
View File
@@ -3,30 +3,31 @@
"version": "1.0.4",
"private": false,
"description": "A package for internationalization (i18n) that provides utilities for dealing with international phone number prefixes, country codes, and names.",
"exports": {
".": "./dist_ts/index.js"
},
"main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts",
"type": "module",
"author": "Task Venture Capital GmbH",
"author": "Task Venture Capital GmbH <hello@task.vc>",
"license": "MIT",
"scripts": {
"test": "(tstest test/ --web)",
"build": "(tsbuild --web --allowimplicitany)",
"buildDocs": "(tsdoc)"
"test": "tstest test/",
"build": "tsbuild --web",
"buildDocs": "tsdoc"
},
"devDependencies": {
"@git.zone/tsbuild": "^2.1.25",
"@git.zone/tsbundle": "^2.0.5",
"@git.zone/tsrun": "^1.2.46",
"@git.zone/tstest": "^1.0.44",
"@push.rocks/tapbundle": "^5.0.15",
"@types/node": "^20.8.7"
"@git.zone/tsbuild": "^4.4.0",
"@git.zone/tsdoc": "^2.0.3",
"@git.zone/tstest": "^3.6.3",
"@types/node": "^25.6.0"
},
"repository": {
"type": "git",
"url": "https://code.foss.global/push.rocks/smarti18n.git"
},
"bugs": {
"url": "https://gitlab.com/push.rocks/smarti18n/issues"
"url": "https://code.foss.global/push.rocks/smarti18n/issues"
},
"homepage": "https://code.foss.global/push.rocks/smarti18n",
"browserslist": [
@@ -41,6 +42,8 @@
"dist_ts_web/**/*",
"assets/**/*",
"cli.js",
".smartconfig.json",
"license",
"npmextra.json",
"readme.md"
],
@@ -56,4 +59,4 @@
"translation utilities",
"globalization"
]
}
}
+7414 -4903
View File
File diff suppressed because it is too large Load Diff
+84 -57
View File
@@ -1,108 +1,135 @@
# @push.rocks/smarti18n
a package dealing with i18n stuff
`@push.rocks/smarti18n` is a tiny, typed ESM package for working with country metadata in international applications. It currently ships a ready-to-use country-code dataset that maps ISO-style country codes to human-readable country names and international phone prefixes.
Use it when you need dependable country data for signup forms, billing profiles, phone-number UI, address flows, CRM imports, or any TypeScript project that needs country names and dialing prefixes without pulling in a large i18n framework.
## Issue Reporting and Security
For reporting bugs, issues, or security vulnerabilities, please visit [community.foss.global/](https://community.foss.global/). This is the central community hub for all issue reporting. Developers who sign and comply with our contribution agreement and go through identification can also get a [code.foss.global/](https://code.foss.global/) account to submit Pull Requests directly.
## Install
To use @push.rocks/smarti18n in your project, you will need to install it via npm or yarn. Ensure you have Node.js installed before proceeding. To install the package, run the following command in your project's root directory:
```bash
npm install @push.rocks/smarti18n --save
```
or if you prefer using yarn:
```bash
yarn add @push.rocks/smarti18n
pnpm add @push.rocks/smarti18n
```
This command will download @push.rocks/smarti18n and add it to your project's `node_modules` directory as well as add it as a dependency in your project's `package.json` file.
The package is published as native ESM and includes TypeScript declarations.
## What It Exports
### `ICountryCode`
```typescript
export interface ICountryCode {
code: string;
name: string;
phonePrefix: string;
}
```
Each record contains:
- `code`: the two-letter country or territory code, such as `DE`, `US`, or `GB`
- `name`: the display name for the country or territory
- `phonePrefix`: the international dialing prefix without a leading `+`, such as `49` for Germany
Some territories do not have their own dialing prefix in the dataset. In those cases, `phonePrefix` is an empty string.
### `countryCodeArray`
```typescript
export const countryCodeArray: ICountryCode[];
```
`countryCodeArray` contains more than 200 country and territory records.
## Usage
The `@push.rocks/smarti18n` package provides functionalities to deal with internationalization (i18n) aspects, such as language codes, country codes, and potentially localized strings management. Let's explore its capabilities through various use cases.
### Importing the module
First, you need to import the module into your TypeScript project. Since this package uses ESM syntax, you should import it like so:
```typescript
import * as smarti18n from '@push.rocks/smarti18n';
```
Or if you just need specific exports like `countryCodeArray`, you can import them directly:
### Import The Dataset
```typescript
import { countryCodeArray } from '@push.rocks/smarti18n';
```
### Working with Country Codes
One primary feature of `@push.rocks/smarti18n` is dealing with country codes. The module provides an array of country codes along with their respective names and phone prefixes.
### Find A Country By Code
```typescript
import { countryCodeArray } from '@push.rocks/smarti18n';
// Let's log the name and phone prefix of Germany
const germanyInfo = countryCodeArray.find(country => country.code === 'DE');
console.log(`Country: ${germanyInfo?.name}, Phone Prefix: ${germanyInfo?.phonePrefix}`);
const germany = countryCodeArray.find((country) => country.code === 'DE');
console.log(germany);
// { code: 'DE', name: 'Germany', phonePrefix: '49' }
```
This example would output something like:
### Build Country Select Options
```plaintext
Country: Germany, Phone Prefix: 49
```typescript
import { countryCodeArray } from '@push.rocks/smarti18n';
const countryOptions = countryCodeArray.map((country) => ({
value: country.code,
label: country.phonePrefix
? `${country.name} (+${country.phonePrefix})`
: country.name,
}));
```
This simple scenario showcases how you can retrieve information about a country, which can be particularly useful when working with international forms, user profiles, etc.
### Create A Fast Lookup Map
### Advanced Usage Scenarios
```typescript
import { countryCodeArray } from '@push.rocks/smarti18n';
Though the provided test cases and examples primarily deal with country codes, the infrastructure of `@push.rocks/smarti18n` allows for expansions to include handling localized strings based on user locale, formatting numbers and dates according to locale, etc.
const countriesByCode = new Map(
countryCodeArray.map((country) => [country.code, country])
);
Here's a conceptual overview of how you might expand upon the existing framework to include localized strings:
const unitedStates = countriesByCode.get('US');
console.log(unitedStates?.phonePrefix);
// '1'
```
1. **Defining Localized Strings**: Imagine you have JSON files for each locale, containing key-value pairs of strings that need to be localized.
### Filter Countries With Phone Prefixes
```json
// en.json
{
"greeting": "Hello, World!"
}
```typescript
import { countryCodeArray } from '@push.rocks/smarti18n';
// de.json
{
"greeting": "Hallo, Welt!"
}
```
const countriesWithDialingPrefixes = countryCodeArray.filter(
(country) => country.phonePrefix.length > 0
);
```
2. **Loading and Using Localized Strings**: First, you'd load the appropriate JSON file based on the user's locale. Then, you could access the localized strings using a key.
## API Surface
```typescript
import { getLocalizedString } from '@push.rocks/smarti18n';
The package intentionally keeps the API small:
const userLocale = 'de'; // This would typically come from the user's preferences
const greeting = getLocalizedString('greeting', userLocale);
console.log(greeting); // Outputs: Hallo, Welt!
```
- `ICountryCode`: TypeScript interface for a country record
- `countryCodeArray`: Array of country records
Note: The function `getLocalizedString` is hypothetical and represents a potential feature of the library, illustrating how it could be expanded to handle a broader scope of i18n needs.
There are no runtime helpers, localization engines, translation loaders, or date/number formatters in the current release. If you need those features, combine this dataset with the platform `Intl` APIs or your existing i18n framework.
### Conclusion
## Runtime Compatibility
While `@push.rocks/smarti18n` currently focuses on providing a comprehensive listing of country codes, its design allows for easy expansion to cover a wide array of internationalization and localization features. Whether you're building a multinational web application or just need to handle different languages and regions, `@push.rocks/smarti18n` offers a solid foundation to incorporate i18n aspects into your TypeScript projects.
`@push.rocks/smarti18n` is built as an ESM package and works in modern Node.js and browser-oriented TypeScript builds. The dataset is static, has no runtime dependencies, and can be imported directly in frontend or backend code.
## License and Legal Information
This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository.
This repository contains open-source code licensed under the MIT License. A copy of the license can be found in the [LICENSE](./LICENSE) file.
**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
### Trademarks
This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.
This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH or third parties, and are not included within the scope of the MIT license granted herein.
Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines or the guidelines of the respective third-party owners, and any usage must be approved in writing. Third-party trademarks used herein are the property of their respective owners and used only in a descriptive manner, e.g. for an implementation of an API or similar.
### Company Information
Task Venture Capital GmbH
Registered at District court Bremen HRB 35230 HB, Germany
Registered at District Court Bremen HRB 35230 HB, Germany
For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.
For any legal inquiries or further information, please contact us via email at hello@task.vc.
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.
+15
View File
@@ -0,0 +1,15 @@
import { expect, tap } from '@git.zone/tstest/tapbundle';
import * as smarti18n from '../ts/index.js';
tap.test('should expose country code records', async () => {
expect(smarti18n.countryCodeArray.length).toBeGreaterThan(200);
});
tap.test('should include Germany with phone prefix', async () => {
const germany = smarti18n.countryCodeArray.find((countryArg) => countryArg.code === 'DE');
expect(germany?.name).toEqual('Germany');
expect(germany?.phonePrefix).toEqual('49');
});
export default tap.start();
-8
View File
@@ -1,8 +0,0 @@
import { expect, expectAsync, tap } from '@push.rocks/tapbundle';
import * as smarti18n from '../ts/index.js'
tap.test('first test', async () => {
console.log(smarti18n)
})
tap.start()
+3 -3
View File
@@ -1,8 +1,8 @@
/**
* autocreated commitinfo by @pushrocks/commitinfo
* autocreated commitinfo by @push.rocks/commitinfo
*/
export const commitinfo = {
name: '@push.rocks/smarti18n',
version: '1.0.4',
description: 'a package dealing with i18n stuff'
version: '1.1.0',
description: 'A package for internationalization (i18n) that provides utilities for dealing with international phone number prefixes, country codes, and names.'
}
+8 -2
View File
@@ -1,4 +1,10 @@
export const countryCodeArray = [
export interface ICountryCode {
code: string;
name: string;
phonePrefix: string;
}
export const countryCodeArray: ICountryCode[] = [
{ "code": "AD", "name": "Andorra", "phonePrefix": "376" },
{ "code": "AE", "name": "United Arab Emirates", "phonePrefix": "971" },
{ "code": "AF", "name": "Afghanistan", "phonePrefix": "93" },
@@ -248,4 +254,4 @@ export const countryCodeArray = [
{ "code": "ZA", "name": "South Africa", "phonePrefix": "27" },
{ "code": "ZM", "name": "Zambia", "phonePrefix": "260" },
{ "code": "ZW", "name": "Zimbabwe", "phonePrefix": "263" }
];
];
-1
View File
@@ -1,2 +1 @@
import * as plugins from './smarti18n.plugins.js';
export * from './countrycodes.js';
+1 -4
View File
@@ -1,4 +1 @@
const removeme = {};
export {
removeme
}
export {};
+3 -1
View File
@@ -5,8 +5,10 @@
"target": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"noImplicitAny": true,
"esModuleInterop": true,
"verbatimModuleSyntax": true
"verbatimModuleSyntax": true,
"types": ["node"]
},
"exclude": [
"dist_*/**/*.d.ts"