From 656200ed6c06be47f0db2e9ff1be2b4dcdf52601 Mon Sep 17 00:00:00 2001 From: Ulad Kasach Date: Thu, 12 Dec 2024 04:19:29 -0800 Subject: [PATCH] feat(name): bump name to domain-glossary namespace --- changelog.md | 16 ++++++++++------ declapract.use.yml | 2 +- package-lock.json | 4 ++-- package.json | 18 +++++++----------- readme.md | 28 ++++++++++++++-------------- src/UniPhone.ts | 4 ++-- src/UniPhoneNumber.ts | 2 +- src/asUniPhoneInHumanWords.test.ts | 10 +++++----- src/asUniPhoneInHumanWords.ts | 6 +++--- src/asUniPhoneNumber.test.ts | 10 +++++----- src/asUniPhoneNumber.ts | 8 ++++---- src/index.ts | 10 +++++----- src/isUniPhoneNumber.ts | 10 +++++----- 13 files changed, 64 insertions(+), 64 deletions(-) diff --git a/changelog.md b/changelog.md index d6c50f6..b796c94 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,6 @@ # Changelog +<<<<<<< Updated upstream ## [1.2.0](https://github.com/ehmpathy/uni-phone/compare/v1.1.1...v1.2.0) (2024-12-04) @@ -8,29 +9,32 @@ * **cast:** expose cast asPartialPhoneInHumanWords ([f1efe3d](https://github.com/ehmpathy/uni-phone/commit/f1efe3d79508aeaf9a14e643f928e5f67eae868c)) ## [1.1.1](https://github.com/ehmpathy/uni-phone/compare/v1.1.0...v1.1.1) (2024-12-03) +======= +## [1.1.1](https://github.com/ehmpathy/domain-glossary-phone/compare/v1.1.0...v1.1.1) (2024-12-03) +>>>>>>> Stashed changes ### Bug Fixes -* **pkg:** ensure new cast is exposed on index ([0a1a5c2](https://github.com/ehmpathy/uni-phone/commit/0a1a5c23d72aecb996c3b85cbc48da8043b6f57f)) +* **pkg:** ensure new cast is exposed on index ([0a1a5c2](https://github.com/ehmpathy/domain-glossary-phone/commit/0a1a5c23d72aecb996c3b85cbc48da8043b6f57f)) -## [1.1.0](https://github.com/ehmpathy/uni-phone/compare/v1.0.1...v1.1.0) (2024-12-03) +## [1.1.0](https://github.com/ehmpathy/domain-glossary-phone/compare/v1.0.1...v1.1.0) (2024-12-03) ### Features -* **cast:** cast to phone in human words ([9f2eaea](https://github.com/ehmpathy/uni-phone/commit/9f2eaea0852bc51eee230387aeb5d6b045d3db69)) +* **cast:** cast to phone in human words ([9f2eaea](https://github.com/ehmpathy/domain-glossary-phone/commit/9f2eaea0852bc51eee230387aeb5d6b045d3db69)) -## [1.0.1](https://github.com/ehmpathy/uni-phone/compare/v1.0.0...v1.0.1) (2024-12-03) +## [1.0.1](https://github.com/ehmpathy/domain-glossary-phone/compare/v1.0.0...v1.0.1) (2024-12-03) ### Bug Fixes -* **check:** extend isUniPhoneNumber withAssure ([47f530b](https://github.com/ehmpathy/uni-phone/commit/47f530b76b2c56066895b8162cbcfb608dddf722)) +* **check:** extend isPhoneNumber withAssure ([47f530b](https://github.com/ehmpathy/domain-glossary-phone/commit/47f530b76b2c56066895b8162cbcfb608dddf722)) ## 1.0.0 (2024-11-29) ### Features -* **init:** initialize based on uni-time ([8db8ce5](https://github.com/ehmpathy/uni-phone/commit/8db8ce5ee3b925ebd43aadef4e8b8425d445c227)) +* **init:** initialize based on uni-time ([8db8ce5](https://github.com/ehmpathy/domain-glossary-phone/commit/8db8ce5ee3b925ebd43aadef4e8b8425d445c227)) diff --git a/declapract.use.yml b/declapract.use.yml index 88c4af9..05fbf86 100644 --- a/declapract.use.yml +++ b/declapract.use.yml @@ -3,4 +3,4 @@ declarations: npm:declapract-typescript-ehmpathy useCase: npm-package # specify which use case your repo is following, see `declapract-typescript-ehmpathy:src/useCases.yml` for options variables: # specify the values of the variables to use against checks organizationName: 'ehmpathy' - projectName: 'uni-phone' + projectName: 'domain-glossary-phone' diff --git a/package-lock.json b/package-lock.json index f26157e..055902a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,11 +1,11 @@ { - "name": "uni-phone", + "name": "domain-glossary-phone", "version": "1.2.0", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "uni-phone", + "name": "domain-glossary-phone", "version": "1.2.0", "hasInstallScript": true, "license": "MIT", diff --git a/package.json b/package.json index dd7497e..d3e5882 100644 --- a/package.json +++ b/package.json @@ -1,19 +1,15 @@ { - "name": "uni-phone", + "name": "domain-glossary-phone", "author": "ehmpathy", - "description": "a glossary of universally intuitive time, date, and duration domain literals", + "description": "A glossary of intuitive, universally unambiguous phone definitions and useful procedures.", "version": "1.2.0", - "repository": "ehmpathy/uni-phone", - "homepage": "https://github.com/ehmpathy/uni-phone", + "repository": "ehmpathy/domain-glossary-phone", + "homepage": "https://github.com/ehmpathy/domain-glossary-phone", "keywords": [ - "time", - "date", - "datetime", - "UniDate", - "UniDateTime", - "UniDuration" + "phone", + "phone number" ], - "bugs": "https://github.com/ehmpathy/uni-phone/issues", + "bugs": "https://github.com/ehmpathy/domain-glossary-phone/issues", "license": "MIT", "main": "dist/index.js", "engines": { diff --git a/readme.md b/readme.md index 03e6e08..154df35 100644 --- a/readme.md +++ b/readme.md @@ -1,26 +1,26 @@ -# uni-phone +# domain-glossary-phone -![test](https://github.com/ehmpathy/uni-phone/workflows/test/badge.svg) -![publish](https://github.com/ehmpathy/uni-phone/workflows/publish/badge.svg) +![test](https://github.com/ehmpathy/domain-glossary-phone/workflows/test/badge.svg) +![publish](https://github.com/ehmpathy/domain-glossary-phone/workflows/publish/badge.svg) -A glossary of intuitive, universally unambiguous phone domain literals. +A glossary of intuitive, universally unambiguous phone definitions and useful procedures. # purpose declare a universally unambiguous serialization format for phones -- `UniPhoneNumber` = [E.164](https://en.wikipedia.org/wiki/E.164) -- `UniPhone` = `{ number: UniPhoneNumber }` +- `PhoneNumber` = [E.164](https://en.wikipedia.org/wiki/E.164) +- `Phone` = `{ number: PhoneNumber }` usecases -- clarify the format a string should be in (`const phoneNumber: UniPhoneNumber = '+13231110101'`) -- cast date to universal format (`const phoneNumber: UniPhoneNumber = toUniPhoneNumber('(323) 111-0101')`) -- narrow type of strings with runtime validation (`if (!isUniPhoneNumber(input)) throw new Error('wrong format')`) +- clarify the format a string should be in (`const phoneNumber: PhoneNumber = '+13231110101'`) +- cast date to universal format (`const phoneNumber: PhoneNumber = toPhoneNumber('(323) 111-0101')`) +- narrow type of strings with runtime validation (`if (!isPhoneNumber(input)) throw new Error('wrong format')`) # install ```sh -npm install uni-phone +npm install domain-glossary-phone ``` # use @@ -30,21 +30,21 @@ npm install uni-phone ### declare that a phone or phone.number must be in the universal format ```ts -const phone: UniPhone; -const phoneNumber: UniPhoneNumber; +const phone: Phone; +const phoneNumber: PhoneNumber; ``` ### assure that a phone number is in the universal phormat ```ts -const phone: UniPhone = { number: isUniPhoneNumber.assure('+13231110101') } +const phone: Phone = { number: isPhoneNumber.assure('+13231110101') } ``` ### cast a phone number into the universal format ```ts -const phone: UniPhone = { number: asUniPhoneNumber('(323) 111-0101') } +const phone: Phone = { number: asPhoneNumber('(323) 111-0101') } ``` diff --git a/src/UniPhone.ts b/src/UniPhone.ts index 9e61ec1..fce7a06 100644 --- a/src/UniPhone.ts +++ b/src/UniPhone.ts @@ -1,7 +1,7 @@ import { DomainLiteral } from 'domain-objects'; -export interface UniPhone { +export interface Phone { id?: number; number: string; } -export class UniPhone extends DomainLiteral implements UniPhone {} +export class Phone extends DomainLiteral implements Phone {} diff --git a/src/UniPhoneNumber.ts b/src/UniPhoneNumber.ts index eedc102..58a65c0 100644 --- a/src/UniPhoneNumber.ts +++ b/src/UniPhoneNumber.ts @@ -4,4 +4,4 @@ import { AsOfGlossary } from 'domain-glossaries'; * a phone number in the universal E.164 format * - E.164 example: +18175698900 */ -export type UniPhoneNumber = AsOfGlossary; +export type PhoneNumber = AsOfGlossary; diff --git a/src/asUniPhoneInHumanWords.test.ts b/src/asUniPhoneInHumanWords.test.ts index ab86065..1d01b9f 100644 --- a/src/asUniPhoneInHumanWords.test.ts +++ b/src/asUniPhoneInHumanWords.test.ts @@ -1,10 +1,10 @@ -import { asUniPhoneInHumanWords } from './asUniPhoneInHumanWords'; -import { isUniPhoneNumber } from './isUniPhoneNumber'; +import { asPhoneInHumanWords } from './asPhoneInHumanWords'; +import { isPhoneNumber } from './isPhoneNumber'; -describe('asUniPhoneInHumanWords', () => { +describe('asPhoneInHumanWords', () => { it('should look right', () => { - const result = asUniPhoneInHumanWords({ - number: isUniPhoneNumber.assure('+13175557777'), + const result = asPhoneInHumanWords({ + number: isPhoneNumber.assure('+13175557777'), }); expect(result).toEqual('(317) 555-7777'); }); diff --git a/src/asUniPhoneInHumanWords.ts b/src/asUniPhoneInHumanWords.ts index e516ff9..d09236f 100644 --- a/src/asUniPhoneInHumanWords.ts +++ b/src/asUniPhoneInHumanWords.ts @@ -1,18 +1,18 @@ -import { UniPhone } from './UniPhone'; +import { Phone } from './Phone'; /** * .what = casts a uni phone into human words * .example * - +13335557777 => (333) 555-7777 */ -export const asUniPhoneInHumanWords = (input: UniPhone): string => { +export const asPhoneInHumanWords = (input: Phone): string => { // Validate input: must start with '+' followed by digits const phoneRegex = /^\+(\d{1,3})(\d{3})(\d{3})(\d{4})$/; const match = input.number.match(phoneRegex); if (!match) { throw new Error( - 'Invalid UniPhone format. Expected format: +<10-digit-phone>', + 'Invalid Phone format. Expected format: +<10-digit-phone>', ); } diff --git a/src/asUniPhoneNumber.test.ts b/src/asUniPhoneNumber.test.ts index 4c34088..0d3bf98 100644 --- a/src/asUniPhoneNumber.test.ts +++ b/src/asUniPhoneNumber.test.ts @@ -1,10 +1,10 @@ -import { asUniPhoneNumber } from './asUniPhoneNumber'; +import { asPhoneNumber } from './asPhoneNumber'; -describe('asUniPhoneNumber', () => { +describe('asPhoneNumber', () => { it('should be able to normalize a phone number', () => { - const fromVariant1 = asUniPhoneNumber('317 821 1234'); - const fromVariant2 = asUniPhoneNumber('(317) 821-1234'); - const fromVariant3 = asUniPhoneNumber('317821-1234'); + const fromVariant1 = asPhoneNumber('317 821 1234'); + const fromVariant2 = asPhoneNumber('(317) 821-1234'); + const fromVariant3 = asPhoneNumber('317821-1234'); expect(fromVariant1).toEqual('+13178211234'); expect(fromVariant2).toEqual(fromVariant1); expect(fromVariant3).toEqual(fromVariant2); diff --git a/src/asUniPhoneNumber.ts b/src/asUniPhoneNumber.ts index b193bfc..bf7353d 100644 --- a/src/asUniPhoneNumber.ts +++ b/src/asUniPhoneNumber.ts @@ -1,17 +1,17 @@ import { UnexpectedCodePathError } from '@ehmpathy/error-fns'; import { phone } from 'phone'; -import { UniPhoneNumber } from './UniPhoneNumber'; +import { PhoneNumber } from './PhoneNumber'; /** * casts a phone number into the universal format, E.164 */ -export const asUniPhoneNumber = (input: string): UniPhoneNumber => { +export const asPhoneNumber = (input: string): PhoneNumber => { const { phoneNumber: normalizedPhoneNumber } = phone(input); if (!normalizedPhoneNumber) throw new UnexpectedCodePathError( - 'input was not a valid phone number. can not be cast to uni-phone-number', + 'input was not a valid phone number. can not be cast to domain-glossary-phone-number', { input }, ); - return normalizedPhoneNumber as UniPhoneNumber; + return normalizedPhoneNumber as PhoneNumber; }; diff --git a/src/index.ts b/src/index.ts index 6f398f7..e1163a8 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,7 +1,7 @@ -export * from './UniPhoneNumber'; -export * from './isUniPhoneNumber'; -export * from './asUniPhoneNumber'; +export * from './PhoneNumber'; export * from './isPhoneNumber'; -export * from './UniPhone'; -export * from './asUniPhoneInHumanWords'; +export * from './asPhoneNumber'; +export * from './isPhoneNumber'; +export * from './Phone'; +export * from './asPhoneInHumanWords'; export * from './asPartialPhoneInHumanWords'; diff --git a/src/isUniPhoneNumber.ts b/src/isUniPhoneNumber.ts index 3e05f9e..f857a72 100644 --- a/src/isUniPhoneNumber.ts +++ b/src/isUniPhoneNumber.ts @@ -1,15 +1,15 @@ import { withAssure } from 'type-fns'; -import { UniPhoneNumber } from './UniPhoneNumber'; -import { asUniPhoneNumber } from './asUniPhoneNumber'; +import { PhoneNumber } from './PhoneNumber'; +import { asPhoneNumber } from './asPhoneNumber'; /** * checks whether a string is a universally formatted phone number */ -export const isUniPhoneNumber = withAssure( - (input: string): input is UniPhoneNumber => { +export const isPhoneNumber = withAssure( + (input: string): input is PhoneNumber => { try { - const universal = asUniPhoneNumber(input); + const universal = asPhoneNumber(input); return input === universal; } catch { // if there was an error, then its not a phone number, so defo not a universal phone number