@scottlexium/finpro
Version:
🚀 FinPro.js by Scott Lexium - The most comprehensive TypeScript library for financial data operations. Features 154+ currencies, 250+ countries, MongoDB-style queries, dual ESM/CommonJS support, and flag integration. Created by Scott Lexium for modern Ja
168 lines • 4.99 kB
TypeScript
import { continents } from './data/continents';
import { countries } from './data/countries';
import { languages } from './data/languages';
export type TContinentCode = keyof typeof continents;
export type TCountryCode = keyof typeof countries;
export type TLanguageCode = keyof typeof languages;
/**
* Core types for FinPro.js
*/
export interface Entity {
readonly id?: string;
}
export interface Currency extends Entity {
readonly id: string;
readonly type: 'fiat';
readonly code: string;
readonly symbol: string;
readonly name: string;
readonly decimals: number;
readonly isActive: boolean;
readonly countries: readonly string[];
readonly region?: string;
readonly centralBank?: string;
}
export interface Country extends Entity {
readonly name: string;
readonly native: string;
readonly phone: readonly number[];
readonly continent: string;
readonly capital: string;
readonly currency: readonly string[];
readonly languages: readonly string[];
}
export interface State extends Entity {
readonly code: string;
readonly name: string;
readonly type: string;
readonly country_code: string;
}
export interface Language extends Entity {
readonly name: string;
readonly native: string;
readonly rtl?: number;
}
export interface QueryOptions {
readonly limit?: number;
readonly skip?: number;
readonly sort?: Record<string, 1 | -1>;
}
export interface FindOptions extends QueryOptions {
readonly populate?: string[];
}
export type QueryFilter<T> = {
[K in keyof T]?: T[K] | {
$in?: T[K][];
} | {
$regex?: string | RegExp;
} | {
$gt?: T[K];
} | {
$gte?: T[K];
} | {
$lt?: T[K];
} | {
$lte?: T[K];
};
};
export interface QueryBuilder<T extends Entity> {
find(filter?: Partial<T>): QueryBuilder<T>;
findOne(filter?: Partial<T>): T | null;
findById(id: string): T | null;
where<K extends keyof T>(field: K, value?: any): QueryBuilder<T>;
equals(value: any): QueryBuilder<T>;
in(values: any[]): QueryBuilder<T>;
regex(pattern: string | RegExp, options?: string): QueryBuilder<T>;
gt(value: any): QueryBuilder<T>;
gte(value: any): QueryBuilder<T>;
lt(value: any): QueryBuilder<T>;
lte(value: any): QueryBuilder<T>;
sort(options: string | Partial<Record<keyof T, 1 | -1>>): QueryBuilder<T>;
limit(count: number): QueryBuilder<T>;
skip(count: number): QueryBuilder<T>;
populate(field: string): QueryBuilder<T>;
exec(): T[];
count(): number;
}
export interface FormatOptions {
readonly locale?: string;
readonly style?: 'currency' | 'decimal' | 'percent';
readonly minimumFractionDigits?: number;
readonly maximumFractionDigits?: number;
readonly useGrouping?: boolean;
}
export interface FlagOptions {
readonly format?: 'svg' | 'png';
readonly size?: 'w20' | 'w40' | 'w80' | 'w160' | 'w320' | 'w640' | 'w1280';
}
export interface CurrencyWithFlags extends Currency {
readonly flag?: string;
readonly flags?: {
readonly svg?: string;
readonly png?: Record<string, string>;
readonly allCountries?: Record<string, string>;
};
}
export interface ILanguage {
/**
* Language name in English.
*/
name: string;
/**
* Language name written natively.
*/
native: string;
/**
* Specified if Language is RTL.
*/
rtl?: number;
}
export interface ICountry {
/**
* Country name in English.
*/
name: string;
/**
* Country name written natively.
*/
native: string;
/**
* Calling phone codes.
*/
phone: number[];
/**
* Main continent alpha-2 code.
*/
continent: TContinentCode;
/**
* Continent list alpha-2 codes (for transcontinental countries).
*/
continents?: TContinentCode[];
/**
* Capital city of the country.
*/
capital: string;
/**
* Currency alpha-3 codes.
*/
currency: string[];
/**
* List of Country's spoken Languages (alpha-2 codes).
*/
languages: TLanguageCode[];
/**
* Specified in cases when entity is currently a part of another one.
* Example: Ã…land is an autonomous and demilitarised region of Finland and has own ISO code.
* @see: https://en.wikipedia.org/wiki/Ã…land
* @todo: Type should be TCountryCode, but need to resolve cyclic referencing on dynamically generated type.
*/
partOf?: string;
/**
* Specified in cases when entity is not a part of the main ISO 3166-1 standart, but a User assigned code.
* @see: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#User-assigned_code_elements
*/
userAssigned?: boolean;
}
export type { CryptoCurrency, DeFiToken, NFT } from './modules/crypto';
export type { Commodity, PreciousMetal, Energy, Agriculture } from './modules/commodities';
//# sourceMappingURL=types.d.ts.map