thai-address-sdk 0.1.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 +539 -0
- package/THIRD_PARTY_LICENSES.md +27 -0
- package/dist/index.cjs +75335 -0
- package/dist/index.d.cts +100 -0
- package/dist/index.d.ts +100 -0
- package/dist/index.js +75296 -0
- package/package.json +38 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
type AddressLevel = "province" | "district" | "subdistrict";
|
|
2
|
+
type AddressFormat = "full_th" | "short_th" | "plain_th" | "en";
|
|
3
|
+
type MatchType = "exact" | "alias" | "prefix" | "contains" | "fuzzy";
|
|
4
|
+
interface Province {
|
|
5
|
+
id: number;
|
|
6
|
+
provinceCode: number;
|
|
7
|
+
provinceNameEn: string;
|
|
8
|
+
provinceNameTh: string;
|
|
9
|
+
}
|
|
10
|
+
interface District {
|
|
11
|
+
id: number;
|
|
12
|
+
provinceCode: number;
|
|
13
|
+
districtCode: number;
|
|
14
|
+
districtNameEn: string;
|
|
15
|
+
districtNameTh: string;
|
|
16
|
+
postalCode: number;
|
|
17
|
+
}
|
|
18
|
+
interface Subdistrict {
|
|
19
|
+
id: number;
|
|
20
|
+
provinceCode: number;
|
|
21
|
+
districtCode: number;
|
|
22
|
+
subdistrictCode: number;
|
|
23
|
+
subdistrictNameEn: string;
|
|
24
|
+
subdistrictNameTh: string;
|
|
25
|
+
postalCode: number;
|
|
26
|
+
}
|
|
27
|
+
interface AddressHierarchy {
|
|
28
|
+
province: Province;
|
|
29
|
+
district?: District;
|
|
30
|
+
subdistrict?: Subdistrict;
|
|
31
|
+
postalCode?: number;
|
|
32
|
+
formattedAddress: string;
|
|
33
|
+
}
|
|
34
|
+
interface MatchMetadata {
|
|
35
|
+
input: string;
|
|
36
|
+
matchedText: string;
|
|
37
|
+
matchType: MatchType;
|
|
38
|
+
confidence: number;
|
|
39
|
+
corrected: boolean;
|
|
40
|
+
}
|
|
41
|
+
interface SearchResult extends AddressHierarchy {
|
|
42
|
+
type: AddressLevel;
|
|
43
|
+
match: MatchMetadata;
|
|
44
|
+
}
|
|
45
|
+
interface SearchOptions {
|
|
46
|
+
levels?: AddressLevel[];
|
|
47
|
+
limit?: number;
|
|
48
|
+
minScore?: number;
|
|
49
|
+
format?: AddressFormat;
|
|
50
|
+
}
|
|
51
|
+
interface FilterOptions {
|
|
52
|
+
provinceCode?: number;
|
|
53
|
+
districtCode?: number;
|
|
54
|
+
}
|
|
55
|
+
interface NormalizeOptions {
|
|
56
|
+
format?: AddressFormat;
|
|
57
|
+
limit?: number;
|
|
58
|
+
minScore?: number;
|
|
59
|
+
}
|
|
60
|
+
interface Correction {
|
|
61
|
+
input: string;
|
|
62
|
+
normalized: string;
|
|
63
|
+
field: AddressLevel;
|
|
64
|
+
matchType: MatchType;
|
|
65
|
+
}
|
|
66
|
+
type NormalizeStatus = "matched" | "partial" | "ambiguous" | "not_found";
|
|
67
|
+
interface NormalizeResult {
|
|
68
|
+
input: string;
|
|
69
|
+
normalizedInput: string;
|
|
70
|
+
status: NormalizeStatus;
|
|
71
|
+
bestMatch: AddressHierarchy | null;
|
|
72
|
+
confidence: number;
|
|
73
|
+
alternatives: AddressHierarchy[];
|
|
74
|
+
corrections: Correction[];
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
declare function getProvinces(): readonly Province[];
|
|
78
|
+
declare function getProvince(provinceCode: number): Province | undefined;
|
|
79
|
+
declare function getDistricts(options?: Pick<FilterOptions, "provinceCode">): District[];
|
|
80
|
+
declare function getDistrict(districtCode: number): District | undefined;
|
|
81
|
+
declare function getSubdistricts(options?: FilterOptions): Subdistrict[];
|
|
82
|
+
declare function getSubdistrict(subdistrictCode: number): Subdistrict | undefined;
|
|
83
|
+
|
|
84
|
+
interface FormatInput {
|
|
85
|
+
province: Province;
|
|
86
|
+
district?: District;
|
|
87
|
+
subdistrict?: Subdistrict;
|
|
88
|
+
}
|
|
89
|
+
declare function formatAddress(address: FormatInput, format?: AddressFormat): string;
|
|
90
|
+
|
|
91
|
+
declare function normalizeAddress(input: string, options?: NormalizeOptions): NormalizeResult;
|
|
92
|
+
declare const smartSearch: typeof normalizeAddress;
|
|
93
|
+
|
|
94
|
+
declare function search(query: string, options?: SearchOptions): SearchResult[];
|
|
95
|
+
|
|
96
|
+
declare function normalizeText(value: string): string;
|
|
97
|
+
declare function stripAddressLabels(value: string): string;
|
|
98
|
+
declare function damerauLevenshtein(left: string, right: string): number;
|
|
99
|
+
|
|
100
|
+
export { type AddressFormat, type AddressHierarchy, type AddressLevel, type Correction, type District, type FilterOptions, type MatchMetadata, type MatchType, type NormalizeOptions, type NormalizeResult, type NormalizeStatus, type Province, type SearchOptions, type SearchResult, type Subdistrict, damerauLevenshtein, formatAddress, getDistrict, getDistricts, getProvince, getProvinces, getSubdistrict, getSubdistricts, normalizeAddress, normalizeText, search, smartSearch, stripAddressLabels };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
type AddressLevel = "province" | "district" | "subdistrict";
|
|
2
|
+
type AddressFormat = "full_th" | "short_th" | "plain_th" | "en";
|
|
3
|
+
type MatchType = "exact" | "alias" | "prefix" | "contains" | "fuzzy";
|
|
4
|
+
interface Province {
|
|
5
|
+
id: number;
|
|
6
|
+
provinceCode: number;
|
|
7
|
+
provinceNameEn: string;
|
|
8
|
+
provinceNameTh: string;
|
|
9
|
+
}
|
|
10
|
+
interface District {
|
|
11
|
+
id: number;
|
|
12
|
+
provinceCode: number;
|
|
13
|
+
districtCode: number;
|
|
14
|
+
districtNameEn: string;
|
|
15
|
+
districtNameTh: string;
|
|
16
|
+
postalCode: number;
|
|
17
|
+
}
|
|
18
|
+
interface Subdistrict {
|
|
19
|
+
id: number;
|
|
20
|
+
provinceCode: number;
|
|
21
|
+
districtCode: number;
|
|
22
|
+
subdistrictCode: number;
|
|
23
|
+
subdistrictNameEn: string;
|
|
24
|
+
subdistrictNameTh: string;
|
|
25
|
+
postalCode: number;
|
|
26
|
+
}
|
|
27
|
+
interface AddressHierarchy {
|
|
28
|
+
province: Province;
|
|
29
|
+
district?: District;
|
|
30
|
+
subdistrict?: Subdistrict;
|
|
31
|
+
postalCode?: number;
|
|
32
|
+
formattedAddress: string;
|
|
33
|
+
}
|
|
34
|
+
interface MatchMetadata {
|
|
35
|
+
input: string;
|
|
36
|
+
matchedText: string;
|
|
37
|
+
matchType: MatchType;
|
|
38
|
+
confidence: number;
|
|
39
|
+
corrected: boolean;
|
|
40
|
+
}
|
|
41
|
+
interface SearchResult extends AddressHierarchy {
|
|
42
|
+
type: AddressLevel;
|
|
43
|
+
match: MatchMetadata;
|
|
44
|
+
}
|
|
45
|
+
interface SearchOptions {
|
|
46
|
+
levels?: AddressLevel[];
|
|
47
|
+
limit?: number;
|
|
48
|
+
minScore?: number;
|
|
49
|
+
format?: AddressFormat;
|
|
50
|
+
}
|
|
51
|
+
interface FilterOptions {
|
|
52
|
+
provinceCode?: number;
|
|
53
|
+
districtCode?: number;
|
|
54
|
+
}
|
|
55
|
+
interface NormalizeOptions {
|
|
56
|
+
format?: AddressFormat;
|
|
57
|
+
limit?: number;
|
|
58
|
+
minScore?: number;
|
|
59
|
+
}
|
|
60
|
+
interface Correction {
|
|
61
|
+
input: string;
|
|
62
|
+
normalized: string;
|
|
63
|
+
field: AddressLevel;
|
|
64
|
+
matchType: MatchType;
|
|
65
|
+
}
|
|
66
|
+
type NormalizeStatus = "matched" | "partial" | "ambiguous" | "not_found";
|
|
67
|
+
interface NormalizeResult {
|
|
68
|
+
input: string;
|
|
69
|
+
normalizedInput: string;
|
|
70
|
+
status: NormalizeStatus;
|
|
71
|
+
bestMatch: AddressHierarchy | null;
|
|
72
|
+
confidence: number;
|
|
73
|
+
alternatives: AddressHierarchy[];
|
|
74
|
+
corrections: Correction[];
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
declare function getProvinces(): readonly Province[];
|
|
78
|
+
declare function getProvince(provinceCode: number): Province | undefined;
|
|
79
|
+
declare function getDistricts(options?: Pick<FilterOptions, "provinceCode">): District[];
|
|
80
|
+
declare function getDistrict(districtCode: number): District | undefined;
|
|
81
|
+
declare function getSubdistricts(options?: FilterOptions): Subdistrict[];
|
|
82
|
+
declare function getSubdistrict(subdistrictCode: number): Subdistrict | undefined;
|
|
83
|
+
|
|
84
|
+
interface FormatInput {
|
|
85
|
+
province: Province;
|
|
86
|
+
district?: District;
|
|
87
|
+
subdistrict?: Subdistrict;
|
|
88
|
+
}
|
|
89
|
+
declare function formatAddress(address: FormatInput, format?: AddressFormat): string;
|
|
90
|
+
|
|
91
|
+
declare function normalizeAddress(input: string, options?: NormalizeOptions): NormalizeResult;
|
|
92
|
+
declare const smartSearch: typeof normalizeAddress;
|
|
93
|
+
|
|
94
|
+
declare function search(query: string, options?: SearchOptions): SearchResult[];
|
|
95
|
+
|
|
96
|
+
declare function normalizeText(value: string): string;
|
|
97
|
+
declare function stripAddressLabels(value: string): string;
|
|
98
|
+
declare function damerauLevenshtein(left: string, right: string): number;
|
|
99
|
+
|
|
100
|
+
export { type AddressFormat, type AddressHierarchy, type AddressLevel, type Correction, type District, type FilterOptions, type MatchMetadata, type MatchType, type NormalizeOptions, type NormalizeResult, type NormalizeStatus, type Province, type SearchOptions, type SearchResult, type Subdistrict, damerauLevenshtein, formatAddress, getDistrict, getDistricts, getProvince, getProvinces, getSubdistrict, getSubdistricts, normalizeAddress, normalizeText, search, smartSearch, stripAddressLabels };
|