asma-core-helpers 0.35.0 → 0.37.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -15,8 +15,46 @@ pnpm add asma-core-helpers
15
15
  ```typescript
16
16
  import { history, isAdcuris, getParamByName } from 'asma-core-helpers/lib'
17
17
  import { ActorTypes, ActivityStatuses } from 'asma-core-helpers'
18
+ import { parsePhoneNr, toE164, isValidPhone } from 'asma-core-helpers/phone'
18
19
  ```
19
20
 
21
+ ### The `phone` subpath
22
+
23
+ Phone numbers live behind their own entry point and are **never** re-exported from the
24
+ root barrel. The subpath carries `libphonenumber-js` and its metadata, so exporting it
25
+ from the barrel would put that weight into every consumer that only wanted an enum.
26
+
27
+ ```typescript
28
+ import { parsePhoneNr, toE164, isValidPhone, phoneTelHref } from 'asma-core-helpers/phone'
29
+
30
+ // One canonicaliser for every writer and the backfill, so runtime and migration agree.
31
+ // The region is an explicit input, applied where a value enters the system and only
32
+ // when the input carries no `+` — never an implicit `+47` prefix.
33
+ const parsed = parsePhoneNr('45456565', 'NO')
34
+ // → { ok: true, e164: '+4745456565', country: 'NO', callingCode: '47' }
35
+
36
+ // A value that is not a real number under that region is reported, never rewritten
37
+ // into something plausible.
38
+ parsePhoneNr('12345678', 'NO') // → { ok: false, reason: 'INVALID', input: '12345678' }
39
+ ```
40
+
41
+ The stored form is bare E.164 (`+4748012345`). The `tel:` scheme belongs to the render of
42
+ a click-to-call link and is produced by `phoneTelHref`, never written to a field.
43
+
44
+ The read-only helpers refuse the same values the parser does, so nothing is invented at the
45
+ last moment either. `'0701234567'` is a Swedish mobile written nationally, and under `NO` it
46
+ is not a number — it stays readable and dialable, but as itself:
47
+
48
+ ```typescript
49
+ formatPhoneForDisplay('0701234567', 'NO') // → '0701234567', shown as stored, not '+47 0701234567'
50
+ phoneTelHref('0701234567', 'NO') // → 'tel:0701234567', the stored digits, not 'tel:+470701234567'
51
+ phoneTelHref('ana@example.com') // → '', so the caller renders text instead of a link
52
+ ```
53
+
54
+ A number the plan confirms is canonicalised (`'48012345'` under `NO` → `tel:+4748012345`);
55
+ anything else is linked verbatim, so the dialer opens with the digits a therapist would have
56
+ read off the field rather than with a country we composed for them.
57
+
20
58
  ## Features
21
59
 
22
60
  - **Environment utilities**: Environment detection, URL helpers, domain utilities
@@ -25,6 +63,7 @@ import { ActorTypes, ActivityStatuses } from 'asma-core-helpers'
25
63
  - **Type definitions**: Shared TypeScript types and enums
26
64
  - **State management**: MST (MobX State Tree) helpers
27
65
  - **Data utilities**: Validation, formatting, and transformation helpers
66
+ - **Phone numbers** (`/phone`): country-aware parsing, validation and E.164 canonicalisation
28
67
 
29
68
  ## Development
