From 67a3e5fb0d748aac5311a498dcc2bc8ad6c7acb5 Mon Sep 17 00:00:00 2001 From: Ali Mihandoost Date: Tue, 19 Sep 2023 19:35:04 +0330 Subject: [PATCH] lint: format --- .github/ISSUE_TEMPLATE/1-bug-report.md | 5 + .github/dependabot.yml | 20 ++-- .vscode/settings.json | 10 +- demo/crypto/rand.ts | 1 - demo/es-bench/bench.ts | 6 +- demo/es-bench/compare.ts | 7 +- demo/es-bench/flat-str.ts | 14 +-- demo/es-bench/import-tmp.ts | 2 +- demo/es-bench/index.html | 2 +- demo/es-bench/logger.ts | 1 - demo/es-bench/many-bind.ts | 16 +-- demo/es-bench/node-exist.ts | 11 +- demo/tsconfig.json | 2 +- demo/validator/validator.ts | 57 ++-------- packages/crypto/CHANGELOG.md | 8 +- packages/crypto/src/type.ts | 1 - packages/crypto/src/user.ts | 5 +- packages/fetch/CHANGELOG.md | 80 ++++++------- packages/fetch/src/fetch.ts | 6 +- packages/logger/CHANGELOG.md | 34 +++--- packages/math/CHANGELOG.md | 34 +++--- packages/math/src/math.ts | 2 +- packages/math/src/unicode-digits.ts | 1 - packages/nano-server/CHANGELOG.md | 60 +++++----- packages/nano-server/src/nano-server.ts | 17 ++- packages/nano-server/tsconfig.json | 6 +- packages/type/CHANGELOG.md | 142 ++++++++++++------------ packages/type/src/i18n.ts | 11 +- packages/type/src/service-response.ts | 7 +- packages/type/src/type-helper.ts | 14 +-- packages/type/src/user.ts | 2 +- packages/util/CHANGELOG.md | 42 +++---- packages/util/src/polyfill.ts | 5 +- packages/validator/CHANGELOG.md | 54 ++++----- packages/validator/src/validator.ts | 3 +- tsconfig.base.json | 2 +- tsconfig.json | 4 +- 37 files changed, 316 insertions(+), 378 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/1-bug-report.md b/.github/ISSUE_TEMPLATE/1-bug-report.md index b853b2e5..79d60038 100644 --- a/.github/ISSUE_TEMPLATE/1-bug-report.md +++ b/.github/ISSUE_TEMPLATE/1-bug-report.md @@ -11,12 +11,15 @@ Note: Please search to see if an issue already exists for the bug you encountere --> ### Current Behavior + ### Expected Behavior + ### Steps To Reproduce + ### Environment + ### Anything else + diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 0baf10d8..3592b543 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -2,8 +2,7 @@ version: 2 updates: - - - package-ecosystem: github-actions + - package-ecosystem: github-actions directory: / open-pull-requests-limit: 20 reviewers: @@ -17,10 +16,9 @@ updates: groups: github-actions: patterns: - - "*" + - '*' - - - package-ecosystem: npm + - package-ecosystem: npm directory: / versioning-strategy: increase open-pull-requests-limit: 20 @@ -35,15 +33,15 @@ updates: - maintenance groups: production-dependencies: - dependency-type: "production" + dependency-type: 'production' development-dependencies: - dependency-type: "development" + dependency-type: 'development' exclude-patterns: - - "*lint*" + - '*lint*' lint-dependencies: patterns: - - "*lint*" + - '*lint*' alwatr-dependencies: patterns: - - "@alwatr/*" - - "fract" + - '@alwatr/*' + - 'fract' diff --git a/.vscode/settings.json b/.vscode/settings.json index 8def1dbb..61659b1c 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -24,12 +24,6 @@ "cSpell.words": [], "typescript.tsdk": "node_modules/typescript/lib", "git.autoStash": true, - "git.branchProtection": [ - "main", - "next" - ], - "githubPullRequests.ignoredPullRequestBranches": [ - "main", - "next" - ] + "git.branchProtection": ["main", "next"], + "githubPullRequests.ignoredPullRequestBranches": ["main", "next"] } diff --git a/demo/crypto/rand.ts b/demo/crypto/rand.ts index cc484aae..5e2cb21a 100644 --- a/demo/crypto/rand.ts +++ b/demo/crypto/rand.ts @@ -5,4 +5,3 @@ const hashGenerator = new AlwatrHashGenerator(secretGeneratorPreConfig); for (let i = 0; i <= 10; i++) { console.log('hash: %s', hashGenerator.randomSelfValidate()); } - diff --git a/demo/es-bench/bench.ts b/demo/es-bench/bench.ts index 184e74cb..3dc6c198 100644 --- a/demo/es-bench/bench.ts +++ b/demo/es-bench/bench.ts @@ -1,5 +1,7 @@ if (globalThis.process && (globalThis.process?.env.NODE_ENV !== 'production' || typeof globalThis.gc !== 'function')) { - console.warn('Please run node in production with `--expose-gc` for benchmark\nNODE_ENV=production node --expose-gc demo/...'); + console.warn( + 'Please run node in production with `--expose-gc` for benchmark\nNODE_ENV=production node --expose-gc demo/...', + ); } export const bench = (name: string, func: () => void, count = 1_000_000): void => { @@ -19,7 +21,7 @@ export const bench = (name: string, func: () => void, count = 1_000_000): void = console.log( `run ${name} ${runPerSec.toLocaleString()}/s with ${ globalThis.process?.memoryUsage.rss !== undefined ? memoryUsage.toLocaleString() : '?' - }kb` + }kb`, ); globalThis.gc?.(); }; diff --git a/demo/es-bench/compare.ts b/demo/es-bench/compare.ts index 97ba890f..cebd9218 100644 --- a/demo/es-bench/compare.ts +++ b/demo/es-bench/compare.ts @@ -5,8 +5,7 @@ const value = undefined; function test_1(): boolean { if (value === true) { return true; - } - else { + } else { return false; } } @@ -14,13 +13,11 @@ function test_1(): boolean { function test_2(): boolean { if (value) { return true; - } - else { + } else { return false; } } - bench('test_1', test_1); bench('test_2', test_2); diff --git a/demo/es-bench/flat-str.ts b/demo/es-bench/flat-str.ts index 1d1c6e03..a28aa09b 100644 --- a/demo/es-bench/flat-str.ts +++ b/demo/es-bench/flat-str.ts @@ -1,9 +1,9 @@ import {bench} from './bench.js'; -function flatstr (s: string) { +function flatstr(s: string) { // @ts-ignore - s | 0 - return s + s | 0; + return s; } let temp = ''; @@ -11,7 +11,7 @@ let temp = ''; function test_1(): void { let s = ''; let n = 1_000_000; - while(n--) { + while (n--) { s += 'ali'; } temp = s; @@ -20,13 +20,12 @@ function test_1(): void { function test_2(): void { let s = ''; let n = 1_000_000; - while(n--) { + while (n--) { s += 'ali'; } temp = flatstr(s); } - bench('test_1', test_1, 10); bench('test_2', test_2, 10); @@ -36,5 +35,4 @@ bench('test_2', test_2, 10); bench('test_1', test_1, 10); bench('test_2', test_2, 10); - -console.log(temp.length) +console.log(temp.length); diff --git a/demo/es-bench/import-tmp.ts b/demo/es-bench/import-tmp.ts index a8ada091..cbcfc01e 100644 --- a/demo/es-bench/import-tmp.ts +++ b/demo/es-bench/import-tmp.ts @@ -1,3 +1,3 @@ -export {} +export {}; console.log('test'); diff --git a/demo/es-bench/index.html b/demo/es-bench/index.html index b0c1e779..454310ea 100644 --- a/demo/es-bench/index.html +++ b/demo/es-bench/index.html @@ -1,4 +1,4 @@ - + diff --git a/demo/es-bench/logger.ts b/demo/es-bench/logger.ts index 150e7da3..2febf20d 100644 --- a/demo/es-bench/logger.ts +++ b/demo/es-bench/logger.ts @@ -35,5 +35,4 @@ bench('test_without_logger 1st', () => test_without_logger(getUserList())); bench('test_with_logger 2nd', () => test_with_logger(getUserList())); bench('test_without_logger 2nd', () => test_without_logger(getUserList())); - globalThis.document?.body.append(' Done. Check the console.'); diff --git a/demo/es-bench/many-bind.ts b/demo/es-bench/many-bind.ts index f5c070d9..6c9428d5 100644 --- a/demo/es-bench/many-bind.ts +++ b/demo/es-bench/many-bind.ts @@ -10,16 +10,16 @@ function test3(id: string): void { console.log(id); } -const bind = (id: string) => ({ - id, - test1: test1.bind(null, id), - test2: test2.bind(null, id), - test3: test3.bind(null, id), -} as const); +const bind = (id: string) => + ({ + id, + test1: test1.bind(null, id), + test2: test2.bind(null, id), + test3: test3.bind(null, id), + }) as const; class MyClass { - constructor(public id: string) { - } + constructor(public id: string) {} test1(): void { console.log(this.id); diff --git a/demo/es-bench/node-exist.ts b/demo/es-bench/node-exist.ts index 539d0adc..68675a03 100644 --- a/demo/es-bench/node-exist.ts +++ b/demo/es-bench/node-exist.ts @@ -1,5 +1,5 @@ import {accessSync, existsSync, constants} from 'node:fs'; -import { bench } from './bench.js'; +import {bench} from './bench.js'; const filePath = './temp-file.txt'; function exist(): boolean { @@ -10,14 +10,13 @@ function access(): boolean { try { accessSync(filePath, constants.F_OK); return true; - } - catch { - return false + } catch { + return false; } } -console.log('exist(%s) => %s', filePath, exist()) -console.log('access(%s) => %s', filePath, access()) +console.log('exist(%s) => %s', filePath, exist()); +console.log('access(%s) => %s', filePath, access()); bench('exist', exist); bench('access', access); diff --git a/demo/tsconfig.json b/demo/tsconfig.json index f9a8b086..03f0514a 100644 --- a/demo/tsconfig.json +++ b/demo/tsconfig.json @@ -16,6 +16,6 @@ {"path": "../packages/crypto"}, {"path": "../packages/math"}, {"path": "../packages/util"}, - {"path": "../packages/validator"}, + {"path": "../packages/validator"} ] } diff --git a/demo/validator/validator.ts b/demo/validator/validator.ts index f151fe63..d866f431 100644 --- a/demo/validator/validator.ts +++ b/demo/validator/validator.ts @@ -2,9 +2,7 @@ import {validator} from '@alwatr/validator'; console.log('basic test'); console.log( - validator< - {num: number; str: string; bool: boolean; _null: null; ali: 'ali'; five: 5; true: true} - >( + validator<{num: number; str: string; bool: boolean; _null: null; ali: 'ali'; five: 5; true: true}>( {num: Number, str: String, bool: Boolean, _null: null, ali: 'ali', five: 5, true: true}, {num: 123, str: 'test', bool: false, _null: null, ali: 'ali', five: 5, true: true}, ), @@ -12,9 +10,7 @@ console.log( console.log('sanitize value test'); console.log( - validator< - {num: number; str: string; bool: boolean; _null: null; ali: 'ali'; five: 5; true: true} - >( + validator<{num: number; str: string; bool: boolean; _null: null; ali: 'ali'; five: 5; true: true}>( {num: Number, str: String, bool: Boolean, _null: null, ali: 'ali', five: 5, true: true}, {num: '123', str: 'test', bool: 'false', _null: null, ali: 'ali', five: 5, true: true}, ), @@ -22,9 +18,7 @@ console.log( console.log('nested value test'); console.log( - validator< - {a: {num: number; str: string; bool: boolean; _null: null; ali: 'ali'; five: 5; true: true}} - >( + validator<{a: {num: number; str: string; bool: boolean; _null: null; ali: 'ali'; five: 5; true: true}}>( {a: {num: Number, str: String, bool: Boolean, _null: null, ali: 'ali', five: 5, true: true}}, {a: {num: '123', str: 'test', bool: 'false', _null: null, ali: 'ali', five: 5, true: true}}, ), @@ -32,14 +26,7 @@ console.log( console.log('not valid test'); try { - console.log( - validator< - {num: number} - >( - {num: Number}, - {num: 'test'}, - ), - ); + console.log(validator<{num: number}>({num: Number}, {num: 'test'})); throw new Error('validator_not_work'); } catch (err) { @@ -52,14 +39,7 @@ catch (err) { } try { - console.log( - validator< - {num: boolean} - >( - {num: Boolean}, - {num: 'true'}, - ), - ); + console.log(validator<{num: boolean}>({num: Boolean}, {num: 'true'})); throw new Error('validator_not_work'); } catch (err) { @@ -72,14 +52,7 @@ catch (err) { } try { - console.log( - validator< - {num: null} - >( - {num: null}, - {num: 'test'}, - ), - ); + console.log(validator<{num: null}>({num: null}, {num: 'test'})); throw new Error('validator_not_work'); } catch (err) { @@ -92,14 +65,7 @@ catch (err) { } try { - console.log( - validator< - {num: number} - >( - {num: Number}, - {num: 'test'}, - ), - ); + console.log(validator<{num: number}>({num: Number}, {num: 'test'})); throw new Error('validator_not_work'); } catch (err) { @@ -112,14 +78,7 @@ catch (err) { } try { - console.log( - validator< - {num: string} - >( - {num: 'test'}, - {num: 'tes'}, - ), - ); + console.log(validator<{num: string}>({num: 'test'}, {num: 'tes'})); throw new Error('validator_not_work'); } catch (err) { diff --git a/packages/crypto/CHANGELOG.md b/packages/crypto/CHANGELOG.md index 2690f2af..2bb3f792 100644 --- a/packages/crypto/CHANGELOG.md +++ b/packages/crypto/CHANGELOG.md @@ -19,21 +19,21 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline ### Features -* **crypto:** add some pre config ([4b960c5](https://github.com/AliMD/alwatr/commit/4b960c5cb3f7495c0689adcb65c62a1032ae2650)) +- **crypto:** add some pre config ([4b960c5](https://github.com/AliMD/alwatr/commit/4b960c5cb3f7495c0689adcb65c62a1032ae2650)) ### Performance Improvements -* **crypto/hash:** enhance crc generator ([ba8c4bc](https://github.com/AliMD/alwatr/commit/ba8c4bcf8f9ec9767b0bd3b6c3fd5c4f503a84dd)) +- **crypto/hash:** enhance crc generator ([ba8c4bc](https://github.com/AliMD/alwatr/commit/ba8c4bcf8f9ec9767b0bd3b6c3fd5c4f503a84dd)) # 0.31.0 (2023-05-08) ### Bug Fixes -* **crypto:** package ([866c5f4](https://github.com/AliMD/alwatr/commit/866c5f490ea2eaa75bf177f35b3f4711931e13d2)) +- **crypto:** package ([866c5f4](https://github.com/AliMD/alwatr/commit/866c5f490ea2eaa75bf177f35b3f4711931e13d2)) ### Features -* **crypto:** make prefix for userId ([5baa00a](https://github.com/AliMD/alwatr/commit/5baa00aafb16a4c6ed1d77913edddd090f732dad)) +- **crypto:** make prefix for userId ([5baa00a](https://github.com/AliMD/alwatr/commit/5baa00aafb16a4c6ed1d77913edddd090f732dad)) # [1.0.0](https://github.com/AliMD/alwatr/compare/v0.32.0...v1.0.0) (2023-06-14) diff --git a/packages/crypto/src/type.ts b/packages/crypto/src/type.ts index ed9d2ecf..af051868 100644 --- a/packages/crypto/src/type.ts +++ b/packages/crypto/src/type.ts @@ -6,7 +6,6 @@ export type CryptoEncoding = 'base64' | 'base64url' | 'hex' | 'binary'; export type TokenStatus = 'valid' | 'invalid' | 'expired'; export type HashStatus = 'valid' | 'invalid'; - export interface TokenGeneratorConfig { /** * Secret string data to generate token. diff --git a/packages/crypto/src/user.ts b/packages/crypto/src/user.ts index 7a2e18f7..0b8449f5 100644 --- a/packages/crypto/src/user.ts +++ b/packages/crypto/src/user.ts @@ -10,10 +10,7 @@ export class AlwatrUserFactory { protected _tokenGenerator; protected _hashGenerator; - constructor( - hashConfig: HashGeneratorConfig, - tokenConfig: TokenGeneratorConfig, - ) { + constructor(hashConfig: HashGeneratorConfig, tokenConfig: TokenGeneratorConfig) { this._hashGenerator = new AlwatrHashGenerator(hashConfig); this._tokenGenerator = new AlwatrTokenGenerator(tokenConfig); } diff --git a/packages/fetch/CHANGELOG.md b/packages/fetch/CHANGELOG.md index a24f2d65..173bca56 100644 --- a/packages/fetch/CHANGELOG.md +++ b/packages/fetch/CHANGELOG.md @@ -19,51 +19,51 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline ### Bug Fixes -* **fetch:** serviceRequest type ([44c1086](https://github.com/AliMD/alwatr/commit/44c10866e1c630bc3cf85b3e9be38b268b5b0c31)) -* **fetch:** userAuth in StringifyableFetchOptions ([f554b57](https://github.com/AliMD/alwatr/commit/f554b575584cb1464d48fbe8a8c4006125365853)) +- **fetch:** serviceRequest type ([44c1086](https://github.com/AliMD/alwatr/commit/44c10866e1c630bc3cf85b3e9be38b268b5b0c31)) +- **fetch:** userAuth in StringifyableFetchOptions ([f554b57](https://github.com/AliMD/alwatr/commit/f554b575584cb1464d48fbe8a8c4006125365853)) # 0.31.0 (2023-05-08) ### Bug Fixes -* **fetch.ts:** compatible with node ([c3acb53](https://github.com/AliMD/alwatr/commit/c3acb53effd4a79e389bc4de1567b0285c03d71d)) -* **fetch:** bodyJson type ([5740467](https://github.com/AliMD/alwatr/commit/57404673e7f031a73d1cf23501e6fa8d89759769)) -* **fetch:** check node_mode before use navigator.online ([a688f48](https://github.com/AliMD/alwatr/commit/a688f48e9ce4b103c25ffd50f1b8c96e89c205d1)) -* **fetch:** serviceRequest generic type ([074ef38](https://github.com/AliMD/alwatr/commit/074ef3876086f93486753559d8e3db0b60c52a0e)) -* **fetch:** suppress fetch_cache_not_found extra error ([c04f609](https://github.com/AliMD/alwatr/commit/c04f60944106dbd8d1bf2fb5ce0e7be644c3abc6)) -* new logger api ([9d83a7d](https://github.com/AliMD/alwatr/commit/9d83a7dc5c103bc3bb4282dacfd85fa998915300)) +- **fetch.ts:** compatible with node ([c3acb53](https://github.com/AliMD/alwatr/commit/c3acb53effd4a79e389bc4de1567b0285c03d71d)) +- **fetch:** bodyJson type ([5740467](https://github.com/AliMD/alwatr/commit/57404673e7f031a73d1cf23501e6fa8d89759769)) +- **fetch:** check node_mode before use navigator.online ([a688f48](https://github.com/AliMD/alwatr/commit/a688f48e9ce4b103c25ffd50f1b8c96e89c205d1)) +- **fetch:** serviceRequest generic type ([074ef38](https://github.com/AliMD/alwatr/commit/074ef3876086f93486753559d8e3db0b60c52a0e)) +- **fetch:** suppress fetch_cache_not_found extra error ([c04f609](https://github.com/AliMD/alwatr/commit/c04f60944106dbd8d1bf2fb5ce0e7be644c3abc6)) +- new logger api ([9d83a7d](https://github.com/AliMD/alwatr/commit/9d83a7dc5c103bc3bb4282dacfd85fa998915300)) ### Features -* **fetch:** add user auth ([811fbc0](https://github.com/AliMD/alwatr/commit/811fbc018c2b4e3b808704e8623bd5dff2b2f3f7)) -* **fetch:** StringifyableFetchOptions type ([e13fdb2](https://github.com/AliMD/alwatr/commit/e13fdb2550cf3a2102c331aa7980234ca6f86e08)) +- **fetch:** add user auth ([811fbc0](https://github.com/AliMD/alwatr/commit/811fbc018c2b4e3b808704e8623bd5dff2b2f3f7)) +- **fetch:** StringifyableFetchOptions type ([e13fdb2](https://github.com/AliMD/alwatr/commit/e13fdb2550cf3a2102c331aa7980234ca6f86e08)) # 0.30.0 (2023-03-06) ### Bug Fixes -* **fetch:** fetchContext duplicate setSignalValue ([8aa9b00](https://github.com/AliMD/alwatr/commit/8aa9b003a2d7b7ffc8243ff7092d9560763d7273)) -* **fetch:** getClientId in nodejs ([c99e41c](https://github.com/AliMD/alwatr/commit/c99e41c9e9a979ca50cc01aeb5371a3487d9da2e)) +- **fetch:** fetchContext duplicate setSignalValue ([8aa9b00](https://github.com/AliMD/alwatr/commit/8aa9b003a2d7b7ffc8243ff7092d9560763d7273)) +- **fetch:** getClientId in nodejs ([c99e41c](https://github.com/AliMD/alwatr/commit/c99e41c9e9a979ca50cc01aeb5371a3487d9da2e)) ### Features -* **fetch:** enhance fetchContext with dispatchOptions and only cache_only request in first time ([1f6b575](https://github.com/AliMD/alwatr/commit/1f6b575437104d64ede8a2c23d141160360d2cd5)) -* **fetch:** fetchContext ([d63d17e](https://github.com/AliMD/alwatr/commit/d63d17ecb58221159dc45a473fdd1c992d306d2b)) -* **fetch:** fetchContext skip online request when offline ([7c2b649](https://github.com/AliMD/alwatr/commit/7c2b6491f78acb961cdc0583112e3c709a177b79)) -* **fetch:** fetchContext work on background ([2e12bfd](https://github.com/AliMD/alwatr/commit/2e12bfde0a0636c30e60906c4812ec66b2d36742)) -* **fetch:** handle offline for all requests ([6a8d7b7](https://github.com/AliMD/alwatr/commit/6a8d7b7159732d834be052191935580331e36962)) +- **fetch:** enhance fetchContext with dispatchOptions and only cache_only request in first time ([1f6b575](https://github.com/AliMD/alwatr/commit/1f6b575437104d64ede8a2c23d141160360d2cd5)) +- **fetch:** fetchContext ([d63d17e](https://github.com/AliMD/alwatr/commit/d63d17ecb58221159dc45a473fdd1c992d306d2b)) +- **fetch:** fetchContext skip online request when offline ([7c2b649](https://github.com/AliMD/alwatr/commit/7c2b6491f78acb961cdc0583112e3c709a177b79)) +- **fetch:** fetchContext work on background ([2e12bfd](https://github.com/AliMD/alwatr/commit/2e12bfde0a0636c30e60906c4812ec66b2d36742)) +- **fetch:** handle offline for all requests ([6a8d7b7](https://github.com/AliMD/alwatr/commit/6a8d7b7159732d834be052191935580331e36962)) # 0.29.0 (2023-02-10) ### Bug Fixes -* **fetch:** device id to client id ([077e467](https://github.com/AliMD/alwatr/commit/077e4671d804d43c8f61a9d163d8d51d7a69134e)) -* **fetch:** headers type ([cd4b14e](https://github.com/AliMD/alwatr/commit/cd4b14e46b5090b6df8cb4f89d22b53966b9151e)) +- **fetch:** device id to client id ([077e467](https://github.com/AliMD/alwatr/commit/077e4671d804d43c8f61a9d163d8d51d7a69134e)) +- **fetch:** headers type ([cd4b14e](https://github.com/AliMD/alwatr/commit/cd4b14e46b5090b6df8cb4f89d22b53966b9151e)) ### Features -* **fetch:** add update_cache to CacheStrategy ([e1406b1](https://github.com/AliMD/alwatr/commit/e1406b12e1276de3295c47506c8102ab3f8bfa79)) -* **fetch:** clientId on service request ([9575a1d](https://github.com/AliMD/alwatr/commit/9575a1d595a0a4757581a29a66837cbe4be46ed3)) +- **fetch:** add update_cache to CacheStrategy ([e1406b1](https://github.com/AliMD/alwatr/commit/e1406b12e1276de3295c47506c8102ab3f8bfa79)) +- **fetch:** clientId on service request ([9575a1d](https://github.com/AliMD/alwatr/commit/9575a1d595a0a4757581a29a66837cbe4be46ed3)) # 0.28.0 (2023-01-20) @@ -71,36 +71,36 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline ### Bug Fixes -* review issue ([e5d192c](https://github.com/AliMD/alwatr/commit/e5d192cbee6917c2de01146cf8bd026895724ab8)) +- review issue ([e5d192c](https://github.com/AliMD/alwatr/commit/e5d192cbee6917c2de01146cf8bd026895724ab8)) ### Features -* **type:** add types ([2de3842](https://github.com/AliMD/alwatr/commit/2de384297b70b9818ec8d62ce8d31be4822d95a4)) +- **type:** add types ([2de3842](https://github.com/AliMD/alwatr/commit/2de384297b70b9818ec8d62ce8d31be4822d95a4)) # 0.26.0 (2022-12-22) ### Bug Fixes -* all import without .js ([fa739ab](https://github.com/AliMD/alwatr/commit/fa739ab23f67bae1d10bfcc146920b71377a26fc)) -* **core/fetch:** tsconfig refrences ([e6b9542](https://github.com/AliMD/alwatr/commit/e6b9542284e67b67600da4dcebd19daedb031c9c)) -* **fetch:** always call revalidateCallback ([444edc5](https://github.com/AliMD/alwatr/commit/444edc52b6dd5de5418ae8630e1f2270f0114372)) -* **fetch:** enhance handle and report errors in serviceRequest ([dbfc7ff](https://github.com/AliMD/alwatr/commit/dbfc7ff2a036216498dc8e2ff58b74b7eb8d9bc0)) -* **fetch:** fetch_cache_not_found is not error ([3d1aa4e](https://github.com/AliMD/alwatr/commit/3d1aa4e572fbf4bc7b0a527a3fdcf4c521af18dd)) -* **fetch:** fetch_failed error message ([3e98bd9](https://github.com/AliMD/alwatr/commit/3e98bd926a495c13d476f2f1cfb9e546a059d4d8)) -* **fetch:** remove extra _options ([ad24c81](https://github.com/AliMD/alwatr/commit/ad24c8104b944ebda52308e60d41976ac1eeee81)) -* **fetch:** revalidateCallback issue ([7207909](https://github.com/AliMD/alwatr/commit/72079098edb438c28256dad03d7802bc2fab0858)) -* set correct path ([d01ce6f](https://github.com/AliMD/alwatr/commit/d01ce6ffa749a5e3e0e11e35b4ed61d75d61fec9)) -* **storage-engine:** AlwatrDocumentStorage ([ca9a7bf](https://github.com/AliMD/alwatr/commit/ca9a7bf5e17b333538e749ada5d481a06c847101)) -* tsconfig ([e96dcd3](https://github.com/AliMD/alwatr/commit/e96dcd30774a9f06f7d051e0504192cbbe019e35)) -* tsconfig refrences ([cea0562](https://github.com/AliMD/alwatr/commit/cea05621ecfa499476c5b10a412e60f27ba6a06d)) +- all import without .js ([fa739ab](https://github.com/AliMD/alwatr/commit/fa739ab23f67bae1d10bfcc146920b71377a26fc)) +- **core/fetch:** tsconfig refrences ([e6b9542](https://github.com/AliMD/alwatr/commit/e6b9542284e67b67600da4dcebd19daedb031c9c)) +- **fetch:** always call revalidateCallback ([444edc5](https://github.com/AliMD/alwatr/commit/444edc52b6dd5de5418ae8630e1f2270f0114372)) +- **fetch:** enhance handle and report errors in serviceRequest ([dbfc7ff](https://github.com/AliMD/alwatr/commit/dbfc7ff2a036216498dc8e2ff58b74b7eb8d9bc0)) +- **fetch:** fetch_cache_not_found is not error ([3d1aa4e](https://github.com/AliMD/alwatr/commit/3d1aa4e572fbf4bc7b0a527a3fdcf4c521af18dd)) +- **fetch:** fetch_failed error message ([3e98bd9](https://github.com/AliMD/alwatr/commit/3e98bd926a495c13d476f2f1cfb9e546a059d4d8)) +- **fetch:** remove extra \_options ([ad24c81](https://github.com/AliMD/alwatr/commit/ad24c8104b944ebda52308e60d41976ac1eeee81)) +- **fetch:** revalidateCallback issue ([7207909](https://github.com/AliMD/alwatr/commit/72079098edb438c28256dad03d7802bc2fab0858)) +- set correct path ([d01ce6f](https://github.com/AliMD/alwatr/commit/d01ce6ffa749a5e3e0e11e35b4ed61d75d61fec9)) +- **storage-engine:** AlwatrDocumentStorage ([ca9a7bf](https://github.com/AliMD/alwatr/commit/ca9a7bf5e17b333538e749ada5d481a06c847101)) +- tsconfig ([e96dcd3](https://github.com/AliMD/alwatr/commit/e96dcd30774a9f06f7d051e0504192cbbe019e35)) +- tsconfig refrences ([cea0562](https://github.com/AliMD/alwatr/commit/cea05621ecfa499476c5b10a412e60f27ba6a06d)) ### Features -* **fetch:** add AlwatrDocumentStorage type ([44b84f0](https://github.com/AliMD/alwatr/commit/44b84f0754169a707472655811020f6e542a6e5d)) -* **fetch:** serviceRequest ([b0b5478](https://github.com/AliMD/alwatr/commit/b0b5478d16b2cb590cfc29d644006e4a459dd6d6)) -* **fetch:** serviceRequest ([#513](https://github.com/AliMD/alwatr/issues/513)) ([113ee49](https://github.com/AliMD/alwatr/commit/113ee498c778d9efc00cc4807bfef09e52336a31)) -* improve accident debugging ([d697e6c](https://github.com/AliMD/alwatr/commit/d697e6c4c7d0a4172f4dba9caf6fbd478f79de9c)) -* improve error debugging ([1fba504](https://github.com/AliMD/alwatr/commit/1fba50400a1e8ececc10bbe8ea11cc8dcea2289c)) +- **fetch:** add AlwatrDocumentStorage type ([44b84f0](https://github.com/AliMD/alwatr/commit/44b84f0754169a707472655811020f6e542a6e5d)) +- **fetch:** serviceRequest ([b0b5478](https://github.com/AliMD/alwatr/commit/b0b5478d16b2cb590cfc29d644006e4a459dd6d6)) +- **fetch:** serviceRequest ([#513](https://github.com/AliMD/alwatr/issues/513)) ([113ee49](https://github.com/AliMD/alwatr/commit/113ee498c778d9efc00cc4807bfef09e52336a31)) +- improve accident debugging ([d697e6c](https://github.com/AliMD/alwatr/commit/d697e6c4c7d0a4172f4dba9caf6fbd478f79de9c)) +- improve error debugging ([1fba504](https://github.com/AliMD/alwatr/commit/1fba50400a1e8ececc10bbe8ea11cc8dcea2289c)) # [1.0.0](https://github.com/AliMD/alwatr/compare/v0.32.0...v1.0.0) (2023-06-14) diff --git a/packages/fetch/src/fetch.ts b/packages/fetch/src/fetch.ts index acea4454..538f3452 100644 --- a/packages/fetch/src/fetch.ts +++ b/packages/fetch/src/fetch.ts @@ -67,9 +67,9 @@ export async function fetchContext( /** * Fetch from alwatr services and return standard response. */ -export async function serviceRequest< - T extends AlwatrServiceResponse = AlwatrServiceResponse ->(options: FetchOptions): Promise { +export async function serviceRequest( + options: FetchOptions, +): Promise { logger.logMethodArgs?.('serviceRequest', {url: options.url}); if (!NODE_MODE) { diff --git a/packages/logger/CHANGELOG.md b/packages/logger/CHANGELOG.md index 678fb7cc..dd9914ff 100644 --- a/packages/logger/CHANGELOG.md +++ b/packages/logger/CHANGELOG.md @@ -7,7 +7,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline ### Bug Fixes -* **logger:** change localStorage debug key to `alwatrDebug` ([66542ea](https://github.com/AliMD/alwatr/commit/66542ea22a9a515db4a15dc966624b3029f517ed)) by @AliMD +- **logger:** change localStorage debug key to `alwatrDebug` ([66542ea](https://github.com/AliMD/alwatr/commit/66542ea22a9a515db4a15dc966624b3029f517ed)) by @AliMD ## [1.1.1](https://github.com/AliMD/alwatr/compare/@alwatr/logger@1.1.0...@alwatr/logger@1.1.1) (2023-09-12) @@ -17,7 +17,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline ### Features -* **logger:** add logModule ([2e37bef](https://github.com/AliMD/alwatr/commit/2e37befd5f66094c5a521424e2a9d60796384f88)) +- **logger:** add logModule ([2e37bef](https://github.com/AliMD/alwatr/commit/2e37befd5f66094c5a521424e2a9d60796384f88)) # 1.0.0 (2023-06-14) @@ -27,21 +27,21 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline ### Bug Fixes -* **logger:** logMethod args type ([66338b7](https://github.com/AliMD/alwatr/commit/66338b7ba1d4b15af78f9f604f7be0a7e483413d)) -* **logger:** logMethod args type ([1983b3d](https://github.com/AliMD/alwatr/commit/1983b3d2fe260226ca2660e33b9bd924facdf776)) -* new logger api ([9d83a7d](https://github.com/AliMD/alwatr/commit/9d83a7dc5c103bc3bb4282dacfd85fa998915300)) +- **logger:** logMethod args type ([66338b7](https://github.com/AliMD/alwatr/commit/66338b7ba1d4b15af78f9f604f7be0a7e483413d)) +- **logger:** logMethod args type ([1983b3d](https://github.com/AliMD/alwatr/commit/1983b3d2fe260226ca2660e33b9bd924facdf776)) +- new logger api ([9d83a7d](https://github.com/AliMD/alwatr/commit/9d83a7dc5c103bc3bb4282dacfd85fa998915300)) ### Features -* **logger:** add `duration time` to logger time label ([ef188c4](https://github.com/AliMD/alwatr/commit/ef188c41a02789e1b35ab424bab24a393a03a3b0)) -* **logger:** add `time` & `timeEnd` ([0bd4ec5](https://github.com/AliMD/alwatr/commit/0bd4ec5dbd185b17cfb8656a84a782e848ade138)) -* **logger:** optional devMode per package ([cc1eb87](https://github.com/AliMD/alwatr/commit/cc1eb879832807d55ad4cf268a54b2d5e4346fff)) +- **logger:** add `duration time` to logger time label ([ef188c4](https://github.com/AliMD/alwatr/commit/ef188c41a02789e1b35ab424bab24a393a03a3b0)) +- **logger:** add `time` & `timeEnd` ([0bd4ec5](https://github.com/AliMD/alwatr/commit/0bd4ec5dbd185b17cfb8656a84a782e848ade138)) +- **logger:** optional devMode per package ([cc1eb87](https://github.com/AliMD/alwatr/commit/cc1eb879832807d55ad4cf268a54b2d5e4346fff)) # 0.30.0 (2023-03-06) ### Features -* **logger:** export isBrowser ([5b5be8b](https://github.com/AliMD/alwatr/commit/5b5be8b2312ca67f186d1614506423f1fdb90877)) +- **logger:** export isBrowser ([5b5be8b](https://github.com/AliMD/alwatr/commit/5b5be8b2312ca67f186d1614506423f1fdb90877)) # 0.29.0 (2023-02-10) @@ -49,30 +49,30 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline ### Bug Fixes -* **logger:** _ALWATR_VERSION_ ([9cf8f20](https://github.com/AliMD/alwatr/commit/9cf8f208e8adbfa2e2c622a8465453d5554cbd37)) +- **logger:** _ALWATR_VERSION_ ([9cf8f20](https://github.com/AliMD/alwatr/commit/9cf8f208e8adbfa2e2c622a8465453d5554cbd37)) # 0.27.0 (2022-12-29) ### Bug Fixes -* **logger:** version ([2295fee](https://github.com/AliMD/alwatr/commit/2295fee74e8eebd9db399129de31f2b0d6d6b168)) +- **logger:** version ([2295fee](https://github.com/AliMD/alwatr/commit/2295fee74e8eebd9db399129de31f2b0d6d6b168)) ### Features -* **type:** define alwatrRegistredList ([25406c2](https://github.com/AliMD/alwatr/commit/25406c268f39cf3e055ea05c9fc7b50bd3dd0a17)) +- **type:** define alwatrRegistredList ([25406c2](https://github.com/AliMD/alwatr/commit/25406c268f39cf3e055ea05c9fc7b50bd3dd0a17)) # 0.26.0 (2022-12-22) ### Bug Fixes -* set correct path ([d01ce6f](https://github.com/AliMD/alwatr/commit/d01ce6ffa749a5e3e0e11e35b4ed61d75d61fec9)) -* tsconfig ([e96dcd3](https://github.com/AliMD/alwatr/commit/e96dcd30774a9f06f7d051e0504192cbbe019e35)) +- set correct path ([d01ce6f](https://github.com/AliMD/alwatr/commit/d01ce6ffa749a5e3e0e11e35b4ed61d75d61fec9)) +- tsconfig ([e96dcd3](https://github.com/AliMD/alwatr/commit/e96dcd30774a9f06f7d051e0504192cbbe019e35)) ### Features -* improve error debugging ([1fba504](https://github.com/AliMD/alwatr/commit/1fba50400a1e8ececc10bbe8ea11cc8dcea2289c)) -* **logger:** add root version ([2ac01c1](https://github.com/AliMD/alwatr/commit/2ac01c1d12323a6c8591b3dd4826d08a55647dc1)) -* **logger:** move incident to deployment mode ([4ee8dac](https://github.com/AliMD/alwatr/commit/4ee8dac5c54ce8a897382d3d4fb5bb852d24cf24)) +- improve error debugging ([1fba504](https://github.com/AliMD/alwatr/commit/1fba50400a1e8ececc10bbe8ea11cc8dcea2289c)) +- **logger:** add root version ([2ac01c1](https://github.com/AliMD/alwatr/commit/2ac01c1d12323a6c8591b3dd4826d08a55647dc1)) +- **logger:** move incident to deployment mode ([4ee8dac](https://github.com/AliMD/alwatr/commit/4ee8dac5c54ce8a897382d3d4fb5bb852d24cf24)) # [1.0.0](https://github.com/AliMD/alwatr/compare/v0.32.0...v1.0.0) (2023-06-14) diff --git a/packages/math/CHANGELOG.md b/packages/math/CHANGELOG.md index a95de32d..07807367 100644 --- a/packages/math/CHANGELOG.md +++ b/packages/math/CHANGELOG.md @@ -21,60 +21,60 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline ### Features -* **math:** simpleHashNumber ([dffb285](https://github.com/AliMD/alwatr/commit/dffb285e11cd9652d54d2d22956fc22177d16699)) +- **math:** simpleHashNumber ([dffb285](https://github.com/AliMD/alwatr/commit/dffb285e11cd9652d54d2d22956fc22177d16699)) # 0.30.0 (2023-03-06) ### Bug Fixes -* **math:** remove getClientId ([b5894d6](https://github.com/AliMD/alwatr/commit/b5894d6cf75798d35773dcc048e9dd21fa44199d)) +- **math:** remove getClientId ([b5894d6](https://github.com/AliMD/alwatr/commit/b5894d6cf75798d35773dcc048e9dd21fa44199d)) ### Features -* **math:** calcDiscount ([ac7c18b](https://github.com/AliMD/alwatr/commit/ac7c18bc0f0e008b8db9fd4b69451a89e7fb069b)) +- **math:** calcDiscount ([ac7c18b](https://github.com/AliMD/alwatr/commit/ac7c18bc0f0e008b8db9fd4b69451a89e7fb069b)) # 0.29.0 (2023-02-10) ### Bug Fixes -* **typescript:** rollback to 4.9.5 ([cc30f85](https://github.com/AliMD/alwatr/commit/cc30f8502bf95868ff41ba986120b2842acba36b)) +- **typescript:** rollback to 4.9.5 ([cc30f85](https://github.com/AliMD/alwatr/commit/cc30f8502bf95868ff41ba986120b2842acba36b)) ### Features -* **i18n:** add replaceNumber and auto detect setLocale from html ([3413471](https://github.com/AliMD/alwatr/commit/341347149f8685bc259034f5593048aa7db0b927)) -* **math:** clamp function ([6fe4423](https://github.com/AliMD/alwatr/commit/6fe44236fc123a32837cfb4ea278b783f2bc2e7a)) -* **math:** getDeviceUuid ([946dad3](https://github.com/AliMD/alwatr/commit/946dad3544f2741462ff239edab8b4a9ea323bd6)) -* **math:** random uuid ([738f51e](https://github.com/AliMD/alwatr/commit/738f51eb323100fafca0a5f515b48d215dae5b3c)) -* **math:** rename deviceId to clientId ([b211fd4](https://github.com/AliMD/alwatr/commit/b211fd42245d51d7109186ddb2f41574d0f0b786)) +- **i18n:** add replaceNumber and auto detect setLocale from html ([3413471](https://github.com/AliMD/alwatr/commit/341347149f8685bc259034f5593048aa7db0b927)) +- **math:** clamp function ([6fe4423](https://github.com/AliMD/alwatr/commit/6fe44236fc123a32837cfb4ea278b783f2bc2e7a)) +- **math:** getDeviceUuid ([946dad3](https://github.com/AliMD/alwatr/commit/946dad3544f2741462ff239edab8b4a9ea323bd6)) +- **math:** random uuid ([738f51e](https://github.com/AliMD/alwatr/commit/738f51eb323100fafca0a5f515b48d215dae5b3c)) +- **math:** rename deviceId to clientId ([b211fd4](https://github.com/AliMD/alwatr/commit/b211fd42245d51d7109186ddb2f41574d0f0b786)) ### Performance Improvements -* **math:** enhance getClientId ([3187039](https://github.com/AliMD/alwatr/commit/3187039a9b87472bda16af6d4b0b71e31c17f272)) -* **math:** enhance getClientId ([af42959](https://github.com/AliMD/alwatr/commit/af429594950c7ded35af53414494dd2f6f4fe208)) -* **unicode-digits:** enhance translate ([104bdba](https://github.com/AliMD/alwatr/commit/104bdba948df11e62577f084b1e51fc4c78e0d9c)) +- **math:** enhance getClientId ([3187039](https://github.com/AliMD/alwatr/commit/3187039a9b87472bda16af6d4b0b71e31c17f272)) +- **math:** enhance getClientId ([af42959](https://github.com/AliMD/alwatr/commit/af429594950c7ded35af53414494dd2f6f4fe208)) +- **unicode-digits:** enhance translate ([104bdba](https://github.com/AliMD/alwatr/commit/104bdba948df11e62577f084b1e51fc4c78e0d9c)) # 0.28.0 (2023-01-20) ### Bug Fixes -* **type:** revert paramkey ([f1ad066](https://github.com/AliMD/alwatr/commit/f1ad06621f7fe80018573e50804e9f3c1b2edde1)) +- **type:** revert paramkey ([f1ad066](https://github.com/AliMD/alwatr/commit/f1ad06621f7fe80018573e50804e9f3c1b2edde1)) ### Features -* **type:** add optional text on ChatPhotoMessage ([af83f5b](https://github.com/AliMD/alwatr/commit/af83f5b8604cecd3c9b0cb2375267458fd02431d)) +- **type:** add optional text on ChatPhotoMessage ([af83f5b](https://github.com/AliMD/alwatr/commit/af83f5b8604cecd3c9b0cb2375267458fd02431d)) # 0.27.0 (2022-12-29) ### Features -* **type:** define math types ([8c19f40](https://github.com/AliMD/alwatr/commit/8c19f4058d4361b7d3f4f714595e34cb6fa21109)) +- **type:** define math types ([8c19f40](https://github.com/AliMD/alwatr/commit/8c19f4058d4361b7d3f4f714595e34cb6fa21109)) # 0.26.0 (2022-12-22) ### Bug Fixes -* set correct path ([d01ce6f](https://github.com/AliMD/alwatr/commit/d01ce6ffa749a5e3e0e11e35b4ed61d75d61fec9)) -* tsconfig ([e96dcd3](https://github.com/AliMD/alwatr/commit/e96dcd30774a9f06f7d051e0504192cbbe019e35)) +- set correct path ([d01ce6f](https://github.com/AliMD/alwatr/commit/d01ce6ffa749a5e3e0e11e35b4ed61d75d61fec9)) +- tsconfig ([e96dcd3](https://github.com/AliMD/alwatr/commit/e96dcd30774a9f06f7d051e0504192cbbe019e35)) # [1.0.0](https://github.com/AliMD/alwatr/compare/v0.32.0...v1.0.0) (2023-06-14) diff --git a/packages/math/src/math.ts b/packages/math/src/math.ts index 902e7052..0fb216b6 100644 --- a/packages/math/src/math.ts +++ b/packages/math/src/math.ts @@ -255,7 +255,7 @@ export const hex = (bytes: Uint8Array): string => { export const calcDiscount = (marketPrice: number, salePrice: number, decimal = 2, upSide = true): number => { decimal = Math.pow(10, decimal); - return Math.round((marketPrice - salePrice) / (upSide ? salePrice : marketPrice) * 100 * decimal) / decimal; + return Math.round(((marketPrice - salePrice) / (upSide ? salePrice : marketPrice)) * 100 * decimal) / decimal; }; export const simpleHashNumber = (num: number): string => { diff --git a/packages/math/src/unicode-digits.ts b/packages/math/src/unicode-digits.ts index 29bf9ed3..aa0b6a34 100644 --- a/packages/math/src/unicode-digits.ts +++ b/packages/math/src/unicode-digits.ts @@ -60,7 +60,6 @@ const supportedLanguageList = { 'fula': 0x1e950, // adlam script in fula lang } as const; - export type UnicodeLangKeys = keyof typeof supportedLanguageList; const commonLangList: UnicodeLangKeys[] = ['en', 'fa', 'ar']; diff --git a/packages/nano-server/CHANGELOG.md b/packages/nano-server/CHANGELOG.md index b857b28d..3e96f6b4 100644 --- a/packages/nano-server/CHANGELOG.md +++ b/packages/nano-server/CHANGELOG.md @@ -19,75 +19,75 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline ### Bug Fixes -* **nano-server:** `data` type ([f629f3b](https://github.com/AliMD/alwatr/commit/f629f3b7952b775ead78119c699ce93c119b8164)) +- **nano-server:** `data` type ([f629f3b](https://github.com/AliMD/alwatr/commit/f629f3b7952b775ead78119c699ce93c119b8164)) # 0.31.0 (2023-05-08) ### Bug Fixes -* **nano-server:** path prefix ([83995f7](https://github.com/AliMD/alwatr/commit/83995f7bc9748ecb632d6f8dbea5e2f96fa59c41)) -* **nano-server:** prefixPattern, logger ([f9d203e](https://github.com/AliMD/alwatr/commit/f9d203e65955629f6dd5c468867f20ce578337eb)) -* new logger api ([9d83a7d](https://github.com/AliMD/alwatr/commit/9d83a7dc5c103bc3bb4282dacfd85fa998915300)) +- **nano-server:** path prefix ([83995f7](https://github.com/AliMD/alwatr/commit/83995f7bc9748ecb632d6f8dbea5e2f96fa59c41)) +- **nano-server:** prefixPattern, logger ([f9d203e](https://github.com/AliMD/alwatr/commit/f9d203e65955629f6dd5c468867f20ce578337eb)) +- new logger api ([9d83a7d](https://github.com/AliMD/alwatr/commit/9d83a7dc5c103bc3bb4282dacfd85fa998915300)) ### Features -* **nano-server:** add getUserAuth ([615266f](https://github.com/AliMD/alwatr/commit/615266f06ef47a7a5b36fe3d6abee1653703bf6f)) -* **nano-server:** prefix pattern ([ad5e1b5](https://github.com/AliMD/alwatr/commit/ad5e1b56651c96cb825187604f877fee396b3ec4)) +- **nano-server:** add getUserAuth ([615266f](https://github.com/AliMD/alwatr/commit/615266f06ef47a7a5b36fe3d6abee1653703bf6f)) +- **nano-server:** prefix pattern ([ad5e1b5](https://github.com/AliMD/alwatr/commit/ad5e1b56651c96cb825187604f877fee396b3ec4)) # 0.30.0 (2023-03-06) ### Features -* **nano-server:** getRemoteAddress ([eff82cb](https://github.com/AliMD/alwatr/commit/eff82cbdba5a35a88d95f6997365210683163d62)) -* **nano-server:** requireClientId ([fccd734](https://github.com/AliMD/alwatr/commit/fccd734f0c08cc624492b30e14c451143706cc00)) +- **nano-server:** getRemoteAddress ([eff82cb](https://github.com/AliMD/alwatr/commit/eff82cbdba5a35a88d95f6997365210683163d62)) +- **nano-server:** requireClientId ([fccd734](https://github.com/AliMD/alwatr/commit/fccd734f0c08cc624492b30e14c451143706cc00)) # 0.29.0 (2023-02-10) ### Bug Fixes -* **nano-server:** compatible with ParamValueType ([325d896](https://github.com/AliMD/alwatr/commit/325d89651aeba38079d6fb9184adb894df94f083)) -* **nano-server:** null parsedParams ([bb969b2](https://github.com/AliMD/alwatr/commit/bb969b23495f791003225b5c557e40e10e7f8124)) -* **nano-server:** type ([2586061](https://github.com/AliMD/alwatr/commit/25860611f765e67ecddd586d80169ebe7f75701b)) +- **nano-server:** compatible with ParamValueType ([325d896](https://github.com/AliMD/alwatr/commit/325d89651aeba38079d6fb9184adb894df94f083)) +- **nano-server:** null parsedParams ([bb969b2](https://github.com/AliMD/alwatr/commit/bb969b23495f791003225b5c557e40e10e7f8124)) +- **nano-server:** type ([2586061](https://github.com/AliMD/alwatr/commit/25860611f765e67ecddd586d80169ebe7f75701b)) ### Features -* **nano-server:** add client-id to IncomingHttpHeaders type ([a4a86c7](https://github.com/AliMD/alwatr/commit/a4a86c7e410edfe69e66cdab6b8ffdc0d9b95eb8)) -* **nano-service:** api prefix support ([21960dc](https://github.com/AliMD/alwatr/commit/21960dce5f25a587b19886e487f7d46af5ca087b)) +- **nano-server:** add client-id to IncomingHttpHeaders type ([a4a86c7](https://github.com/AliMD/alwatr/commit/a4a86c7e410edfe69e66cdab6b8ffdc0d9b95eb8)) +- **nano-service:** api prefix support ([21960dc](https://github.com/AliMD/alwatr/commit/21960dce5f25a587b19886e487f7d46af5ca087b)) # 0.28.0 (2023-01-20) ### Bug Fixes -* **nano-server:** math references ([e46071a](https://github.com/AliMD/alwatr/commit/e46071a49bb61cb6f36d2e79e14c32712f3746fa)) -* **type:** revert paramkey ([f1ad066](https://github.com/AliMD/alwatr/commit/f1ad06621f7fe80018573e50804e9f3c1b2edde1)) +- **nano-server:** math references ([e46071a](https://github.com/AliMD/alwatr/commit/e46071a49bb61cb6f36d2e79e14c32712f3746fa)) +- **type:** revert paramkey ([f1ad066](https://github.com/AliMD/alwatr/commit/f1ad06621f7fe80018573e50804e9f3c1b2edde1)) # 0.27.0 (2022-12-29) ### Bug Fixes -* review issue ([e5d192c](https://github.com/AliMD/alwatr/commit/e5d192cbee6917c2de01146cf8bd026895724ab8)) +- review issue ([e5d192c](https://github.com/AliMD/alwatr/commit/e5d192cbee6917c2de01146cf8bd026895724ab8)) # 0.26.0 (2022-12-22) ### Bug Fixes -* inline home route ([ce978f6](https://github.com/AliMD/alwatr/commit/ce978f6e1e2890e853d0db351c08efca665e5fad)) -* **nano-server:** check method on getBody ([9aa9857](https://github.com/AliMD/alwatr/commit/9aa9857fb6ad96f861f31c651bf131813e46b343)) -* **nano-server:** handle utf8 reply issue ([33aa238](https://github.com/AliMD/alwatr/commit/33aa238d99f92c03a5b39e829cb39172dc45d5c6)) -* **nano-server:** remove return null on requireToken ([3c6779f](https://github.com/AliMD/alwatr/commit/3c6779f6b114aa1afe71e9b2054fb6dbe273c26a)) -* **nano-server:** route generic ([94e181b](https://github.com/AliMD/alwatr/commit/94e181ba1172399ac992af6dc969c56e4edffbf0)) -* **nano-server:** update docs and return type ([df949c1](https://github.com/AliMD/alwatr/commit/df949c19ea75921ab9c3e7323dc33ef340bd3ee7)) -* set correct path ([d01ce6f](https://github.com/AliMD/alwatr/commit/d01ce6ffa749a5e3e0e11e35b4ed61d75d61fec9)) -* tsconfig ([e96dcd3](https://github.com/AliMD/alwatr/commit/e96dcd30774a9f06f7d051e0504192cbbe019e35)) +- inline home route ([ce978f6](https://github.com/AliMD/alwatr/commit/ce978f6e1e2890e853d0db351c08efca665e5fad)) +- **nano-server:** check method on getBody ([9aa9857](https://github.com/AliMD/alwatr/commit/9aa9857fb6ad96f861f31c651bf131813e46b343)) +- **nano-server:** handle utf8 reply issue ([33aa238](https://github.com/AliMD/alwatr/commit/33aa238d99f92c03a5b39e829cb39172dc45d5c6)) +- **nano-server:** remove return null on requireToken ([3c6779f](https://github.com/AliMD/alwatr/commit/3c6779f6b114aa1afe71e9b2054fb6dbe273c26a)) +- **nano-server:** route generic ([94e181b](https://github.com/AliMD/alwatr/commit/94e181ba1172399ac992af6dc969c56e4edffbf0)) +- **nano-server:** update docs and return type ([df949c1](https://github.com/AliMD/alwatr/commit/df949c19ea75921ab9c3e7323dc33ef340bd3ee7)) +- set correct path ([d01ce6f](https://github.com/AliMD/alwatr/commit/d01ce6ffa749a5e3e0e11e35b4ed61d75d61fec9)) +- tsconfig ([e96dcd3](https://github.com/AliMD/alwatr/commit/e96dcd30774a9f06f7d051e0504192cbbe019e35)) ### Features -* improve accident debugging ([d697e6c](https://github.com/AliMD/alwatr/commit/d697e6c4c7d0a4172f4dba9caf6fbd478f79de9c)) -* improve error debugging ([1fba504](https://github.com/AliMD/alwatr/commit/1fba50400a1e8ececc10bbe8ea11cc8dcea2289c)) -* **nano-server:** clear debug info from client for security reasons. ([5814af2](https://github.com/AliMD/alwatr/commit/5814af2ceeac6e2175c4ab924e4b40cef765072c)) -* **nano-server:** maybe promise type ([d782761](https://github.com/AliMD/alwatr/commit/d7827616ea71b7e6328c6a85b80c2daec0b6f512)) -* **nano-server:** reply throw on route ([083dfa5](https://github.com/AliMD/alwatr/commit/083dfa51b391dc689d1d4fed9f1f17d768e7384c)) -* **nano-server:** routeMiddleware type ([a05b1a2](https://github.com/AliMD/alwatr/commit/a05b1a2bc79aeca67a81f4758f5d2b0f6c890028)) +- improve accident debugging ([d697e6c](https://github.com/AliMD/alwatr/commit/d697e6c4c7d0a4172f4dba9caf6fbd478f79de9c)) +- improve error debugging ([1fba504](https://github.com/AliMD/alwatr/commit/1fba50400a1e8ececc10bbe8ea11cc8dcea2289c)) +- **nano-server:** clear debug info from client for security reasons. ([5814af2](https://github.com/AliMD/alwatr/commit/5814af2ceeac6e2175c4ab924e4b40cef765072c)) +- **nano-server:** maybe promise type ([d782761](https://github.com/AliMD/alwatr/commit/d7827616ea71b7e6328c6a85b80c2daec0b6f512)) +- **nano-server:** reply throw on route ([083dfa5](https://github.com/AliMD/alwatr/commit/083dfa51b391dc689d1d4fed9f1f17d768e7384c)) +- **nano-server:** routeMiddleware type ([a05b1a2](https://github.com/AliMD/alwatr/commit/a05b1a2bc79aeca67a81f4758f5d2b0f6c890028)) # [1.0.0](https://github.com/AliMD/alwatr/compare/v0.32.0...v1.0.0) (2023-06-14) diff --git a/packages/nano-server/src/nano-server.ts b/packages/nano-server/src/nano-server.ts index 04c86396..d4c9e9f6 100644 --- a/packages/nano-server/src/nano-server.ts +++ b/packages/nano-server/src/nano-server.ts @@ -24,7 +24,7 @@ import type {Duplex} from 'node:stream'; export type RouteMiddleware< TData extends Stringifyable = Stringifyable, - TMeta extends StringifyableRecord = StringifyableRecord + TMeta extends StringifyableRecord = StringifyableRecord, > = (connection: AlwatrConnection) => MaybePromise | null>; export type { @@ -152,10 +152,11 @@ export class AlwatrNanoServer { * }; * ``` */ - route< - TData extends Stringifyable = Stringifyable, - TMeta extends StringifyableRecord = StringifyableRecord - >(method: 'ALL' | Methods, route: 'all' | `/${string}`, middleware: RouteMiddleware): void { + route( + method: 'ALL' | Methods, + route: 'all' | `/${string}`, + middleware: RouteMiddleware, + ): void { this._logger.logMethodArgs?.('route', {method, route}); if (this.middlewareList[method] == null) this.middlewareList[method] = {}; @@ -187,10 +188,7 @@ export class AlwatrNanoServer { * }); * ``` */ - reply( - serverResponse: ServerResponse, - content: AlwatrServiceResponse, - ): void { + reply(serverResponse: ServerResponse, content: AlwatrServiceResponse): void { content.statusCode ??= 200; this._logger.logMethodArgs?.('reply', {ok: content.ok, statusCode: content.statusCode}); @@ -618,6 +616,7 @@ export class AlwatrConnection { } getRemoteAddress(): string { + // prettier-ignore return ( this.incomingMessage.headers['x-forwarded-for'] ?.split(',') diff --git a/packages/nano-server/tsconfig.json b/packages/nano-server/tsconfig.json index 1181543f..86baa770 100644 --- a/packages/nano-server/tsconfig.json +++ b/packages/nano-server/tsconfig.json @@ -9,9 +9,5 @@ "include": ["src/**/*.ts"], "exclude": [], - "references": [ - {"path": "../logger"}, - {"path": "../math"}, - {"path": "../type"}, - ] + "references": [{"path": "../logger"}, {"path": "../math"}, {"path": "../type"}] } diff --git a/packages/type/CHANGELOG.md b/packages/type/CHANGELOG.md index dc80b3b6..c6f2d765 100644 --- a/packages/type/CHANGELOG.md +++ b/packages/type/CHANGELOG.md @@ -13,125 +13,125 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline ### Bug Fixes -* **type/photo:** make meta optional ([5cea716](https://github.com/AliMD/alwatr/commit/5cea716d77bfe4db57c8f25307c4ee18862bb716)) +- **type/photo:** make meta optional ([5cea716](https://github.com/AliMD/alwatr/commit/5cea716d77bfe4db57c8f25307c4ee18862bb716)) # 0.32.0 (2023-05-27) ### Bug Fixes -* **com-api:** user-list-inc-order permission ([91beb27](https://github.com/AliMD/alwatr/commit/91beb27cbe372e6b66c99928e26fa4679b751c23)) -* **fetch:** userAuth in StringifyableFetchOptions ([f554b57](https://github.com/AliMD/alwatr/commit/f554b575584cb1464d48fbe8a8c4006125365853)) -* **type/com:** orderInfoSchema ([b90d872](https://github.com/AliMD/alwatr/commit/b90d87268429fc802fb9966fd6efd43912bc851a)) -* **type:** `data` type ([0601384](https://github.com/AliMD/alwatr/commit/06013843612fb2400d664a4dd084f70278a5eaa4)) -* **type:** `orderInfoSchema` ([47ca524](https://github.com/AliMD/alwatr/commit/47ca5243f6de3c966c3fb3bd10256134d100e4e9)) +- **com-api:** user-list-inc-order permission ([91beb27](https://github.com/AliMD/alwatr/commit/91beb27cbe372e6b66c99928e26fa4679b751c23)) +- **fetch:** userAuth in StringifyableFetchOptions ([f554b57](https://github.com/AliMD/alwatr/commit/f554b575584cb1464d48fbe8a8c4006125365853)) +- **type/com:** orderInfoSchema ([b90d872](https://github.com/AliMD/alwatr/commit/b90d87268429fc802fb9966fd6efd43912bc851a)) +- **type:** `data` type ([0601384](https://github.com/AliMD/alwatr/commit/06013843612fb2400d664a4dd084f70278a5eaa4)) +- **type:** `orderInfoSchema` ([47ca524](https://github.com/AliMD/alwatr/commit/47ca5243f6de3c966c3fb3bd10256134d100e4e9)) ### Features -* **com-pwa:** car count ([d2ea9c1](https://github.com/AliMD/alwatr/commit/d2ea9c12863d214afe5daa7d07997175c19ca859)) -* **type/com:** ComUserIncOrder ([8ddf5bf](https://github.com/AliMD/alwatr/commit/8ddf5bf0b75b601582751f017f293a26c74b1815)) -* **type/com:** rewrite ([1829673](https://github.com/AliMD/alwatr/commit/1829673cf63746d4356aaa3673aefc001b042258)) -* **type/user:** add token! ([de23795](https://github.com/AliMD/alwatr/commit/de237957a7a045c1998cf43b585125027fad5d7d)) -* **type:** add `priceListName` to `ComUser` ([b22555e](https://github.com/AliMD/alwatr/commit/b22555ebe508cc0d732e6af0e1bbf99f99eaca16)) -* **type:** user permissions ([e3d7091](https://github.com/AliMD/alwatr/commit/e3d70916fb7e93f8daf51a8c4aaf856f109b01be)) -* **type:** user permissions ([6bb0aac](https://github.com/AliMD/alwatr/commit/6bb0aacb991e11a930a30dc9071a5de0edf77368)) +- **com-pwa:** car count ([d2ea9c1](https://github.com/AliMD/alwatr/commit/d2ea9c12863d214afe5daa7d07997175c19ca859)) +- **type/com:** ComUserIncOrder ([8ddf5bf](https://github.com/AliMD/alwatr/commit/8ddf5bf0b75b601582751f017f293a26c74b1815)) +- **type/com:** rewrite ([1829673](https://github.com/AliMD/alwatr/commit/1829673cf63746d4356aaa3673aefc001b042258)) +- **type/user:** add token! ([de23795](https://github.com/AliMD/alwatr/commit/de237957a7a045c1998cf43b585125027fad5d7d)) +- **type:** add `priceListName` to `ComUser` ([b22555e](https://github.com/AliMD/alwatr/commit/b22555ebe508cc0d732e6af0e1bbf99f99eaca16)) +- **type:** user permissions ([e3d7091](https://github.com/AliMD/alwatr/commit/e3d70916fb7e93f8daf51a8c4aaf856f109b01be)) +- **type:** user permissions ([6bb0aac](https://github.com/AliMD/alwatr/commit/6bb0aacb991e11a930a30dc9071a5de0edf77368)) # 0.31.0 (2023-05-08) ### Bug Fixes -* **com-pwa/new-order:** debugging ([9027eb0](https://github.com/AliMD/alwatr/commit/9027eb013e6803b1f77dc7cbf4cc14704f49557d)) -* **type/service-response:** default generics ([04dfe54](https://github.com/AliMD/alwatr/commit/04dfe549c272878756544481f0a0d301d6e3c228)) -* **type:** fix `ComUser` ([670660f](https://github.com/AliMD/alwatr/commit/670660fb3b18e63ad54d22a76297b982c77533be)) -* **type:** Stringifyable ([058381b](https://github.com/AliMD/alwatr/commit/058381b50641ba44f4ac60e2173b5b91449e58cd)) -* **validator:** array support ([08f5215](https://github.com/AliMD/alwatr/commit/08f521534a0e937e5cf0f92bf5ca274838f41f93)) +- **com-pwa/new-order:** debugging ([9027eb0](https://github.com/AliMD/alwatr/commit/9027eb013e6803b1f77dc7cbf4cc14704f49557d)) +- **type/service-response:** default generics ([04dfe54](https://github.com/AliMD/alwatr/commit/04dfe549c272878756544481f0a0d301d6e3c228)) +- **type:** fix `ComUser` ([670660f](https://github.com/AliMD/alwatr/commit/670660fb3b18e63ad54d22a76297b982c77533be)) +- **type:** Stringifyable ([058381b](https://github.com/AliMD/alwatr/commit/058381b50641ba44f4ac60e2173b5b91449e58cd)) +- **validator:** array support ([08f5215](https://github.com/AliMD/alwatr/commit/08f521534a0e937e5cf0f92bf5ca274838f41f93)) ### Features -* **com-pwa:** `sing-in` process ([407e9c6](https://github.com/AliMD/alwatr/commit/407e9c640899efdd2bc4633bb966665c6f9b00be)) -* **com-pwa:** change order_shipping_car i18n key ([b8f7daa](https://github.com/AliMD/alwatr/commit/b8f7daa2622506d45e85274db38dbe20a2518f1f)) -* **com-pwa:** validate shipping form and item list before enable submit ([9af59d7](https://github.com/AliMD/alwatr/commit/9af59d72a2678249776d738ea79e4f248a442c5c)) -* **type/com:** ComUser/permissions ([a962366](https://github.com/AliMD/alwatr/commit/a9623669a83f1cce0f96428d5c2d126ad3e5984b)) -* **type/com:** order schema ([d1aacdb](https://github.com/AliMD/alwatr/commit/d1aacdb56cb9995bc05d54bb78bc67e3f629e12c)) -* **type/com:** qtyStep const ([3c928d4](https://github.com/AliMD/alwatr/commit/3c928d406859c85cf939827ece98db6fc39ff914)) -* **type:** ArrayItems ([4f20d8a](https://github.com/AliMD/alwatr/commit/4f20d8ab312787d3073a43594e813bcddeb99aeb)) -* **type:** MaybeArray ([0c61708](https://github.com/AliMD/alwatr/commit/0c6170890faad306a052c3d8242df21f780ef1c3)) -* **type:** SingleOrArray, Prop, Values, Merge ([c3d2a86](https://github.com/AliMD/alwatr/commit/c3d2a8669f4ae83abeb69a1cfef51ecc23c76a10)) -* **type:** user permissions ([aff0853](https://github.com/AliMD/alwatr/commit/aff08538d183e3f6b2d637e56fe2f2281c4da768)) -* **type:** UserAuth ([c902144](https://github.com/AliMD/alwatr/commit/c9021444743c5a0a5a333688830cd0a7dd7d9867)) +- **com-pwa:** `sing-in` process ([407e9c6](https://github.com/AliMD/alwatr/commit/407e9c640899efdd2bc4633bb966665c6f9b00be)) +- **com-pwa:** change order_shipping_car i18n key ([b8f7daa](https://github.com/AliMD/alwatr/commit/b8f7daa2622506d45e85274db38dbe20a2518f1f)) +- **com-pwa:** validate shipping form and item list before enable submit ([9af59d7](https://github.com/AliMD/alwatr/commit/9af59d72a2678249776d738ea79e4f248a442c5c)) +- **type/com:** ComUser/permissions ([a962366](https://github.com/AliMD/alwatr/commit/a9623669a83f1cce0f96428d5c2d126ad3e5984b)) +- **type/com:** order schema ([d1aacdb](https://github.com/AliMD/alwatr/commit/d1aacdb56cb9995bc05d54bb78bc67e3f629e12c)) +- **type/com:** qtyStep const ([3c928d4](https://github.com/AliMD/alwatr/commit/3c928d406859c85cf939827ece98db6fc39ff914)) +- **type:** ArrayItems ([4f20d8a](https://github.com/AliMD/alwatr/commit/4f20d8ab312787d3073a43594e813bcddeb99aeb)) +- **type:** MaybeArray ([0c61708](https://github.com/AliMD/alwatr/commit/0c6170890faad306a052c3d8242df21f780ef1c3)) +- **type:** SingleOrArray, Prop, Values, Merge ([c3d2a86](https://github.com/AliMD/alwatr/commit/c3d2a8669f4ae83abeb69a1cfef51ecc23c76a10)) +- **type:** user permissions ([aff0853](https://github.com/AliMD/alwatr/commit/aff08538d183e3f6b2d637e56fe2f2281c4da768)) +- **type:** UserAuth ([c902144](https://github.com/AliMD/alwatr/commit/c9021444743c5a0a5a333688830cd0a7dd7d9867)) # 0.30.0 (2023-03-06) ### Bug Fixes -* **type:** com orderStatusCS ([b789640](https://github.com/AliMD/alwatr/commit/b789640b01165e403e9e12a014c9c777b61689b7)) -* **type:** export user and photo ([27e352e](https://github.com/AliMD/alwatr/commit/27e352e231aed966d4d049cc2f1f93781f386952)) +- **type:** com orderStatusCS ([b789640](https://github.com/AliMD/alwatr/commit/b789640b01165e403e9e12a014c9c777b61689b7)) +- **type:** export user and photo ([27e352e](https://github.com/AliMD/alwatr/commit/27e352e231aed966d4d049cc2f1f93781f386952)) ### Features -* **button:** click signal with detail ([03c2dc1](https://github.com/AliMD/alwatr/commit/03c2dc1e64562815505b468c761ac245554470ed)) -* **com-pwa:** carType/ladingType ([94a2e96](https://github.com/AliMD/alwatr/commit/94a2e969465c20f7b52b7f18050b9ae0d3fec62d)) -* **i18n:** l18eReadyPromise ([85c7570](https://github.com/AliMD/alwatr/commit/85c7570d71c3d5b9ec87b0e357ecf41f47f96227)) -* **type/com:** OrderDraft, orderDeliverySchema ([4417877](https://github.com/AliMD/alwatr/commit/44178779fbeba5d14a465380541c64ffb3f4f597)) -* **type:** ProductPrice ([7fe7b32](https://github.com/AliMD/alwatr/commit/7fe7b321c0ab94c8abc4527b4aa33191cf5a9213)) +- **button:** click signal with detail ([03c2dc1](https://github.com/AliMD/alwatr/commit/03c2dc1e64562815505b468c761ac245554470ed)) +- **com-pwa:** carType/ladingType ([94a2e96](https://github.com/AliMD/alwatr/commit/94a2e969465c20f7b52b7f18050b9ae0d3fec62d)) +- **i18n:** l18eReadyPromise ([85c7570](https://github.com/AliMD/alwatr/commit/85c7570d71c3d5b9ec87b0e357ecf41f47f96227)) +- **type/com:** OrderDraft, orderDeliverySchema ([4417877](https://github.com/AliMD/alwatr/commit/44178779fbeba5d14a465380541c64ffb3f4f597)) +- **type:** ProductPrice ([7fe7b32](https://github.com/AliMD/alwatr/commit/7fe7b321c0ab94c8abc4527b4aa33191cf5a9213)) # 0.29.0 (2023-02-10) ### Bug Fixes -* **storage-server:** type ([5e033d7](https://github.com/AliMD/alwatr/commit/5e033d75d158a3b634a0d05da741241ff76f58d9)) +- **storage-server:** type ([5e033d7](https://github.com/AliMD/alwatr/commit/5e033d75d158a3b634a0d05da741241ff76f58d9)) ### Features -* **icon-button:** new content prop with click signal event ([bb5dae6](https://github.com/AliMD/alwatr/commit/bb5dae6048fcacb4a4e70aab514e4900fd5a96ea)) -* **route:** makeRouteContext ([16be581](https://github.com/AliMD/alwatr/commit/16be5815a4a44f22bd17c4a87f1b7ef30f9aec6c)) -* **router:** new api from scratch! ([2b26a8d](https://github.com/AliMD/alwatr/commit/2b26a8d9f95b5968dbda003edc9d540ea95fadd1)) -* **type:** enhance com types ([ed91385](https://github.com/AliMD/alwatr/commit/ed9138584b0096377e73251557cc4ff8aa92a3cc)) -* **type:** OmitFirstParam ([b5a778f](https://github.com/AliMD/alwatr/commit/b5a778f3da03244a0ad693ab15ef8dd782039163)) -* **type:** Stringifyable ([c2e0771](https://github.com/AliMD/alwatr/commit/c2e077118e0371fb32a5fc3fc81cf7f87d65104b)) +- **icon-button:** new content prop with click signal event ([bb5dae6](https://github.com/AliMD/alwatr/commit/bb5dae6048fcacb4a4e70aab514e4900fd5a96ea)) +- **route:** makeRouteContext ([16be581](https://github.com/AliMD/alwatr/commit/16be5815a4a44f22bd17c4a87f1b7ef30f9aec6c)) +- **router:** new api from scratch! ([2b26a8d](https://github.com/AliMD/alwatr/commit/2b26a8d9f95b5968dbda003edc9d540ea95fadd1)) +- **type:** enhance com types ([ed91385](https://github.com/AliMD/alwatr/commit/ed9138584b0096377e73251557cc4ff8aa92a3cc)) +- **type:** OmitFirstParam ([b5a778f](https://github.com/AliMD/alwatr/commit/b5a778f3da03244a0ad693ab15ef8dd782039163)) +- **type:** Stringifyable ([c2e0771](https://github.com/AliMD/alwatr/commit/c2e077118e0371fb32a5fc3fc81cf7f87d65104b)) # 0.28.0 (2023-01-20) ### Bug Fixes -* **type:** ChatPhotoMessage ([c72bcb2](https://github.com/AliMD/alwatr/commit/c72bcb24bfa936cd325728b42ad0f2acf463865d)) -* **type:** cleanup ([15c7d64](https://github.com/AliMD/alwatr/commit/15c7d648819914820374e752b91d41f287db574b)) -* **type:** export alwatrRegisteredList ([fa308b5](https://github.com/AliMD/alwatr/commit/fa308b5208e0a2ef0ed33e0fe7299cae0af51a97)) -* **type:** import type ([efaf4eb](https://github.com/AliMD/alwatr/commit/efaf4eb0ccbbf5eba5f34ece72bf27758f175521)) -* **type:** revert paramkey ([f1ad066](https://github.com/AliMD/alwatr/commit/f1ad06621f7fe80018573e50804e9f3c1b2edde1)) +- **type:** ChatPhotoMessage ([c72bcb2](https://github.com/AliMD/alwatr/commit/c72bcb24bfa936cd325728b42ad0f2acf463865d)) +- **type:** cleanup ([15c7d64](https://github.com/AliMD/alwatr/commit/15c7d648819914820374e752b91d41f287db574b)) +- **type:** export alwatrRegisteredList ([fa308b5](https://github.com/AliMD/alwatr/commit/fa308b5208e0a2ef0ed33e0fe7299cae0af51a97)) +- **type:** import type ([efaf4eb](https://github.com/AliMD/alwatr/commit/efaf4eb0ccbbf5eba5f34ece72bf27758f175521)) +- **type:** revert paramkey ([f1ad066](https://github.com/AliMD/alwatr/commit/f1ad06621f7fe80018573e50804e9f3c1b2edde1)) ### Features -* **type:** add optional text on ChatPhotoMessage ([af83f5b](https://github.com/AliMD/alwatr/commit/af83f5b8604cecd3c9b0cb2375267458fd02431d)) -* **type:** C.O.M ([d4655d8](https://github.com/AliMD/alwatr/commit/d4655d83f196990a3ffad2e4753be7b77639ee19)) -* **type:** chat ([4b7ac95](https://github.com/AliMD/alwatr/commit/4b7ac95522dcb637ebab2eda0b8f3e0cd80d59b0)) -* **type:** i18nString ([614037d](https://github.com/AliMD/alwatr/commit/614037d690415b257f34fb13c7143f76dfa2c6ca)) -* **type:** id in storage meta type ([146b9eb](https://github.com/AliMD/alwatr/commit/146b9eb4ebc748eda852988328b88abb75651945)) -* **type:** order ([79426ea](https://github.com/AliMD/alwatr/commit/79426ea696a0ca0723a8c7bfb6259c83a15c32d9)) -* **type:** order storage ([bd5f11c](https://github.com/AliMD/alwatr/commit/bd5f11c93f35ff235fb2f85df6cecd8823ea34fc)) -* **type:** photo ([7e38283](https://github.com/AliMD/alwatr/commit/7e38283113606a0a01c705caeb1f773a75dfd97c)) -* **type:** photo ([742005f](https://github.com/AliMD/alwatr/commit/742005f8588e408e818188a60eb9cf4a1fe9592f)) -* **type:** service-response ([18f8be3](https://github.com/AliMD/alwatr/commit/18f8be3f91f1678d6f5fb779c1f782736e29a010)) -* **type:** storage ([d4b3a95](https://github.com/AliMD/alwatr/commit/d4b3a956fb17b80b748d0587f12e818c021e3985)) -* **type:** user ([a0d8242](https://github.com/AliMD/alwatr/commit/a0d824202d91d75678945d72497965a55c4deba7)) -* **type:** user ([30b8edb](https://github.com/AliMD/alwatr/commit/30b8edb17aad0f20ccb887c1a71c65c385104ee3)) +- **type:** add optional text on ChatPhotoMessage ([af83f5b](https://github.com/AliMD/alwatr/commit/af83f5b8604cecd3c9b0cb2375267458fd02431d)) +- **type:** C.O.M ([d4655d8](https://github.com/AliMD/alwatr/commit/d4655d83f196990a3ffad2e4753be7b77639ee19)) +- **type:** chat ([4b7ac95](https://github.com/AliMD/alwatr/commit/4b7ac95522dcb637ebab2eda0b8f3e0cd80d59b0)) +- **type:** i18nString ([614037d](https://github.com/AliMD/alwatr/commit/614037d690415b257f34fb13c7143f76dfa2c6ca)) +- **type:** id in storage meta type ([146b9eb](https://github.com/AliMD/alwatr/commit/146b9eb4ebc748eda852988328b88abb75651945)) +- **type:** order ([79426ea](https://github.com/AliMD/alwatr/commit/79426ea696a0ca0723a8c7bfb6259c83a15c32d9)) +- **type:** order storage ([bd5f11c](https://github.com/AliMD/alwatr/commit/bd5f11c93f35ff235fb2f85df6cecd8823ea34fc)) +- **type:** photo ([7e38283](https://github.com/AliMD/alwatr/commit/7e38283113606a0a01c705caeb1f773a75dfd97c)) +- **type:** photo ([742005f](https://github.com/AliMD/alwatr/commit/742005f8588e408e818188a60eb9cf4a1fe9592f)) +- **type:** service-response ([18f8be3](https://github.com/AliMD/alwatr/commit/18f8be3f91f1678d6f5fb779c1f782736e29a010)) +- **type:** storage ([d4b3a95](https://github.com/AliMD/alwatr/commit/d4b3a956fb17b80b748d0587f12e818c021e3985)) +- **type:** user ([a0d8242](https://github.com/AliMD/alwatr/commit/a0d824202d91d75678945d72497965a55c4deba7)) +- **type:** user ([30b8edb](https://github.com/AliMD/alwatr/commit/30b8edb17aad0f20ccb887c1a71c65c385104ee3)) # 0.27.0 (2022-12-29) ### Bug Fixes -* **core/type:** remove extras ([63fe462](https://github.com/AliMD/alwatr/commit/63fe462e88e1d3e0dca8696f0c4c073ebc94c490)) -* resolve conflict ([052314d](https://github.com/AliMD/alwatr/commit/052314d2adb3b9b0e44e54f9b8e6d60fc1827075)) -* review issue ([e5d192c](https://github.com/AliMD/alwatr/commit/e5d192cbee6917c2de01146cf8bd026895724ab8)) +- **core/type:** remove extras ([63fe462](https://github.com/AliMD/alwatr/commit/63fe462e88e1d3e0dca8696f0c4c073ebc94c490)) +- resolve conflict ([052314d](https://github.com/AliMD/alwatr/commit/052314d2adb3b9b0e44e54f9b8e6d60fc1827075)) +- review issue ([e5d192c](https://github.com/AliMD/alwatr/commit/e5d192cbee6917c2de01146cf8bd026895724ab8)) ### Features -* **core/type:** make package ([1d8d1bd](https://github.com/AliMD/alwatr/commit/1d8d1bdfc39c4b1e238770a69d7c8e0cad593251)) -* **type:** add types ([2de3842](https://github.com/AliMD/alwatr/commit/2de384297b70b9818ec8d62ce8d31be4822d95a4)) -* **type:** define alwatrRegistredList ([25406c2](https://github.com/AliMD/alwatr/commit/25406c268f39cf3e055ea05c9fc7b50bd3dd0a17)) -* **type:** define chat type ([e4a345a](https://github.com/AliMD/alwatr/commit/e4a345a7c932d88f0d13e2df1b3dd7d2ad745932)) -* **type:** define chat type ([174fb02](https://github.com/AliMD/alwatr/commit/174fb02fe287c6fee6e9783f91dfa1928dbaf2ce)) -* **type:** define constructor type ([39c5ab7](https://github.com/AliMD/alwatr/commit/39c5ab74f0a1471d5e20beff89f6885265907633)) -* **type:** define math types ([8c19f40](https://github.com/AliMD/alwatr/commit/8c19f4058d4361b7d3f4f714595e34cb6fa21109)) +- **core/type:** make package ([1d8d1bd](https://github.com/AliMD/alwatr/commit/1d8d1bdfc39c4b1e238770a69d7c8e0cad593251)) +- **type:** add types ([2de3842](https://github.com/AliMD/alwatr/commit/2de384297b70b9818ec8d62ce8d31be4822d95a4)) +- **type:** define alwatrRegistredList ([25406c2](https://github.com/AliMD/alwatr/commit/25406c268f39cf3e055ea05c9fc7b50bd3dd0a17)) +- **type:** define chat type ([e4a345a](https://github.com/AliMD/alwatr/commit/e4a345a7c932d88f0d13e2df1b3dd7d2ad745932)) +- **type:** define chat type ([174fb02](https://github.com/AliMD/alwatr/commit/174fb02fe287c6fee6e9783f91dfa1928dbaf2ce)) +- **type:** define constructor type ([39c5ab7](https://github.com/AliMD/alwatr/commit/39c5ab74f0a1471d5e20beff89f6885265907633)) +- **type:** define math types ([8c19f40](https://github.com/AliMD/alwatr/commit/8c19f4058d4361b7d3f4f714595e34cb6fa21109)) # [1.0.0](https://github.com/AliMD/alwatr/compare/v0.32.0...v1.0.0) (2023-06-14) diff --git a/packages/type/src/i18n.ts b/packages/type/src/i18n.ts index f734b85a..208362a0 100644 --- a/packages/type/src/i18n.ts +++ b/packages/type/src/i18n.ts @@ -3,10 +3,13 @@ import {StringifyableRecord} from './type-helper.js'; export type LocaleCode = `${Lowercase}-${Uppercase}`; -export type L18eContext = AlwatrServiceResponseSuccessWithMeta, { - code: LocaleCode; - rev: number; -}>; +export type L18eContext = AlwatrServiceResponseSuccessWithMeta< + Record, + { + code: LocaleCode; + rev: number; + } +>; export interface LocaleContext extends StringifyableRecord { /** diff --git a/packages/type/src/service-response.ts b/packages/type/src/service-response.ts index f620081f..f2fd8e23 100644 --- a/packages/type/src/service-response.ts +++ b/packages/type/src/service-response.ts @@ -14,8 +14,7 @@ export interface AlwatrServiceResponseFailed extends StringifyableRecord { data?: never; } -export interface AlwatrServiceResponseSuccess - extends StringifyableRecord { +export interface AlwatrServiceResponseSuccess extends StringifyableRecord { ok: true; statusCode?: number; errorCode?: never; @@ -25,7 +24,7 @@ export interface AlwatrServiceResponseSuccess extends StringifyableRecord { ok: true; statusCode?: number; @@ -36,7 +35,7 @@ export interface AlwatrServiceResponseSuccessWithMeta< export type AlwatrServiceResponse< TData extends Stringifyable = Stringifyable, - TMeta extends StringifyableRecord = StringifyableRecord + TMeta extends StringifyableRecord = StringifyableRecord, > = | AlwatrServiceResponseSuccess | AlwatrServiceResponseSuccessWithMeta diff --git a/packages/type/src/type-helper.ts b/packages/type/src/type-helper.ts index 03d2feda..6e99ea41 100644 --- a/packages/type/src/type-helper.ts +++ b/packages/type/src/type-helper.ts @@ -11,13 +11,13 @@ export type OmitFirstParam = F extends (x: any, ...args: infer A) => infer R * Object that can be JSON.stringify. */ export type Stringifyable = - | string - | number - | boolean - | null - | undefined - | { [P: string]: Stringifyable } - | Stringifyable[]; + | string + | number + | boolean + | null + | undefined + | {[P: string]: Stringifyable} + | Stringifyable[]; export type StringifyableRecord = Record; diff --git a/packages/type/src/user.ts b/packages/type/src/user.ts index 5b5fc183..f76d85ae 100644 --- a/packages/type/src/user.ts +++ b/packages/type/src/user.ts @@ -3,7 +3,7 @@ import {StringifyableRecord} from './type-helper.js'; import type {AlwatrDocumentObject} from './storage.js'; export const genderCS = ['male', 'female'] as const; -export type Gender = typeof genderCS[number]; +export type Gender = (typeof genderCS)[number]; export interface User extends AlwatrDocumentObject { /** diff --git a/packages/util/CHANGELOG.md b/packages/util/CHANGELOG.md index 6acb0e72..c0d6ff02 100644 --- a/packages/util/CHANGELOG.md +++ b/packages/util/CHANGELOG.md @@ -7,7 +7,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline ### Features -* **util:** browser-task ([efc4c6e](https://github.com/AliMD/alwatr/commit/efc4c6efe5d0f716a4855e5c0fd7778a81b53885)) by @AliMD +- **util:** browser-task ([efc4c6e](https://github.com/AliMD/alwatr/commit/efc4c6efe5d0f716a4855e5c0fd7778a81b53885)) by @AliMD ## [1.1.1](https://github.com/AliMD/alwatr/compare/@alwatr/util@1.1.0...@alwatr/util@1.1.1) (2023-09-12) @@ -17,54 +17,54 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline ### Features -* **util:** defaultExport ([82cc24e](https://github.com/AliMD/alwatr/commit/82cc24e84b9e18cebf7c149e6f6cbb1c2c44858c)) -* **util:** renderState ([19a6030](https://github.com/AliMD/alwatr/commit/19a603018c87065191f99a55cdcdfc8193dc493d)) +- **util:** defaultExport ([82cc24e](https://github.com/AliMD/alwatr/commit/82cc24e84b9e18cebf7c149e6f6cbb1c2c44858c)) +- **util:** renderState ([19a6030](https://github.com/AliMD/alwatr/commit/19a603018c87065191f99a55cdcdfc8193dc493d)) # 1.0.0 (2023-06-14) ### Bug Fixes -* **util/fs:** makeLinkForce throw error ([8bfcc80](https://github.com/AliMD/alwatr/commit/8bfcc80b11ad59538478440fe6e88cc9ee12df77)) +- **util/fs:** makeLinkForce throw error ([8bfcc80](https://github.com/AliMD/alwatr/commit/8bfcc80b11ad59538478440fe6e88cc9ee12df77)) ### Features -* **util:** add string capitalize ([c499456](https://github.com/AliMD/alwatr/commit/c4994562f75471184d49f46ba3c6d7acdb4ab796)) +- **util:** add string capitalize ([c499456](https://github.com/AliMD/alwatr/commit/c4994562f75471184d49f46ba3c6d7acdb4ab796)) # 0.32.0 (2023-05-27) ### Features -* **util/fs:** existFile option option ([c8c2020](https://github.com/AliMD/alwatr/commit/c8c202097f6a1fb568993f7987977a140dde5273)) -* **util:** flatStr ([09462ec](https://github.com/AliMD/alwatr/commit/09462ec88082a2339e633975c346f2fa17997400)) +- **util/fs:** existFile option option ([c8c2020](https://github.com/AliMD/alwatr/commit/c8c202097f6a1fb568993f7987977a140dde5273)) +- **util:** flatStr ([09462ec](https://github.com/AliMD/alwatr/commit/09462ec88082a2339e633975c346f2fa17997400)) # 0.31.0 (2023-05-08) ### Features -* **util/node:** makeLinkForce ([f0c091e](https://github.com/AliMD/alwatr/commit/f0c091e454c1cb0b47b5126bd025b450e05b81fb)) -* **util:** generic types ([7a69fa7](https://github.com/AliMD/alwatr/commit/7a69fa78b6b36834816fcdb4376f9d53d3243713)) -* **util:** readJsonFile ([940cba6](https://github.com/AliMD/alwatr/commit/940cba67d2e56c6292aba02d01d0395edfa1b217)) -* **util:** readJsonFileSync ([659b2ea](https://github.com/AliMD/alwatr/commit/659b2ead425264073d53b561c0a7f6e2476ff8cc)) -* **util:** setLocalStorageItem ([46e248c](https://github.com/AliMD/alwatr/commit/46e248cb79b7846f568eadc5a6d5a2214fe4faf3)) -* **util:** writeJsonFile ([3707070](https://github.com/AliMD/alwatr/commit/3707070ef0c7716718e84ccfb6c44e316983e2f2)) -* **util:** writeJsonFileSync ([230f415](https://github.com/AliMD/alwatr/commit/230f4157a19ea539f6c245ef77e02512b7c9c91a)) +- **util/node:** makeLinkForce ([f0c091e](https://github.com/AliMD/alwatr/commit/f0c091e454c1cb0b47b5126bd025b450e05b81fb)) +- **util:** generic types ([7a69fa7](https://github.com/AliMD/alwatr/commit/7a69fa78b6b36834816fcdb4376f9d53d3243713)) +- **util:** readJsonFile ([940cba6](https://github.com/AliMD/alwatr/commit/940cba67d2e56c6292aba02d01d0395edfa1b217)) +- **util:** readJsonFileSync ([659b2ea](https://github.com/AliMD/alwatr/commit/659b2ead425264073d53b561c0a7f6e2476ff8cc)) +- **util:** setLocalStorageItem ([46e248c](https://github.com/AliMD/alwatr/commit/46e248cb79b7846f568eadc5a6d5a2214fe4faf3)) +- **util:** writeJsonFile ([3707070](https://github.com/AliMD/alwatr/commit/3707070ef0c7716718e84ccfb6c44e316983e2f2)) +- **util:** writeJsonFileSync ([230f415](https://github.com/AliMD/alwatr/commit/230f4157a19ea539f6c245ef77e02512b7c9c91a)) # 0.30.0 (2023-03-06) ### Features -* **util:** add getClientId ([f9c1008](https://github.com/AliMD/alwatr/commit/f9c1008da682555e22178aa8d23cf742937b76a4)) -* **util:** add getLocalStorageItem ([dc5fa8b](https://github.com/AliMD/alwatr/commit/dc5fa8b9620a9add1aa3c838d38fb9ed9d364010)) -* **util:** add parseJson ([543da2c](https://github.com/AliMD/alwatr/commit/543da2cbb7079f74fe3f280f9c07b8fe6fc8e987)) -* **util:** polyfil requestAnimationFrame, requestIdleCallbackFallback ([6dc4b73](https://github.com/AliMD/alwatr/commit/6dc4b7347b97d2d2fdd562917e02cbe4d6d1328b)) +- **util:** add getClientId ([f9c1008](https://github.com/AliMD/alwatr/commit/f9c1008da682555e22178aa8d23cf742937b76a4)) +- **util:** add getLocalStorageItem ([dc5fa8b](https://github.com/AliMD/alwatr/commit/dc5fa8b9620a9add1aa3c838d38fb9ed9d364010)) +- **util:** add parseJson ([543da2c](https://github.com/AliMD/alwatr/commit/543da2cbb7079f74fe3f280f9c07b8fe6fc8e987)) +- **util:** polyfil requestAnimationFrame, requestIdleCallbackFallback ([6dc4b73](https://github.com/AliMD/alwatr/commit/6dc4b7347b97d2d2fdd562917e02cbe4d6d1328b)) # 0.29.0 (2023-02-10) ### Features -* **util:** arrow fn and untilEvent types ([ced1de6](https://github.com/AliMD/alwatr/commit/ced1de64f7d7458d14578096484f492be35665fc)) -* **util:** new package ([a7b1fb3](https://github.com/AliMD/alwatr/commit/a7b1fb38d93867b5013ec35c4a0a06d6ffe8716a)) -* **util:** until functions ([3b17ef2](https://github.com/AliMD/alwatr/commit/3b17ef22e2074c0a76751795af15330b6cb08090)) +- **util:** arrow fn and untilEvent types ([ced1de6](https://github.com/AliMD/alwatr/commit/ced1de64f7d7458d14578096484f492be35665fc)) +- **util:** new package ([a7b1fb3](https://github.com/AliMD/alwatr/commit/a7b1fb38d93867b5013ec35c4a0a06d6ffe8716a)) +- **util:** until functions ([3b17ef2](https://github.com/AliMD/alwatr/commit/3b17ef22e2074c0a76751795af15330b6cb08090)) # [1.0.0](https://github.com/AliMD/alwatr/compare/v0.32.0...v1.0.0) (2023-06-14) diff --git a/packages/util/src/polyfill.ts b/packages/util/src/polyfill.ts index 8e1255e0..e80032a9 100644 --- a/packages/util/src/polyfill.ts +++ b/packages/util/src/polyfill.ts @@ -18,7 +18,4 @@ const requestIdleCallbackFallback = ( ): ReturnType => setTimeout(callback, options?.timeout ?? 2000); export const requestIdleCallback: typeof globalThis.requestIdleCallback = - win.requestIdleCallback || - win.webkitRequestIdleCallback || - win.mozRequestIdleCallback || - requestIdleCallbackFallback; + win.requestIdleCallback || win.webkitRequestIdleCallback || win.mozRequestIdleCallback || requestIdleCallbackFallback; diff --git a/packages/validator/CHANGELOG.md b/packages/validator/CHANGELOG.md index 0ab7f55b..6bfbea6a 100644 --- a/packages/validator/CHANGELOG.md +++ b/packages/validator/CHANGELOG.md @@ -21,54 +21,54 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline ### Bug Fixes -* **type:** Stringifyable ([058381b](https://github.com/AliMD/alwatr/commit/058381b50641ba44f4ac60e2173b5b91449e58cd)) -* **validator:** add 98 in start of phone number ([a26b6ae](https://github.com/AliMD/alwatr/commit/a26b6ae63e20e4d2c1f69951f244b8f430e6a755)) -* **validator:** array schema f**ing issue! ([f38a4a5](https://github.com/AliMD/alwatr/commit/f38a4a55d93f885f60b3c2a4678e80b4682af039)) -* **validator:** array support ([08f5215](https://github.com/AliMD/alwatr/commit/08f521534a0e937e5cf0f92bf5ca274838f41f93)) -* **validator:** improve `sanitizePhoneNumber` structure ([fb90f2f](https://github.com/AliMD/alwatr/commit/fb90f2ffcef7bf0d2c4a41a9fd0d578e3b9d40a7)) -* **validator:** local country code issue ([07e9cc0](https://github.com/AliMD/alwatr/commit/07e9cc08bd6067580dc33f839bdc842e178f7e5b)) -* **validator:** remove an unused expression ([d1fe2b4](https://github.com/AliMD/alwatr/commit/d1fe2b4cb3e8f44d37bd681b04c51d35e932268a)) +- **type:** Stringifyable ([058381b](https://github.com/AliMD/alwatr/commit/058381b50641ba44f4ac60e2173b5b91449e58cd)) +- **validator:** add 98 in start of phone number ([a26b6ae](https://github.com/AliMD/alwatr/commit/a26b6ae63e20e4d2c1f69951f244b8f430e6a755)) +- **validator:** array schema f\*\*ing issue! ([f38a4a5](https://github.com/AliMD/alwatr/commit/f38a4a55d93f885f60b3c2a4678e80b4682af039)) +- **validator:** array support ([08f5215](https://github.com/AliMD/alwatr/commit/08f521534a0e937e5cf0f92bf5ca274838f41f93)) +- **validator:** improve `sanitizePhoneNumber` structure ([fb90f2f](https://github.com/AliMD/alwatr/commit/fb90f2ffcef7bf0d2c4a41a9fd0d578e3b9d40a7)) +- **validator:** local country code issue ([07e9cc0](https://github.com/AliMD/alwatr/commit/07e9cc08bd6067580dc33f839bdc842e178f7e5b)) +- **validator:** remove an unused expression ([d1fe2b4](https://github.com/AliMD/alwatr/commit/d1fe2b4cb3e8f44d37bd681b04c51d35e932268a)) ### Features -* **validator:** add some new functions to validate ([aea3ec1](https://github.com/AliMD/alwatr/commit/aea3ec1a242d5577d0e93895724dcacfce48532d)) -* **validator:** array in JsonSchema ([58c9c56](https://github.com/AliMD/alwatr/commit/58c9c56f47b18db5d1aa128b35d0e6c8352d2492)) -* **validator:** fix default value of `replaceNumberToLang` ([0345add](https://github.com/AliMD/alwatr/commit/0345addfa9d03acdc4113a07caf8ee3f1ccdddf9)) -* **validator:** sanitizePhoneNumber ([41f2050](https://github.com/AliMD/alwatr/commit/41f2050269bd74ff9c4908f984bfe3716fc01bc7)) -* **validator:** support array ([b632a7a](https://github.com/AliMD/alwatr/commit/b632a7a6b752fcd8666e6d42da64ebf3b0917c8d)) +- **validator:** add some new functions to validate ([aea3ec1](https://github.com/AliMD/alwatr/commit/aea3ec1a242d5577d0e93895724dcacfce48532d)) +- **validator:** array in JsonSchema ([58c9c56](https://github.com/AliMD/alwatr/commit/58c9c56f47b18db5d1aa128b35d0e6c8352d2492)) +- **validator:** fix default value of `replaceNumberToLang` ([0345add](https://github.com/AliMD/alwatr/commit/0345addfa9d03acdc4113a07caf8ee3f1ccdddf9)) +- **validator:** sanitizePhoneNumber ([41f2050](https://github.com/AliMD/alwatr/commit/41f2050269bd74ff9c4908f984bfe3716fc01bc7)) +- **validator:** support array ([b632a7a](https://github.com/AliMD/alwatr/commit/b632a7a6b752fcd8666e6d42da64ebf3b0917c8d)) # 0.30.0 (2023-03-06) ### Bug Fixes -* **validator:** change ValidType to StringifyableRecord ([ca1e191](https://github.com/AliMD/alwatr/commit/ca1e19166edfd206a3901a2a3390d4be3daaa7bc)) +- **validator:** change ValidType to StringifyableRecord ([ca1e191](https://github.com/AliMD/alwatr/commit/ca1e19166edfd206a3901a2a3390d4be3daaa7bc)) # 0.29.0 (2023-02-10) ### Bug Fixes -* **validator:** not accept empty string ([433236b](https://github.com/AliMD/alwatr/commit/433236bc440f315b08b811d82ea57d3118e3fc6e)) +- **validator:** not accept empty string ([433236b](https://github.com/AliMD/alwatr/commit/433236bc440f315b08b811d82ea57d3118e3fc6e)) # 0.28.0 (2023-01-20) ### Bug Fixes -* **validator:** boolean validator ([593b4a4](https://github.com/AliMD/alwatr/commit/593b4a499529d995836c7a91abc979c4b3a5543b)) -* **validator:** deps ([635866d](https://github.com/AliMD/alwatr/commit/635866d81134df0db46fc44b7ed7575e0486f9cd)) -* **validator:** readme ([af237db](https://github.com/AliMD/alwatr/commit/af237db8e0c2f5cd37d487304f2097bed95e3a90)) -* **validator:** return validObject ([aa44ed0](https://github.com/AliMD/alwatr/commit/aa44ed0b18cca15a0c689f9bdb9ce584b0a55eb0)) +- **validator:** boolean validator ([593b4a4](https://github.com/AliMD/alwatr/commit/593b4a499529d995836c7a91abc979c4b3a5543b)) +- **validator:** deps ([635866d](https://github.com/AliMD/alwatr/commit/635866d81134df0db46fc44b7ed7575e0486f9cd)) +- **validator:** readme ([af237db](https://github.com/AliMD/alwatr/commit/af237db8e0c2f5cd37d487304f2097bed95e3a90)) +- **validator:** return validObject ([aa44ed0](https://github.com/AliMD/alwatr/commit/aa44ed0b18cca15a0c689f9bdb9ce584b0a55eb0)) ### Features -* **validator:** additionalProperties ([60829a6](https://github.com/AliMD/alwatr/commit/60829a6280fdc3138f8702cee776e0dae11f548f)) -* **validator:** demo ([9e577ca](https://github.com/AliMD/alwatr/commit/9e577cad18be45942d36d633932ef0aa2c2ec512)) -* **validator:** enum values ([7c02422](https://github.com/AliMD/alwatr/commit/7c02422e9caf9ab5dd8e352714db346518229d59)) -* **validator:** export schema type ([da91546](https://github.com/AliMD/alwatr/commit/da915461583440d655f26c89c0c29b5c9cb74c6e)) -* **validator:** new package ([5aa48c3](https://github.com/AliMD/alwatr/commit/5aa48c354c116655e7824366d4efcd5965172fe3)) -* **validator:** rename var ([b68b2e4](https://github.com/AliMD/alwatr/commit/b68b2e4671ff30efcc817213e4bf9bee9c322d90)) -* **validator:** throw value in error ([4e99b80](https://github.com/AliMD/alwatr/commit/4e99b8078455443e70aab5ebdbe30c21152b48ae)) -* **validator:** update demo ([d49929f](https://github.com/AliMD/alwatr/commit/d49929fca0007aa94482010b7a6245f0bb360bc0)) -* **validator:** update demo ([cc21a90](https://github.com/AliMD/alwatr/commit/cc21a906b371f51696c3619fc0df0f392be99dee)) +- **validator:** additionalProperties ([60829a6](https://github.com/AliMD/alwatr/commit/60829a6280fdc3138f8702cee776e0dae11f548f)) +- **validator:** demo ([9e577ca](https://github.com/AliMD/alwatr/commit/9e577cad18be45942d36d633932ef0aa2c2ec512)) +- **validator:** enum values ([7c02422](https://github.com/AliMD/alwatr/commit/7c02422e9caf9ab5dd8e352714db346518229d59)) +- **validator:** export schema type ([da91546](https://github.com/AliMD/alwatr/commit/da915461583440d655f26c89c0c29b5c9cb74c6e)) +- **validator:** new package ([5aa48c3](https://github.com/AliMD/alwatr/commit/5aa48c354c116655e7824366d4efcd5965172fe3)) +- **validator:** rename var ([b68b2e4](https://github.com/AliMD/alwatr/commit/b68b2e4671ff30efcc817213e4bf9bee9c322d90)) +- **validator:** throw value in error ([4e99b80](https://github.com/AliMD/alwatr/commit/4e99b8078455443e70aab5ebdbe30c21152b48ae)) +- **validator:** update demo ([d49929f](https://github.com/AliMD/alwatr/commit/d49929fca0007aa94482010b7a6245f0bb360bc0)) +- **validator:** update demo ([cc21a90](https://github.com/AliMD/alwatr/commit/cc21a906b371f51696c3619fc0df0f392be99dee)) # [1.0.0](https://github.com/AliMD/alwatr/compare/v0.32.0...v1.0.0) (2023-06-14) diff --git a/packages/validator/src/validator.ts b/packages/validator/src/validator.ts index 58047f78..2448b4ba 100644 --- a/packages/validator/src/validator.ts +++ b/packages/validator/src/validator.ts @@ -149,8 +149,7 @@ export const sanitizePhoneNumber = (input?: string | number | null, countryCode input = unicodeDigits.translate(input + ''); input = - countryCode + - input.replace(/[ )(-]+/g, '').replace(new RegExp(`^(\\+${countryCode}|${countryCode}|\\+|0)`), ''); + countryCode + input.replace(/[ )(-]+/g, '').replace(new RegExp(`^(\\+${countryCode}|${countryCode}|\\+|0)`), ''); if (input.length !== countryCode.length + 10 || !isNumber(input)) return null; diff --git a/tsconfig.base.json b/tsconfig.base.json index f4faf715..32692253 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -8,7 +8,7 @@ "module": "NodeNext", "moduleResolution": "NodeNext", "resolveJsonModule": true, // temporary for fix import json issue - "lib": ["ES2023", "DOM"], + "lib": ["ES2023", "DOM", "DOM.Iterable"], // "allowJs": true, // "checkJs": true, // "jsx": "preserve", diff --git a/tsconfig.json b/tsconfig.json index 3f119546..d261a6ab 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -4,7 +4,7 @@ "extends": "./tsconfig.base", "compilerOptions": { "composite": true, - "tsBuildInfoFile": ".tsbuildinfo", + "tsBuildInfoFile": ".tsbuildinfo" }, "files": [], "exclude": [], @@ -18,6 +18,6 @@ {"path": "./packages/type"}, // demo - {"path": "./demo"}, + {"path": "./demo"} ] }