1 | import {
|
2 | Metadata,
|
3 | PhoneNumber,
|
4 | E164Number,
|
5 | CountryCallingCode,
|
6 | CountryCode,
|
7 | CarrierCode,
|
8 | NationalNumber,
|
9 | Extension,
|
10 | ParseError,
|
11 | NumberFoundLegacy,
|
12 | NumberFound,
|
13 | NumberType,
|
14 | NumberFormat
|
15 | } from './types';
|
16 |
|
17 | export {
|
18 | Metadata,
|
19 | PhoneNumber,
|
20 | E164Number,
|
21 | CountryCallingCode,
|
22 | CountryCode,
|
23 | CarrierCode,
|
24 | NationalNumber,
|
25 | Extension,
|
26 | ParseError,
|
27 | NumberFoundLegacy,
|
28 | NumberFound,
|
29 | NumberFormat,
|
30 | NumberType
|
31 | };
|
32 |
|
33 | type FormatExtension = (number: string, extension: string, metadata: Metadata) => string
|
34 |
|
35 | type FormatNumberOptionsWithoutIDD = {
|
36 | v2?: boolean;
|
37 | formatExtension?: FormatExtension;
|
38 | };
|
39 |
|
40 | export type FormatNumberOptions = {
|
41 | v2?: boolean;
|
42 | fromCountry?: CountryCode;
|
43 | humanReadable?: boolean;
|
44 | formatExtension?: FormatExtension
|
45 | };
|
46 |
|
47 |
|
48 | export type ParseNumberOptions = {
|
49 | defaultCountry?: CountryCode;
|
50 | extended?: boolean;
|
51 | };
|
52 |
|
53 | export interface ParsedNumber {
|
54 | countryCallingCode?: CountryCallingCode,
|
55 | country: CountryCode,
|
56 | phone: NationalNumber,
|
57 | ext?: Extension,
|
58 | possible?: boolean,
|
59 | valid?: boolean
|
60 | }
|
61 |
|
62 |
|
63 | export function parsePhoneNumber(text: string, defaultCountry?: CountryCode): PhoneNumber;
|
64 | export function parsePhoneNumberWithError(text: string, defaultCountry?: CountryCode): PhoneNumber;
|
65 |
|
66 |
|
67 |
|
68 | export function parsePhoneNumberFromString(text: string, defaultCountry?: CountryCode | { defaultCountry?: CountryCode, defaultCallingCode?: string }): PhoneNumber | undefined;
|
69 |
|
70 | export default parsePhoneNumberFromString;
|
71 |
|
72 |
|
73 |
|
74 | export function parse(text: string, options?: CountryCode | ParseNumberOptions): ParsedNumber;
|
75 |
|
76 | export function parseNumber(text: string, options?: CountryCode | ParseNumberOptions): ParsedNumber | {};
|
77 |
|
78 |
|
79 |
|
80 | export function format(parsedNumber: ParsedNumber, format: NumberFormat): string;
|
81 | export function format(phone: NationalNumber, format: NumberFormat): string;
|
82 | export function format(phone: NationalNumber, country: CountryCode, format: NumberFormat): string;
|
83 |
|
84 | export function formatNumber(parsedNumber: ParsedNumber, format: NumberFormat, options?: FormatNumberOptions): string;
|
85 | export function formatNumber(phone: NationalNumber, format: NumberFormat, options?: FormatNumberOptions): string;
|
86 | export function formatNumber(phone: NationalNumber, country: CountryCode, format: NumberFormat, options?: FormatNumberOptions): string;
|
87 |
|
88 | export function getNumberType(parsedNumber: ParsedNumber): NumberType;
|
89 | export function getNumberType(phone: NationalNumber, country?: CountryCode): NumberType;
|
90 |
|
91 | export function getExampleNumber(country: CountryCode, examples: { [country in CountryCode]: NationalNumber }): PhoneNumber | undefined;
|
92 |
|
93 | export function isPossibleNumber(parsedNumber: ParsedNumber): boolean;
|
94 | export function isPossibleNumber(phone: NationalNumber, country?: CountryCode): boolean;
|
95 |
|
96 | export function isValidNumber(parsedNumber: ParsedNumber): boolean;
|
97 | export function isValidNumber(phone: NationalNumber, country?: CountryCode): boolean;
|
98 |
|
99 | export function isValidNumberForRegion(phone: NationalNumber, country: CountryCode): boolean;
|
100 |
|
101 |
|
102 | export function findParsedNumbers(text: string, options?: CountryCode | { defaultCountry?: CountryCode }): NumberFoundLegacy[];
|
103 | export function searchParsedNumbers(text: string, options?: CountryCode | { defaultCountry?: CountryCode }): IterableIterator<NumberFoundLegacy>;
|
104 |
|
105 |
|
106 | export class ParsedNumberSearch {
|
107 | constructor(text: string, options?: { defaultCountry?: CountryCode });
|
108 | hasNext(): boolean;
|
109 | next(): NumberFoundLegacy | undefined;
|
110 | }
|
111 |
|
112 | export function findNumbers(text: string, options?: CountryCode): NumberFoundLegacy[];
|
113 | export function searchNumbers(text: string, options?: CountryCode): IterableIterator<NumberFoundLegacy>;
|
114 |
|
115 | export function findNumbers(text: string, options?: { defaultCountry?: CountryCode, v2: true }): NumberFound[];
|
116 | export function searchNumbers(text: string, options?: { defaultCountry?: CountryCode, v2: true }): IterableIterator<NumberFound>;
|
117 |
|
118 | export function findPhoneNumbersInText(text: string, options?: CountryCode | { defaultCountry?: CountryCode, defaultCallingCode?: string }): NumberFound[];
|
119 | export function searchPhoneNumbersInText(text: string, options?: CountryCode | { defaultCountry?: CountryCode, defaultCallingCode?: string }): IterableIterator<NumberFound>;
|
120 |
|
121 | export class PhoneNumberMatcher {
|
122 | constructor(text: string, options?: { defaultCountry?: CountryCode, v2: true });
|
123 | hasNext(): boolean;
|
124 | next(): NumberFound | undefined;
|
125 | }
|
126 |
|
127 | export function getCountries(): CountryCode[];
|
128 | export function getCountryCallingCode(countryCode: CountryCode): CountryCallingCode;
|
129 | // Deprecated.
|
130 | export function getPhoneCode(countryCode: CountryCode): CountryCallingCode;
|
131 | export function getExtPrefix(countryCode: CountryCode): string;
|
132 | export function isSupportedCountry(countryCode: string): boolean;
|
133 |
|
134 | export function formatIncompletePhoneNumber(number: string, countryCode?: CountryCode): string;
|
135 | export function parseIncompletePhoneNumber(text: string): string;
|
136 | export function parsePhoneNumberCharacter(character: string): string;
|
137 | export function parseDigits(character: string): string;
|
138 |
|
139 | export class AsYouType {
|
140 | constructor(defaultCountryCode?: CountryCode | { defaultCountry?: CountryCode, defaultCallingCode?: string });
|
141 | input(text: string): string;
|
142 | reset(): void;
|
143 | country: CountryCode | undefined;
|
144 | getNumber(): PhoneNumber | undefined;
|
145 | getNationalNumber(): string;
|
146 | getChars(): string;
|
147 | getTemplate(): string;
|
148 | }
|
149 |
|
150 | // The exported `Metadata` name is already used for exporting the "raw" JSON metadata type.
|
151 | // Then, `Metadata` class has become exported, but its name is already taken, so TypeScript users seem to be unable to use the `Metadata` class.
|
152 | // If someone knows a solution then they could propose it in an issue.
|
153 | // export class Metadata {
|
154 |
|
155 |
|
\ | No newline at end of file |