web_lib

Common web application libraries
git clone https://radroots.dev/git/web_lib.git
Log | Files | Refs | LICENSE

types.ts (1898B)


      1 import { IError } from "@radroots/types-bindings";
      2 import type { GeolocationPoint } from "@radroots/geo";
      3 import type { ResultObj, ResultsList } from "@radroots/utils";
      4 
      5 export type GeocoderIError =
      6     | `*-result`
      7     | `*-statement`
      8     | `*-db`
      9     | `*`
     10 
     11 export type GeocoderReverseResult = {
     12     id: number;
     13     name: string;
     14     admin1_id: string | number;
     15     admin1_name: string;
     16     country_id: string;
     17     country_name: string;
     18     latitude: number;
     19     longitude: number;
     20 };
     21 
     22 export type GeocoderDegreeOffset = 0.5 | 1.0 | 1.5 | 2.0 | 2.5 | 3
     23 
     24 export type GeocoderConfig = {
     25     database_path?: string;
     26 };
     27 
     28 export type GeocoderConnectConfig = GeocoderConfig & {
     29     wasm_path?: string;
     30 };
     31 
     32 export type IGeocoderReverseOpts = {
     33     degree_offset?: GeocoderDegreeOffset;
     34     limit?: number | false;
     35 };
     36 
     37 export type IGeocoderCountryCenter = {
     38     country_id: string;
     39 };
     40 
     41 export type IGeocoderCountryListResult = GeolocationPoint & { country_id: string; country: string };
     42 
     43 export type IGeocoderConnectResolve = true | IError<GeocoderIError>;
     44 export type IGeocoderReverseResolve = ResultsList<GeocoderReverseResult> | IError<GeocoderIError>;
     45 export type IGeocoderCountryResolve = ResultsList<GeocoderReverseResult> | IError<GeocoderIError>;
     46 export type IGeocoderCountryListResolve = ResultsList<IGeocoderCountryListResult> | IError<GeocoderIError>;
     47 export type IGeocoderCountryCenterResolve = ResultObj<GeolocationPoint> | IError<GeocoderIError>;
     48 
     49 export type IGeocoder = {
     50     connect(config?: GeocoderConnectConfig | string): Promise<IGeocoderConnectResolve>;
     51     reverse(point: GeolocationPoint, opts?: IGeocoderReverseOpts): Promise<IGeocoderReverseResolve>;
     52     country(opts: IGeocoderCountryCenter): Promise<IGeocoderCountryResolve>;
     53     country_list(): Promise<IGeocoderCountryListResolve>;
     54     country_center(opts: IGeocoderCountryCenter): Promise<IGeocoderCountryCenterResolve>;
     55 }