30
69
 
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Country-aware phone primitives for ASMA forms (ASMA-7485).
3
+ *
4
+ * Published as `asma-core-helpers/phone` and deliberately **not** re-exported from
5
+ * the root barrel: the root entry is what the ESM kernel bundles and serves to all
6
+ * 17 fleet apps, and `libphonenumber-js` has no business in that shared unit. As a
7
+ * subpath it is absent from `KERNEL_EXTERNAL_SPECIFIERS`, so it bundles into the two
8
+ * apps that actually render a phone field instead.
9
+ *
10
+ * @see asma-modules/_docs/adr/adr-g-0017-frontend-form-state-and-validation-ownership.md:49 — DEC-001, why the rules live here and not in asma-ui-core
11
+ */
12
+ export { DEFAULT_PHONE_COUNTRY, findCountryByDialCode, getPhoneDialCode, listPhoneCountries, matchesPhoneCountry, type PhoneCountry, type PhoneCountryOption, } from './phoneCountries.js';
13
+ export { formatNationalAsYouType, formatPhoneForDisplay, isValidPhone, isValidPhoneValue, parsePhoneNr, parsePhoneValue, phoneTelHref, PHONE_MAX_DIGITS, PHONE_MIN_DIGITS, toE164, type ParsedPhone, type PhoneNrParse, } from './phoneNumber.js';
14
+ export { phoneExample } from './phoneExample.js';
15
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/phone/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EACH,qBAAqB,EACrB,qBAAqB,EACrB,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,EACnB,KAAK,YAAY,EACjB,KAAK,kBAAkB,GAC1B,MAAM,qBAAqB,CAAA;AAE5B,OAAO,EACH,uBAAuB,EACvB,qBAAqB,EACrB,YAAY,EACZ,iBAAiB,EACjB,YAAY,EACZ,eAAe,EACf,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,EAChB,MAAM,EACN,KAAK,WAAW,EAChB,KAAK,YAAY,GACpB,MAAM,kBAAkB,CAAA;AAEzB,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Country-aware phone primitives for ASMA forms (ASMA-7485).
3
+ *
4
+ * Published as `asma-core-helpers/phone` and deliberately **not** re-exported from
5
+ * the root barrel: the root entry is what the ESM kernel bundles and serves to all
6
+ * 17 fleet apps, and `libphonenumber-js` has no business in that shared unit. As a
7
+ * subpath it is absent from `KERNEL_EXTERNAL_SPECIFIERS`, so it bundles into the two
8
+ * apps that actually render a phone field instead.
9
+ *
10
+ * @see asma-modules/_docs/adr/adr-g-0017-frontend-form-state-and-validation-ownership.md:49 — DEC-001, why the rules live here and not in asma-ui-core
11
+ */
12
+ export { DEFAULT_PHONE_COUNTRY, findCountryByDialCode, getPhoneDialCode, listPhoneCountries, matchesPhoneCountry, } from './phoneCountries.js';
13
+ export { formatNationalAsYouType, formatPhoneForDisplay, isValidPhone, isValidPhoneValue, parsePhoneNr, parsePhoneValue, phoneTelHref, PHONE_MAX_DIGITS, PHONE_MIN_DIGITS, toE164, } from './phoneNumber.js';
14
+ export { phoneExample } from './phoneExample.js';
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/phone/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EACH,qBAAqB,EACrB,qBAAqB,EACrB,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,GAGtB,MAAM,qBAAqB,CAAA;AAE5B,OAAO,EACH,uBAAuB,EACvB,qBAAqB,EACrB,YAAY,EACZ,iBAAiB,EACjB,YAAY,EACZ,eAAe,EACf,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,EAChB,MAAM,GAGT,MAAM,kBAAkB,CAAA;AAEzB,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA"}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Country dial-code catalogue for the ASMA phone field (ASMA-7485).
3
+ *
4
+ * Country names come from the platform's own `Intl.DisplayNames` rather than a
5
+ * checked-in translation table, so every locale the browser knows is covered
6
+ * without shipping (or maintaining) 245 names per language.
7
+ */
8
+ import type { CountryCode } from 'libphonenumber-js';
9
+ /** ISO 3166-1 alpha-2 code, narrowed to what the phone metadata actually supports. */
10
+ export type PhoneCountry = CountryCode;
11
+ /** Pre-selected country for every ASMA phone field — see ASMA-7485. */
12
+ export declare const DEFAULT_PHONE_COUNTRY: PhoneCountry;
13
+ export interface PhoneCountryOption {
14
+ iso2: PhoneCountry;
15
+ /** Calling code without the leading `+`, e.g. `'47'`. */
16
+ dialCode: string;
17
+ /** Country name in the requested locale, e.g. `'Norge'` / `'Norway'`. */
18
+ name: string;
19
+ }
20
+ /**
21
+ * Every supported country, sorted by localized name.
22
+ *
23
+ * Ordering of the *rendered* list (pinning the selected country first) belongs to
24
+ * the UI; this returns the stable alphabetical catalogue. Memoized per locale
25
+ * because the underlying `Intl.DisplayNames` lookup runs once per country.
26
+ */
27
+ export declare function listPhoneCountries(locale: string): readonly PhoneCountryOption[];
28
+ export declare function getPhoneDialCode(iso2: PhoneCountry): string;
29
+ /**
30
+ * Search predicate for the country picker: matches on localized name **or** on the
31
+ * calling code, so both `"Norway"` and `"47"` narrow the list to +47 (ASMA-7485).
32
+ *
33
+ * A leading `+` in the query is ignored so pasting `+47` works.
34
+ */
35
+ export declare function matchesPhoneCountry(option: PhoneCountryOption, query: string): boolean;
36
+ /**
37
+ * The country owning the longest calling-code prefix of `digits`.
38
+ *
39
+ * Longest-prefix rather than first-match because calling codes are not prefix-free
40
+ * (`+1` vs `+7`, `+47` vs `+473`), and main-country-wins because 25 countries share
41
+ * `+1` — a plain scan resolves every North-American number to Antigua.
42
+ */
43
+ export declare function findCountryByDialCode(digits: string): PhoneCountry | undefined;
44
+ //# sourceMappingURL=phoneCountries.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"phoneCountries.d.ts","sourceRoot":"","sources":["../../src/phone/phoneCountries.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAEpD,sFAAsF;AACtF,MAAM,MAAM,YAAY,GAAG,WAAW,CAAA;AAEtC,uEAAuE;AACvE,eAAO,MAAM,qBAAqB,EAAE,YAAmB,CAAA;AAEvD,MAAM,WAAW,kBAAkB;IAC/B,IAAI,EAAE,YAAY,CAAA;IAClB,yDAAyD;IACzD,QAAQ,EAAE,MAAM,CAAA;IAChB,yEAAyE;IACzE,IAAI,EAAE,MAAM,CAAA;CACf;AAUD;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,kBAAkB,EAAE,CAiBhF;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,YAAY,GAAG,MAAM,CAE3D;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,kBAAkB,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAQtF;AA0BD;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAO9E"}
@@ -0,0 +1,84 @@
1
+ /**
2
+ * Country dial-code catalogue for the ASMA phone field (ASMA-7485).
3
+ *
4
+ * Country names come from the platform's own `Intl.DisplayNames` rather than a
5
+ * checked-in translation table, so every locale the browser knows is covered
6
+ * without shipping (or maintaining) 245 names per language.
7
+ */
8
+ import { getCountries, getCountryCallingCode, isSupportedCountry, Metadata } from 'libphonenumber-js';
9
+ /** Pre-selected country for every ASMA phone field — see ASMA-7485. */
10
+ export const DEFAULT_PHONE_COUNTRY = 'NO';
11
+ const optionsByLocale = new Map();
12
+ function countryName(iso2, displayNames) {
13
+ // `of` returns undefined for codes the ICU data does not know; the code itself
14
+ // is a better fallback than an empty row.
15
+ return displayNames.of(iso2) ?? iso2;
16
+ }
17
+ /**
18
+ * Every supported country, sorted by localized name.
19
+ *
20
+ * Ordering of the *rendered* list (pinning the selected country first) belongs to
21
+ * the UI; this returns the stable alphabetical catalogue. Memoized per locale
22
+ * because the underlying `Intl.DisplayNames` lookup runs once per country.
23
+ */
24
+ export function listPhoneCountries(locale) {
25
+ const cached = optionsByLocale.get(locale);
26
+ if (cached !== undefined)
27
+ return cached;
28
+ const displayNames = new Intl.DisplayNames([locale], { type: 'region' });
29
+ const collator = new Intl.Collator(locale);
30
+ const options = getCountries()
31
+ .map((iso2) => ({
32
+ iso2,
33
+ dialCode: getCountryCallingCode(iso2),
34
+ name: countryName(iso2, displayNames),
35
+ }))
36
+ .sort((left, right) => collator.compare(left.name, right.name));
37
+ optionsByLocale.set(locale, options);
38
+ return options;
39
+ }
40
+ export function getPhoneDialCode(iso2) {
41
+ return getCountryCallingCode(iso2);
42
+ }
43
+ /**
44
+ * Search predicate for the country picker: matches on localized name **or** on the
45
+ * calling code, so both `"Norway"` and `"47"` narrow the list to +47 (ASMA-7485).
46
+ *
47
+ * A leading `+` in the query is ignored so pasting `+47` works.
48
+ */
49
+ export function matchesPhoneCountry(option, query) {
50
+ const trimmed = query.trim();
51
+ if (trimmed.length === 0)
52
+ return true;
53
+ if (option.name.toLocaleLowerCase().includes(trimmed.toLocaleLowerCase()))
54
+ return true;
55
+ const digits = trimmed.replace(/^\+/, '').replace(/\D/g, '');
56
+ return digits.length > 0 && option.dialCode.startsWith(digits);
57
+ }
58
+ /** Calling codes are at most three digits in the E.164 plan. */
59
+ const MAX_CALLING_CODE_LENGTH = 3;
60
+ /**
61
+ * The primary country for a calling code — `'1'` → `US`, not whichever NANP
62
+ * territory happens to sort first. The metadata index lists the main country first.
63
+ */
64
+ function mainCountryForCallingCode(callingCode) {
65
+ const index = new Metadata();
66
+ const candidate = index.getCountryCodesForCallingCode?.(callingCode)?.[0];
67
+ return candidate !== undefined && isSupportedCountry(candidate) ? candidate : undefined;
68
+ }
69
+ /**
70
+ * The country owning the longest calling-code prefix of `digits`.
71
+ *
72
+ * Longest-prefix rather than first-match because calling codes are not prefix-free
73
+ * (`+1` vs `+7`, `+47` vs `+473`), and main-country-wins because 25 countries share
74
+ * `+1` — a plain scan resolves every North-American number to Antigua.
75
+ */
76
+ export function findCountryByDialCode(digits) {
77
+ for (let length = Math.min(MAX_CALLING_CODE_LENGTH, digits.length); length >= 1; length -= 1) {
78
+ const country = mainCountryForCallingCode(digits.slice(0, length));
79
+ if (country !== undefined)
80
+ return country;
81
+ }
82
+ return undefined;
83
+ }
84
+ //# sourceMappingURL=phoneCountries.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"phoneCountries.js","sourceRoot":"","sources":["../../src/phone/phoneCountries.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,YAAY,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAMrG,uEAAuE;AACvE,MAAM,CAAC,MAAM,qBAAqB,GAAiB,IAAI,CAAA;AAUvD,MAAM,eAAe,GAAG,IAAI,GAAG,EAAyC,CAAA;AAExE,SAAS,WAAW,CAAC,IAAkB,EAAE,YAA+B;IACpE,+EAA+E;IAC/E,0CAA0C;IAC1C,OAAO,YAAY,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,IAAI,CAAA;AACxC,CAAC;AAED;;;;;;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AAA;IAEtF,MAAM,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAA;IAC5D,OAAO,MAAM,CAAC,MAAM,GAAG,CAAC,IAAI,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC,CAAA;AAClE,CAAC;AAED,gEAAgE;AAChE,MAAM,uBAAuB,GAAG,CAAC,CAAA;AAYjC;;;GAGG;AACH,SAAS,yBAAyB,CAAC,WAAmB;IAClD,MAAM,KAAK,GAAG,IAAI,QAAQ,EAAiC,CAAA;IAC3D,MAAM,SAAS,GAAG,KAAK,CAAC,6BAA6B,EAAE,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;IAEzE,OAAO,SAAS,KAAK,SAAS,IAAI,kBAAkB,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAA;AAC3F,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB,CAAC,MAAc;IAChD,KAAK,IAAI,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,uBAAuB,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC,EAAE,MAAM,IAAI,CAAC,EAAE,CAAC;QAC3F,MAAM,OAAO,GAAG,yBAAyB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAA;QAClE,IAAI,OAAO,KAAK,SAAS;YAAE,OAAO,OAAO,CAAA;IAC7C,CAAC;IAED,OAAO,SAAS,CAAA;AACpB,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Example numbers for the actionable half of a validation message (ADR-0017 REQ-003:
3
+ * "what's wrong — how to fix"), e.g. `errorWithHint(msgs.invalid_phone, phoneExample('NO'))`
4
+ * → `'Invalid phone — Ex: +47 40 61 23 45'`.
5
+ *
6
+ * Kept in its own module so consumers that only format or validate do not pull the
7
+ * example metadata (~1.4 kB gz) into their bundle.
8
+ */
9
+ import type { PhoneCountry } from './phoneCountries.js';
10
+ /**
11
+ * A representative mobile number for the country, in international form.
12
+ *
13
+ * Falls back to the bare dial code for the handful of territories that have no
14
+ * example in the metadata, so the hint is never an empty string.
15
+ */
16
+ export declare function phoneExample(iso2: PhoneCountry): string;
17
+ //# sourceMappingURL=phoneExample.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"phoneExample.d.ts","sourceRoot":"","sources":["../../src/phone/phoneExample.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAMH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAEvD;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,YAAY,GAAG,MAAM,CAEvD"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Example numbers for the actionable half of a validation message (ADR-0017 REQ-003:
3
+ * "what's wrong — how to fix"), e.g. `errorWithHint(msgs.invalid_phone, phoneExample('NO'))`
4
+ * → `'Invalid phone — Ex: +47 40 61 23 45'`.
5
+ *
6
+ * Kept in its own module so consumers that only format or validate do not pull the
7
+ * example metadata (~1.4 kB gz) into their bundle.
8
+ */
9
+ import { getExampleNumber } from 'libphonenumber-js';
10
+ import examples from 'libphonenumber-js/examples.mobile.json';
11
+ import { getPhoneDialCode } from './phoneCountries.js';
12
+ /**
13
+ * A representative mobile number for the country, in international form.
14
+ *
15
+ * Falls back to the bare dial code for the handful of territories that have no
16
+ * example in the metadata, so the hint is never an empty string.
17
+ */
18
+ export function phoneExample(iso2) {
19
+ return getExampleNumber(iso2, examples)?.formatInternational() ?? `+${getPhoneDialCode(iso2)}`;
20
+ }
21
+ //# sourceMappingURL=phoneExample.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"phoneExample.js","sourceRoot":"","sources":["../../src/phone/phoneExample.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AACpD,OAAO,QAAQ,MAAM,wCAAwC,CAAA;AAE7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AAGtD;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,IAAkB;IAC3C,OAAO,gBAAgB,CAAC,IAAI,EAAE,QAAQ,CAAC,EAAE,mBAAmB,EAAE,IAAI,IAAI,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAA;AAClG,CAAC"}
@@ -0,0 +1,142 @@
1
+ /**
2
+ * Phone-number formatting, parsing and validation for ASMA forms (ASMA-7485).
3
+ *
4
+ * The stored form is bare E.164 (`+4748012345`) — digits and a leading `+`, no
5
+ * spaces, no `tel:`. The `tel:` scheme belongs to the render of a click-to-call
6
+ * link and is produced by `phoneTelHref`, never written to a field.
7
+ */
8
+ import type { PhoneCountry } from './phoneCountries.js';
9
+ /** Shortest and longest national significant number in the E.164 plan. */
10
+ export declare const PHONE_MIN_DIGITS = 4;
11
+ export declare const PHONE_MAX_DIGITS = 15;
12
+ export interface ParsedPhone {
13
+ /**
14
+ * The country to *edit* with. Always set, because a field needs a selection even for a value
15
+ * that carries no country of its own — in that case this is `fallbackIso2`.
16
+ */
17
+ iso2: PhoneCountry;
18
+ /**
19
+ * The country the value actually *resolves to*, or `undefined` when nothing in the value
20
+ * says. Mirrors `parsePhoneNr(...).country`, and the two must agree: REQ-007.
21
+ *
22
+ * Read this, not `iso2`, before showing a user what country their stored number belongs to.
23
+ * `iso2` answers "which selection do I put in the picker"; `country` answers "do I actually
24
+ * know". Conflating them is what would let a therapist see a Norwegian flag on a foreign
25
+ * number and "correct" it into somebody else's valid Norwegian one.
26
+ */
27
+ country: PhoneCountry | undefined;
28
+ /** National significant number, digits only — no dial code, no separators. */
29
+ national: string;
30
+ }
31
+ export type PhoneNrParse = {
32
+ ok: true;
33
+ e164: string;
34
+ country: PhoneCountry | undefined;
35
+ callingCode: string;
36
+ } | {
37
+ ok: false;
38
+ reason: 'EMPTY' | 'INVALID';
39
+ input: string;
40
+ };
41
+ /**
42
+ * Canonicalise a value of unknown shape into E.164 — the one function every writer and
43
+ * the backfill share, so runtime and migration agree byte for byte.
44
+ *
45
+ * `defaultRegion` is required rather than defaulted on purpose. Guessing a region at
46
+ * *read* time, repeatedly and implicitly, is what left the fleet with several
47
+ * `+47`-assuming normalizers that disagree; the region is an explicit input applied
48
+ * once, where a value enters the system, and only when the input carries no `+`.
49
+ *
50
+ * Returns a result rather than throwing or coercing: a value that is not a real number
51
+ * under that region — junk like `'12345678'`, or a Swedish national number stored bare
52
+ * in a Norwegian tenant — is unrecoverable by any algorithm and must be reported to a
53
+ * human, never rewritten into something plausible.
54
+ */
55
+ export declare function parsePhoneNr(input: string | null | undefined, defaultRegion: PhoneCountry): PhoneNrParse;
56
+ /**
57
+ * Split a stored value into the country and the national number the field edits.
58
+ *
59
+ * `country` is what the **value** says, and `undefined` when it says nothing recognisable. A
60
+ * leading `+` is evidence: `'+4748'` resolves to `NO` while still being typed, because the dial
61
+ * code names the country even though the number is incomplete. A value with no `+` carries no
62
+ * such evidence, so the fallback is reported as the country only when the numbering plan confirms
63
+ * it — otherwise `country` is `undefined` and `iso2` is merely the selection to edit with.
64
+ *
65
+ * Three shapes reach this function:
66
+ * - E.164 (`'+4748012345'`) — the format this ticket introduces;
67
+ * - a bare national number (`'48012345'`) — every record written before it, which
68
+ * is why `fallbackIso2` exists rather than the value being rejected;
69
+ * - a partially typed `+47…`, which `parsePhoneNumberFromString` cannot parse yet
70
+ * and which therefore falls through to the longest-dial-code match.
71
+ */
72
+ export declare function parsePhoneValue(value: string | null | undefined, fallbackIso2?: PhoneCountry): ParsedPhone;
73
+ /**
74
+ * Compose the stored value from the country and whatever the user typed.
75
+ *
76
+ * Two branches, and the split is the point. Once the input is a real number for the
77
+ * country, the stored value is the library's own E.164 rendering, which drops what a
78
+ * plain `+dialCode + digits` concatenation would double: a trunk prefix (`0701234567`
79
+ * for SE), a redundant country code (`4748012345` for NO) or an IDD prefix
80
+ * (`004748012345`). Concatenating those produced `+460701234567` and `+474748012345`.
81
+ *
82
+ * Until then it falls back to concatenation, because an in-progress number must still
83
+ * round-trip through the store for the field to show it back — so this deliberately
84
+ * does not reject anything. Use `isValidPhone` for the save gate. Returns `''` for an
85
+ * empty national part so an untouched field stores nothing rather than a bare `'+47'`.
86
+ */
87
+ export declare function toE164(nationalInput: string, iso2: PhoneCountry): string;
88
+ /**
89
+ * Progressive per-country grouping for the input mask, e.g. `'48012345'` → `'48 01 23 45'`
90
+ * for NO, `'70 123 45 67'` for SE and `'213 373 4253'` for US.
91
+ *
92
+ * Groups by the country's **international** format rather than its national one, and
93
+ * the difference is not cosmetic: countries with a trunk prefix (SE, GB, DE, FR) define
94
+ * their national formats *with* the leading `0`, so feeding the bare national number to
95
+ * `AsYouType(iso2)` returns it unformatted. The field edits the national part while the
96
+ * selector carries the country code, which is exactly the international shape.
97
+ *
98
+ * Grouping therefore follows each country's official format — for Norwegian numbers
99
+ * `xx xx xx xx`, not the `### ## ###` the legacy `NORWEGIAN_PHONE_NUMBER` constant
100
+ * hardcoded for every Norwegian number regardless of its prefix.
101
+ */
102
+ export declare function formatNationalAsYouType(nationalInput: string, iso2: PhoneCountry): string;
103
+ /**
104
+ * Whether the national number is a real, dialable number for the country —
105
+ * a per-country pattern check, not a digit count. `'00000000'` and `'12345678'`
106
+ * are both rejected for NO, `'48012345'` is accepted.
107
+ */
108
+ export declare function isValidPhone(nationalInput: string, iso2: PhoneCountry): boolean;
109
+ /** Whether a stored value is a valid number, resolving its country from the value itself. */
110
+ export declare function isValidPhoneValue(value: string | null | undefined, fallbackIso2?: PhoneCountry): boolean;
111
+ /**
112
+ * Human-readable international form for read-only views, e.g. `'+47 48 01 23 45'`.
113
+ * Falls back to the stored value, byte for byte, for anything that is not a real number.
114
+ *
115
+ * The fallback covers the 13 production rows whose country cannot be derived — a plus-less
116
+ * `'0701234567'` is a Swedish mobile written nationally, and under the `NO` fallback it is not a
117
+ * number at all. Formatting it anyway produced `'+47 0701234567'`: a country the value never named,
118
+ * attached to digits that are not Norwegian. That is invariant 7 ("junk is refused, not
119
+ * transformed — none of them acquires a `+47` prefix") broken in the render rather than in the
120
+ * column, and it reads to a therapist as a number the system understood.
121
+ *
122
+ * Validity, not parseability, is the test. `parsePhoneNumberFromString` returns an object for
123
+ * `'+470701234567'` too, so the old `?? trimmed` fallback could never fire.
124
+ */
125
+ export declare function formatPhoneForDisplay(value: string | null | undefined, fallbackIso2?: PhoneCountry): string;
126
+ /**
127
+ * `tel:` URI for a click-to-call link — the single place the scheme is added (ASMA-7485).
128
+ * Returns `''` only when the value holds no number at all, so callers can skip the link.
129
+ *
130
+ * A number we can confirm is dialled in its canonical E.164 form. Anything else is still
131
+ * dialable — a therapist has to be able to ring the 13 production rows whose country is not
132
+ * derivable — but it is linked **exactly as stored**, so the dialer opens pre-filled with the
133
+ * digits a human would have read off the field and typed.
134
+ *
135
+ * What it must never link is a number we composed. `'0701234567'` under `NO` used to yield
136
+ * `tel:+470701234567`: a Swedish mobile with a Norwegian code welded on, which is a different
137
+ * subscriber, reads as authoritative, and on a phone dials without asking. `tel:0701234567` is
138
+ * the honest version of the same link — it may not connect from a Norwegian handset either, but
139
+ * it hands the therapist the real digits to complete rather than a confident wrong number.
140
+ */
141
+ export declare function phoneTelHref(value: string | null | undefined, fallbackIso2?: PhoneCountry): string;
142
+ //# sourceMappingURL=phoneNumber.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"phoneNumber.d.ts","sourceRoot":"","sources":["../../src/phone/phoneNumber.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAUH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAEvD,0EAA0E;AAC1E,eAAO,MAAM,gBAAgB,IAAI,CAAA;AACjC,eAAO,MAAM,gBAAgB,KAAK,CAAA;AAElC,MAAM,WAAW,WAAW;IACxB;;;OAGG;IACH,I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GAAG,IAAI,GAAG,SAAS,EAChC,YAAY,GAAE,YAAoC,GACnD,MAAM,CAQR;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,YAAY,CACxB,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAChC,YAAY,GAAE,YAAoC,GACnD,MAAM,CAUR"}
@@ -0,0 +1,198 @@
1
+ /**
2
+ * Phone-number formatting, parsing and validation for ASMA forms (ASMA-7485).
3
+ *
4
+ * The stored form is bare E.164 (`+4748012345`) — digits and a leading `+`, no
5
+ * spaces, no `tel:`. The `tel:` scheme belongs to the render of a click-to-call
6
+ * link and is produced by `phoneTelHref`, never written to a field.
7
+ */
8
+ import { AsYouType, isValidPhoneNumber, parsePhoneNumberFromString, parsePhoneNumberWithError, } from 'libphonenumber-js';
9
+ import { DEFAULT_PHONE_COUNTRY, findCountryByDialCode, getPhoneDialCode } from './phoneCountries.js';
10
+ /** Shortest and longest national significant number in the E.164 plan. */
11
+ export const PHONE_MIN_DIGITS = 4;
12
+ export const PHONE_MAX_DIGITS = 15;
13
+ const digitsOnly = (value) => value.replace(/\D/g, '');
14
+ /**
15
+ * Canonicalise a value of unknown shape into E.164 — the one function every writer and
16
+ * the backfill share, so runtime and migration agree byte for byte.
17
+ *
18
+ * `defaultRegion` is required rather than defaulted on purpose. Guessing a region at
19
+ * *read* time, repeatedly and implicitly, is what left the fleet with several
20
+ * `+47`-assuming normalizers that disagree; the region is an explicit input applied
21
+ * once, where a value enters the system, and only when the input carries no `+`.
22
+ *
23
+ * Returns a result rather than throwing or coercing: a value that is not a real number
24
+ * under that region — junk like `'12345678'`, or a Swedish national number stored bare
25
+ * in a Norwegian tenant — is unrecoverable by any algorithm and must be reported to a
26
+ * human, never rewritten into something plausible.
27
+ */
28
+ export function parsePhoneNr(input, defaultRegion) {
29
+ const text = (input ?? '').trim();
30
+ if (text.length === 0)
31
+ return { ok: false, reason: 'EMPTY', input: text };
32
+ try {
33
+ const parsed = parsePhoneNumberWithError(text, defaultRegion);
34
+ if (!parsed.isValid())
35
+ return { ok: false, reason: 'INVALID', input: text };
36
+ return { ok: true, e164: parsed.number, country: parsed.country, callingCode: parsed.countryCallingCode };
37
+ }
38
+ catch {
39
+ return { ok: false, reason: 'INVALID', input: text };
40
+ }
41
+ }
42
+ /**
43
+ * Split a stored value into the country and the national number the field edits.
44
+ *
45
+ * `country` is what the **value** says, and `undefined` when it says nothing recognisable. A
46
+ * leading `+` is evidence: `'+4748'` resolves to `NO` while still being typed, because the dial
47
+ * code names the country even though the number is incomplete. A value with no `+` carries no
48
+ * such evidence, so the fallback is reported as the country only when the numbering plan confirms
49
+ * it — otherwise `country` is `undefined` and `iso2` is merely the selection to edit with.
50
+ *
51
+ * Three shapes reach this function:
52
+ * - E.164 (`'+4748012345'`) — the format this ticket introduces;
53
+ * - a bare national number (`'48012345'`) — every record written before it, which
54
+ * is why `fallbackIso2` exists rather than the value being rejected;
55
+ * - a partially typed `+47…`, which `parsePhoneNumberFromString` cannot parse yet
56
+ * and which therefore falls through to the longest-dial-code match.
57
+ */
58
+ export function parsePhoneValue(value, fallbackIso2 = DEFAULT_PHONE_COUNTRY) {
59
+ const trimmed = (value ?? '').trim();
60
+ if (trimmed.length === 0)
61
+ return { iso2: fallbackIso2, country: undefined, national: '' };
62
+ if (!trimmed.startsWith('+')) {
63
+ // No `+`, so the value itself names no country. The fallback is only *confirmed* when the
64
+ // digits are a real number under it; otherwise the country stays unknown and the caller
65
+ // must not present the fallback as fact. `libphonenumber-js` cannot recover a foreign
66
+ // calling code from a plus-less string — `'37376002949'` under `NO` yields `+4737376002949`
67
+ // with `isValid() === false`, not Moldova — so guessing here is always a guess.
68
+ const national = digitsOnly(trimmed);
69
+ const confirmed = isValidPhone(national, fallbackIso2);
70
+ return { iso2: fallbackIso2, country: confirmed ? fallbackIso2 : undefined, national };
71
+ }
72
+ const parsed = parsePhoneNumberFromString(trimmed);
73
+ if (parsed?.country !== undefined) {
74
+ return { iso2: parsed.country, country: parsed.country, national: parsed.nationalNumber };
75
+ }
76
+ const digits = digitsOnly(trimmed);
77
+ // Keep the country the caller already holds when the digits still agree with it,
78
+ // so typing `+47…` one character at a time never reassigns the user's selection
79
+ // to another country sharing the prefix.
80
+ const fallbackDialCode = getPhoneDialCode(fallbackIso2);
81
+ if (digits.startsWith(fallbackDialCode)) {
82
+ return { iso2: fallbackIso2, country: fallbackIso2, national: digits.slice(fallbackDialCode.length) };
83
+ }
84
+ const iso2 = findCountryByDialCode(digits);
85
+ if (iso2 === undefined)
86
+ return { iso2: fallbackIso2, country: undefined, national: digits };
87
+ return { iso2, country: iso2, national: digits.slice(getPhoneDialCode(iso2).length) };
88
+ }
89
+ /**
90
+ * Compose the stored value from the country and whatever the user typed.
91
+ *
92
+ * Two branches, and the split is the point. Once the input is a real number for the
93
+ * country, the stored value is the library's own E.164 rendering, which drops what a
94
+ * plain `+dialCode + digits` concatenation would double: a trunk prefix (`0701234567`
95
+ * for SE), a redundant country code (`4748012345` for NO) or an IDD prefix
96
+ * (`004748012345`). Concatenating those produced `+460701234567` and `+474748012345`.
97
+ *
98
+ * Until then it falls back to concatenation, because an in-progress number must still
99
+ * round-trip through the store for the field to show it back — so this deliberately
100
+ * does not reject anything. Use `isValidPhone` for the save gate. Returns `''` for an
101
+ * empty national part so an untouched field stores nothing rather than a bare `'+47'`.
102
+ */
103
+ export function toE164(nationalInput, iso2) {
104
+ const digits = digitsOnly(nationalInput);
105
+ if (digits.length === 0)
106
+ return '';
107
+ const parsed = parsePhoneNumberFromString(digits, iso2);
108
+ if (parsed?.isValid() === true)
109
+ return parsed.number;
110
+ return `+${getPhoneDialCode(iso2)}${digits}`;
111
+ }
112
+ /**
113
+ * Progressive per-country grouping for the input mask, e.g. `'48012345'` → `'48 01 23 45'`
114
+ * for NO, `'70 123 45 67'` for SE and `'213 373 4253'` for US.
115
+ *
116
+ * Groups by the country's **international** format rather than its national one, and
117
+ * the difference is not cosmetic: countries with a trunk prefix (SE, GB, DE, FR) define
118
+ * their national formats *with* the leading `0`, so feeding the bare national number to
119
+ * `AsYouType(iso2)` returns it unformatted. The field edits the national part while the
120
+ * selector carries the country code, which is exactly the international shape.
121
+ *
122
+ * Grouping therefore follows each country's official format — for Norwegian numbers
123
+ * `xx xx xx xx`, not the `### ## ###` the legacy `NORWEGIAN_PHONE_NUMBER` constant
124
+ * hardcoded for every Norwegian number regardless of its prefix.
125
+ */
126
+ export function formatNationalAsYouType(nationalInput, iso2) {
127
+ const digits = digitsOnly(nationalInput);
128
+ if (digits.length === 0)
129
+ return '';
130
+ const dialCode = `+${getPhoneDialCode(iso2)}`;
131
+ const formatted = new AsYouType().input(`${dialCode}${digits}`);
132
+ return formatted.startsWith(dialCode) ? formatted.slice(dialCode.length).trimStart() : formatted;
133
+ }
134
+ /**
135
+ * Whether the national number is a real, dialable number for the country —
136
+ * a per-country pattern check, not a digit count. `'00000000'` and `'12345678'`
137
+ * are both rejected for NO, `'48012345'` is accepted.
138
+ */
139
+ export function isValidPhone(nationalInput, iso2) {
140
+ const digits = digitsOnly(nationalInput);
141
+ if (digits.length < PHONE_MIN_DIGITS || digits.length > PHONE_MAX_DIGITS)
142
+ return false;
143
+ return isValidPhoneNumber(digits, iso2);
144
+ }
145
+ /** Whether a stored value is a valid number, resolving its country from the value itself. */
146
+ export function isValidPhoneValue(value, fallbackIso2 = DEFAULT_PHONE_COUNTRY) {
147
+ const { iso2, national } = parsePhoneValue(value, fallbackIso2);
148
+ return isValidPhone(national, iso2);
149
+ }
150
+ /**
151
+ * Human-readable international form for read-only views, e.g. `'+47 48 01 23 45'`.
152
+ * Falls back to the stored value, byte for byte, for anything that is not a real number.
153
+ *
154
+ * The fallback covers the 13 production rows whose country cannot be derived — a plus-less
155
+ * `'0701234567'` is a Swedish mobile written nationally, and under the `NO` fallback it is not a
156
+ * number at all. Formatting it anyway produced `'+47 0701234567'`: a country the value never named,
157
+ * attached to digits that are not Norwegian. That is invariant 7 ("junk is refused, not
158
+ * transformed — none of them acquires a `+47` prefix") broken in the render rather than in the
159
+ * column, and it reads to a therapist as a number the system understood.
160
+ *
161
+ * Validity, not parseability, is the test. `parsePhoneNumberFromString` returns an object for
162
+ * `'+470701234567'` too, so the old `?? trimmed` fallback could never fire.
163
+ */
164
+ export function formatPhoneForDisplay(value, fallbackIso2 = DEFAULT_PHONE_COUNTRY) {
165
+ const trimmed = (value ?? '').trim();
166
+ if (trimmed.length === 0)
167
+ return '';
168
+ const { iso2, national } = parsePhoneValue(trimmed, fallbackIso2);
169
+ const parsed = parsePhoneNumberFromString(toE164(national, iso2));
170
+ return parsed?.isValid() === true ? parsed.formatInternational() : trimmed;
171
+ }
172
+ /**
173
+ * `tel:` URI for a click-to-call link — the single place the scheme is added (ASMA-7485).
174
+ * Returns `''` only when the value holds no number at all, so callers can skip the link.
175
+ *
176
+ * A number we can confirm is dialled in its canonical E.164 form. Anything else is still
177
+ * dialable — a therapist has to be able to ring the 13 production rows whose country is not
178
+ * derivable — but it is linked **exactly as stored**, so the dialer opens pre-filled with the
179
+ * digits a human would have read off the field and typed.
180
+ *
181
+ * What it must never link is a number we composed. `'0701234567'` under `NO` used to yield
182
+ * `tel:+470701234567`: a Swedish mobile with a Norwegian code welded on, which is a different
183
+ * subscriber, reads as authoritative, and on a phone dials without asking. `tel:0701234567` is
184
+ * the honest version of the same link — it may not connect from a Norwegian handset either, but
185
+ * it hands the therapist the real digits to complete rather than a confident wrong number.
186
+ */
187
+ export function phoneTelHref(value, fallbackIso2 = DEFAULT_PHONE_COUNTRY) {
188
+ const { iso2, national } = parsePhoneValue(value, fallbackIso2);
189
+ if (isValidPhone(national, iso2))
190
+ return `tel:${toE164(national, iso2)}`;
191
+ const trimmed = (value ?? '').trim();
192
+ const digits = digitsOnly(trimmed);
193
+ if (digits.length < PHONE_MIN_DIGITS)
194
+ return '';
195
+ // The leading `+` is kept when the stored value carried one, and never added when it did not.
196
+ return `tel:${trimmed.startsWith('+') ? '+' : ''}${digits}`;
197
+ }
198
+ //# sourceMappingURL=phoneN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