@cranberry-money/shared-utils 8.17.8 → 8.17.9
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/package.json +1 -1
- package/dist/allocations.d.ts +0 -18
- package/dist/auth.d.ts +0 -55
- package/dist/badge-status.d.ts +0 -65
- package/dist/badge.d.ts +0 -41
- package/dist/cash-account.d.ts +0 -43
- package/dist/collections.d.ts +0 -81
- package/dist/country.d.ts +0 -108
- package/dist/currency.d.ts +0 -99
- package/dist/dashboard.d.ts +0 -72
- package/dist/date.d.ts +0 -64
- package/dist/document.d.ts +0 -38
- package/dist/downloads.d.ts +0 -46
- package/dist/filters.d.ts +0 -121
- package/dist/formatting.d.ts +0 -59
- package/dist/holdings.d.ts +0 -79
- package/dist/index.d.ts +0 -36
- package/dist/industry.d.ts +0 -128
- package/dist/instruments.d.ts +0 -66
- package/dist/investment-preference.d.ts +0 -25
- package/dist/numbers.d.ts +0 -72
- package/dist/portfolio-template.d.ts +0 -57
- package/dist/portfolio-validation.d.ts +0 -42
- package/dist/portfolio.d.ts +0 -68
- package/dist/sector.d.ts +0 -124
- package/dist/stock-exchange.d.ts +0 -89
- package/dist/tax-residency.d.ts +0 -67
- package/dist/text.d.ts +0 -22
- package/dist/validation.d.ts +0 -238
- package/dist/withdrawal-status.d.ts +0 -72
- package/dist/withdrawal.d.ts +0 -87
package/dist/numbers.d.ts
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Number formatting utilities
|
|
3
|
-
* Generic number manipulation and formatting functions
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Format a large number with K/M suffixes for display
|
|
7
|
-
* @param quantity - The number to format
|
|
8
|
-
* @param decimals - Number of decimal places (default: 1)
|
|
9
|
-
* @returns Formatted number string with suffix
|
|
10
|
-
* @example
|
|
11
|
-
* formatQuantityWithSuffix(1000) // '1.0K'
|
|
12
|
-
* formatQuantityWithSuffix(1500000) // '1.5M'
|
|
13
|
-
* formatQuantityWithSuffix(999) // '999'
|
|
14
|
-
*/
|
|
15
|
-
export declare function formatQuantityWithSuffix(quantity: number, decimals?: number): string;
|
|
16
|
-
/**
|
|
17
|
-
* Format a large number with customizable suffixes
|
|
18
|
-
* @param num - The number to format
|
|
19
|
-
* @param suffixes - Array of suffix configurations (default: standard K, M, B, T)
|
|
20
|
-
* @param decimals - Number of decimal places (default: 1)
|
|
21
|
-
* @returns Formatted number string with suffix
|
|
22
|
-
* @example
|
|
23
|
-
* formatLargeNumber(1500000) // '1.5M'
|
|
24
|
-
* formatLargeNumber(1500000000) // '1.5B'
|
|
25
|
-
*/
|
|
26
|
-
export declare function formatLargeNumber(num: number, suffixes?: Array<{
|
|
27
|
-
threshold: number;
|
|
28
|
-
suffix: string;
|
|
29
|
-
}>, decimals?: number): string;
|
|
30
|
-
/**
|
|
31
|
-
* Format a number as a percentage
|
|
32
|
-
* @param value - The decimal value to format as percentage
|
|
33
|
-
* @param decimals - Number of decimal places (default: 1)
|
|
34
|
-
* @returns Formatted percentage string
|
|
35
|
-
* @example
|
|
36
|
-
* formatAsPercentage(0.1234) // '12.3%'
|
|
37
|
-
* formatAsPercentage(0.5, 0) // '50%'
|
|
38
|
-
*/
|
|
39
|
-
export declare function formatAsPercentage(value: number, decimals?: number): string;
|
|
40
|
-
/**
|
|
41
|
-
* Format a number with thousand separators
|
|
42
|
-
* @param num - The number to format
|
|
43
|
-
* @param separator - The separator character (default: ',')
|
|
44
|
-
* @returns Formatted number string with separators
|
|
45
|
-
* @example
|
|
46
|
-
* formatWithSeparators(1234567) // '1,234,567'
|
|
47
|
-
* formatWithSeparators(1234567, ' ') // '1 234 567'
|
|
48
|
-
*/
|
|
49
|
-
export declare function formatWithSeparators(num: number, separator?: string): string;
|
|
50
|
-
/**
|
|
51
|
-
* Round a number to specified decimal places
|
|
52
|
-
* @param num - The number to round
|
|
53
|
-
* @param decimals - Number of decimal places (default: 2)
|
|
54
|
-
* @returns Rounded number
|
|
55
|
-
* @example
|
|
56
|
-
* roundToDecimals(3.14159, 2) // 3.14
|
|
57
|
-
* roundToDecimals(123.456, 0) // 123
|
|
58
|
-
*/
|
|
59
|
-
export declare function roundToDecimals(num: number, decimals?: number): number;
|
|
60
|
-
/**
|
|
61
|
-
* Clamp a number between min and max values
|
|
62
|
-
* @param num - The number to clamp
|
|
63
|
-
* @param min - Minimum value
|
|
64
|
-
* @param max - Maximum value
|
|
65
|
-
* @returns Clamped number
|
|
66
|
-
* @example
|
|
67
|
-
* clampNumber(150, 0, 100) // 100
|
|
68
|
-
* clampNumber(-10, 0, 100) // 0
|
|
69
|
-
* clampNumber(50, 0, 100) // 50
|
|
70
|
-
*/
|
|
71
|
-
export declare function clampNumber(num: number, min: number, max: number): number;
|
|
72
|
-
//# sourceMappingURL=numbers.d.ts.map
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Base interface for allocation objects
|
|
3
|
-
*/
|
|
4
|
-
export interface BaseAllocation {
|
|
5
|
-
readonly percentage: string;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* Calculate total allocation from an array of allocations
|
|
9
|
-
*
|
|
10
|
-
* @param allocations - Array of allocation objects with percentage strings
|
|
11
|
-
* @returns Total allocation as a number
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* const total = calculateTotalAllocation([
|
|
15
|
-
* { percentage: '50.5' },
|
|
16
|
-
* { percentage: '30.0' },
|
|
17
|
-
* { percentage: '19.5' }
|
|
18
|
-
* ]);
|
|
19
|
-
* // Returns 100.0
|
|
20
|
-
*/
|
|
21
|
-
export declare const calculateTotalAllocation: <T extends BaseAllocation>(allocations: readonly T[]) => number;
|
|
22
|
-
/**
|
|
23
|
-
* Validate that allocation percentages sum to approximately 100%
|
|
24
|
-
*
|
|
25
|
-
* @param allocations - Array of allocation objects with percentage strings
|
|
26
|
-
* @param tolerance - Tolerance for percentage validation (default: 0.01)
|
|
27
|
-
* @returns True if allocations sum to approximately 100%
|
|
28
|
-
*
|
|
29
|
-
* @example
|
|
30
|
-
* const isValid = validateAllocationPercentages([
|
|
31
|
-
* { percentage: '50.0' },
|
|
32
|
-
* { percentage: '30.0' },
|
|
33
|
-
* { percentage: '20.0' }
|
|
34
|
-
* ]);
|
|
35
|
-
* // Returns true
|
|
36
|
-
*
|
|
37
|
-
* @example
|
|
38
|
-
* const isValid = validateAllocationPercentages([
|
|
39
|
-
* { percentage: '50.0' },
|
|
40
|
-
* { percentage: '30.0' },
|
|
41
|
-
* { percentage: '15.0' }
|
|
42
|
-
* ]);
|
|
43
|
-
* // Returns false (sums to 95%)
|
|
44
|
-
*/
|
|
45
|
-
export declare const validateAllocationPercentages: <T extends BaseAllocation>(allocations: readonly T[], tolerance?: number) => boolean;
|
|
46
|
-
/**
|
|
47
|
-
* Format risk level for display (re-export from formatting utilities)
|
|
48
|
-
*
|
|
49
|
-
* @param riskLevel - Risk level string to format
|
|
50
|
-
* @returns Formatted risk level string
|
|
51
|
-
*
|
|
52
|
-
* @example
|
|
53
|
-
* formatRiskLevelDisplay('HIGH'); // returns 'High'
|
|
54
|
-
* formatRiskLevelDisplay('moderate'); // returns 'Moderate'
|
|
55
|
-
*/
|
|
56
|
-
export declare const formatRiskLevelDisplay: (riskLevel: string) => string;
|
|
57
|
-
//# sourceMappingURL=portfolio-template.d.ts.map
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import type { MessageFieldValidation, BaseFormValidation } from '@cranberry-money/shared-types';
|
|
2
|
-
/**
|
|
3
|
-
* Portfolio selection form validation interface
|
|
4
|
-
*/
|
|
5
|
-
export interface PortfolioSelectionValidation extends BaseFormValidation {
|
|
6
|
-
readonly selectedTemplate: MessageFieldValidation;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Portfolio selection state interface
|
|
10
|
-
*/
|
|
11
|
-
export interface PortfolioSelectionState {
|
|
12
|
-
readonly selectedTemplateUuid: string | null;
|
|
13
|
-
readonly viewingDetailsForUuid?: string | null;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Validates if a portfolio template is selected
|
|
17
|
-
*
|
|
18
|
-
* @param selectedTemplateUuid - The UUID of the selected template
|
|
19
|
-
* @returns true if a template is selected, false otherwise
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
* isValidTemplateSelection('123-456'); // returns true
|
|
23
|
-
* isValidTemplateSelection(null); // returns false
|
|
24
|
-
* isValidTemplateSelection(''); // returns false
|
|
25
|
-
*/
|
|
26
|
-
export declare const isValidTemplateSelection: (selectedTemplateUuid: string | null) => boolean;
|
|
27
|
-
/**
|
|
28
|
-
* Comprehensive validation for portfolio selection form
|
|
29
|
-
*
|
|
30
|
-
* @param state - The portfolio selection state
|
|
31
|
-
* @returns Validation object with field-level and form-level validity
|
|
32
|
-
*
|
|
33
|
-
* @example
|
|
34
|
-
* const state = { selectedTemplateUuid: '123-456' };
|
|
35
|
-
* validatePortfolioSelection(state);
|
|
36
|
-
* // returns {
|
|
37
|
-
* // selectedTemplate: { isValid: true, message: '' },
|
|
38
|
-
* // isFormValid: true
|
|
39
|
-
* // }
|
|
40
|
-
*/
|
|
41
|
-
export declare const validatePortfolioSelection: (state: PortfolioSelectionState) => PortfolioSelectionValidation;
|
|
42
|
-
//# sourceMappingURL=portfolio-validation.d.ts.map
|
package/dist/portfolio.d.ts
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Portfolio calculation and formatting utilities
|
|
3
|
-
*
|
|
4
|
-
* This module provides pure functions for portfolio value calculations,
|
|
5
|
-
* allocations, and formatting. All functions handle string or number inputs
|
|
6
|
-
* for flexibility with API responses.
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* Formats a portfolio value as currency with AUD
|
|
10
|
-
*
|
|
11
|
-
* @param value - Portfolio value as string or number
|
|
12
|
-
* @returns Formatted currency string with AUD symbol
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* ```typescript
|
|
16
|
-
* formatPortfolioValue(12345.67) // 'A$12,345.67'
|
|
17
|
-
* formatPortfolioValue('12345.67') // 'A$12,345.67'
|
|
18
|
-
* ```
|
|
19
|
-
*/
|
|
20
|
-
export declare function formatPortfolioValue(value: string | number): string;
|
|
21
|
-
/**
|
|
22
|
-
* Calculates total portfolio value from market value and cash balance
|
|
23
|
-
*
|
|
24
|
-
* @param marketValue - Market value of holdings
|
|
25
|
-
* @param cashBalance - Cash balance in portfolio
|
|
26
|
-
* @returns Total portfolio value as number
|
|
27
|
-
*
|
|
28
|
-
* @example
|
|
29
|
-
* ```typescript
|
|
30
|
-
* calculateTotalValue(10000, 5000) // 15000
|
|
31
|
-
* calculateTotalValue('10000', '5000') // 15000
|
|
32
|
-
* calculateTotalValue('10000.50', 5000.25) // 15000.75
|
|
33
|
-
* ```
|
|
34
|
-
*/
|
|
35
|
-
export declare function calculateTotalValue(marketValue: string | number, cashBalance: string | number): number;
|
|
36
|
-
/**
|
|
37
|
-
* Calculates market allocation percentage in portfolio
|
|
38
|
-
*
|
|
39
|
-
* @param marketValue - Market value of holdings
|
|
40
|
-
* @param totalValue - Total portfolio value
|
|
41
|
-
* @returns Market allocation percentage (0-100)
|
|
42
|
-
*
|
|
43
|
-
* @example
|
|
44
|
-
* ```typescript
|
|
45
|
-
* getMarketAllocation(7500, 10000) // 75
|
|
46
|
-
* getMarketAllocation('7500', '10000') // 75
|
|
47
|
-
* getMarketAllocation(0, 10000) // 0
|
|
48
|
-
* getMarketAllocation(100, 0) // 0 (prevents division by zero)
|
|
49
|
-
* ```
|
|
50
|
-
*/
|
|
51
|
-
export declare function getMarketAllocation(marketValue: string | number, totalValue: string | number): number;
|
|
52
|
-
/**
|
|
53
|
-
* Calculates cash allocation percentage in portfolio
|
|
54
|
-
*
|
|
55
|
-
* @param cashBalance - Cash balance in portfolio
|
|
56
|
-
* @param totalValue - Total portfolio value
|
|
57
|
-
* @returns Cash allocation percentage (0-100)
|
|
58
|
-
*
|
|
59
|
-
* @example
|
|
60
|
-
* ```typescript
|
|
61
|
-
* getCashAllocation(2500, 10000) // 25
|
|
62
|
-
* getCashAllocation('2500', '10000') // 25
|
|
63
|
-
* getCashAllocation(0, 10000) // 0
|
|
64
|
-
* getCashAllocation(100, 0) // 0 (prevents division by zero)
|
|
65
|
-
* ```
|
|
66
|
-
*/
|
|
67
|
-
export declare function getCashAllocation(cashBalance: string | number, totalValue: string | number): number;
|
|
68
|
-
//# sourceMappingURL=portfolio.d.ts.map
|
package/dist/sector.d.ts
DELETED
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
export interface BaseSector {
|
|
2
|
-
readonly uuid: string;
|
|
3
|
-
readonly name: string;
|
|
4
|
-
}
|
|
5
|
-
export type { SortDirection } from './stock-exchange';
|
|
6
|
-
/**
|
|
7
|
-
* Sort sectors by name
|
|
8
|
-
*
|
|
9
|
-
* @param sectors - List of sectors
|
|
10
|
-
* @param direction - Sort direction ('asc' or 'desc')
|
|
11
|
-
* @returns New sorted array of sectors
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* const sectors = [
|
|
15
|
-
* { uuid: '1', name: 'Technology' },
|
|
16
|
-
* { uuid: '2', name: 'Healthcare' }
|
|
17
|
-
* ];
|
|
18
|
-
* sortSectorsByName(sectors); // returns [Healthcare, Technology]
|
|
19
|
-
* sortSectorsByName(sectors, 'desc'); // returns [Technology, Healthcare]
|
|
20
|
-
*/
|
|
21
|
-
export declare const sortSectorsByName: <T extends BaseSector>(sectors: readonly T[], direction?: "asc" | "desc") => T[];
|
|
22
|
-
/**
|
|
23
|
-
* Filter sectors by name (case-insensitive search)
|
|
24
|
-
*
|
|
25
|
-
* @param sectors - List of sectors
|
|
26
|
-
* @param searchTerm - Search term to filter by
|
|
27
|
-
* @returns Filtered array of sectors
|
|
28
|
-
*
|
|
29
|
-
* @example
|
|
30
|
-
* const sectors = [
|
|
31
|
-
* { uuid: '1', name: 'Technology' },
|
|
32
|
-
* { uuid: '2', name: 'Healthcare' },
|
|
33
|
-
* { uuid: '3', name: 'Financial Services' }
|
|
34
|
-
* ];
|
|
35
|
-
* filterSectorsByName(sectors, 'tech'); // returns [Technology]
|
|
36
|
-
* filterSectorsByName(sectors, 'care'); // returns [Healthcare]
|
|
37
|
-
*/
|
|
38
|
-
export declare const filterSectorsByName: <T extends BaseSector>(sectors: readonly T[], searchTerm: string) => T[];
|
|
39
|
-
/**
|
|
40
|
-
* Find sector by exact name match
|
|
41
|
-
*
|
|
42
|
-
* @param sectors - List of sectors
|
|
43
|
-
* @param name - Exact name to search for
|
|
44
|
-
* @returns The sector if found, undefined otherwise
|
|
45
|
-
*
|
|
46
|
-
* @example
|
|
47
|
-
* const sectors = [
|
|
48
|
-
* { uuid: '1', name: 'Technology' },
|
|
49
|
-
* { uuid: '2', name: 'Healthcare' }
|
|
50
|
-
* ];
|
|
51
|
-
* findSectorByName(sectors, 'Technology'); // returns Technology sector
|
|
52
|
-
* findSectorByName(sectors, 'Tech'); // returns undefined
|
|
53
|
-
*/
|
|
54
|
-
export declare const findSectorByName: <T extends BaseSector>(sectors: readonly T[], name: string) => T | undefined;
|
|
55
|
-
/**
|
|
56
|
-
* Get sorted list of sector names
|
|
57
|
-
*
|
|
58
|
-
* @param sectors - List of sectors
|
|
59
|
-
* @returns Sorted array of sector names
|
|
60
|
-
*
|
|
61
|
-
* @example
|
|
62
|
-
* const sectors = [
|
|
63
|
-
* { uuid: '1', name: 'Technology' },
|
|
64
|
-
* { uuid: '2', name: 'Healthcare' },
|
|
65
|
-
* { uuid: '3', name: 'Energy' }
|
|
66
|
-
* ];
|
|
67
|
-
* getSectorNames(sectors); // returns ['Energy', 'Healthcare', 'Technology']
|
|
68
|
-
*/
|
|
69
|
-
export declare const getSectorNames: <T extends BaseSector>(sectors: readonly T[]) => string[];
|
|
70
|
-
/**
|
|
71
|
-
* Group sectors alphabetically by first letter
|
|
72
|
-
*
|
|
73
|
-
* @param sectors - List of sectors
|
|
74
|
-
* @returns Object with first letters as keys and sectors as values
|
|
75
|
-
*
|
|
76
|
-
* @example
|
|
77
|
-
* const sectors = [
|
|
78
|
-
* { uuid: '1', name: 'Technology' },
|
|
79
|
-
* { uuid: '2', name: 'Healthcare' },
|
|
80
|
-
* { uuid: '3', name: 'Energy' },
|
|
81
|
-
* { uuid: '4', name: 'Telecommunications' }
|
|
82
|
-
* ];
|
|
83
|
-
* groupSectorsAlphabetically(sectors);
|
|
84
|
-
* // returns {
|
|
85
|
-
* // 'E': [Energy],
|
|
86
|
-
* // 'H': [Healthcare],
|
|
87
|
-
* // 'T': [Technology, Telecommunications]
|
|
88
|
-
* // }
|
|
89
|
-
*/
|
|
90
|
-
export declare const groupSectorsAlphabetically: <T extends BaseSector>(sectors: readonly T[]) => Record<string, T[]>;
|
|
91
|
-
/**
|
|
92
|
-
* Check if a sector name exists in the list
|
|
93
|
-
*
|
|
94
|
-
* @param sectors - List of sectors
|
|
95
|
-
* @param sectorName - Name to check for existence
|
|
96
|
-
* @returns True if sector exists, false otherwise
|
|
97
|
-
*
|
|
98
|
-
* @example
|
|
99
|
-
* const sectors = [
|
|
100
|
-
* { uuid: '1', name: 'Technology' },
|
|
101
|
-
* { uuid: '2', name: 'Healthcare' }
|
|
102
|
-
* ];
|
|
103
|
-
* sectorExists(sectors, 'Technology'); // returns true
|
|
104
|
-
* sectorExists(sectors, 'Manufacturing'); // returns false
|
|
105
|
-
*/
|
|
106
|
-
export declare const sectorExists: <T extends BaseSector>(sectors: readonly T[], sectorName: string) => boolean;
|
|
107
|
-
/**
|
|
108
|
-
* Get sectors by partial name match (fuzzy search)
|
|
109
|
-
*
|
|
110
|
-
* @param sectors - List of sectors
|
|
111
|
-
* @param partialName - Partial name to search for
|
|
112
|
-
* @returns Array of matching sectors
|
|
113
|
-
*
|
|
114
|
-
* @example
|
|
115
|
-
* const sectors = [
|
|
116
|
-
* { uuid: '1', name: 'Technology' },
|
|
117
|
-
* { uuid: '2', name: 'Biotechnology' },
|
|
118
|
-
* { uuid: '3', name: 'Healthcare Technology' }
|
|
119
|
-
* ];
|
|
120
|
-
* findSectorsByPartialName(sectors, 'tech');
|
|
121
|
-
* // returns [Technology, Biotechnology, Healthcare Technology]
|
|
122
|
-
*/
|
|
123
|
-
export declare const findSectorsByPartialName: <T extends BaseSector>(sectors: readonly T[], partialName: string) => T[];
|
|
124
|
-
//# sourceMappingURL=sector.d.ts.map
|
package/dist/stock-exchange.d.ts
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
export interface BaseCountry {
|
|
2
|
-
readonly uuid: string;
|
|
3
|
-
readonly code: string;
|
|
4
|
-
readonly name?: string;
|
|
5
|
-
}
|
|
6
|
-
export interface BaseStockExchange {
|
|
7
|
-
readonly uuid: string;
|
|
8
|
-
readonly name: string;
|
|
9
|
-
readonly shortName: string;
|
|
10
|
-
readonly country?: BaseCountry | null;
|
|
11
|
-
}
|
|
12
|
-
export type SortDirection = 'asc' | 'desc';
|
|
13
|
-
/**
|
|
14
|
-
* Extract unique countries from stock exchanges
|
|
15
|
-
*
|
|
16
|
-
* @param exchanges - List of stock exchanges
|
|
17
|
-
* @returns Array of unique countries
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* const exchanges = [
|
|
21
|
-
* { uuid: '1', name: 'NYSE', shortName: 'NYSE', country: { uuid: 'us', code: 'US' } },
|
|
22
|
-
* { uuid: '2', name: 'NASDAQ', shortName: 'NASDAQ', country: { uuid: 'us', code: 'US' } },
|
|
23
|
-
* { uuid: '3', name: 'TSX', shortName: 'TSX', country: { uuid: 'ca', code: 'CA' } }
|
|
24
|
-
* ];
|
|
25
|
-
* getCountriesFromExchanges(exchanges); // returns [{ uuid: 'us', code: 'US' }, { uuid: 'ca', code: 'CA' }]
|
|
26
|
-
*/
|
|
27
|
-
export declare const getCountriesFromExchanges: <T extends BaseStockExchange>(exchanges: readonly T[]) => BaseCountry[];
|
|
28
|
-
/**
|
|
29
|
-
* Group stock exchanges by country code
|
|
30
|
-
*
|
|
31
|
-
* @param exchanges - List of stock exchanges
|
|
32
|
-
* @returns Object with country codes as keys and exchanges as values
|
|
33
|
-
*
|
|
34
|
-
* @example
|
|
35
|
-
* const exchanges = [
|
|
36
|
-
* { uuid: '1', name: 'NYSE', shortName: 'NYSE', country: { uuid: 'us', code: 'US' } },
|
|
37
|
-
* { uuid: '2', name: 'TSX', shortName: 'TSX', country: { uuid: 'ca', code: 'CA' } }
|
|
38
|
-
* ];
|
|
39
|
-
* groupExchangesByCountry(exchanges);
|
|
40
|
-
* // returns { 'US': [NYSE exchange], 'CA': [TSX exchange], 'Unknown': [] }
|
|
41
|
-
*/
|
|
42
|
-
export declare const groupExchangesByCountry: <T extends BaseStockExchange>(exchanges: readonly T[]) => Record<string, T[]>;
|
|
43
|
-
/**
|
|
44
|
-
* Find stock exchange by short name
|
|
45
|
-
*
|
|
46
|
-
* @param exchanges - List of stock exchanges
|
|
47
|
-
* @param shortName - Short name to search for
|
|
48
|
-
* @returns The exchange if found, undefined otherwise
|
|
49
|
-
*
|
|
50
|
-
* @example
|
|
51
|
-
* const exchanges = [
|
|
52
|
-
* { uuid: '1', name: 'New York Stock Exchange', shortName: 'NYSE' },
|
|
53
|
-
* { uuid: '2', name: 'NASDAQ', shortName: 'NASDAQ' }
|
|
54
|
-
* ];
|
|
55
|
-
* findExchangeByShortName(exchanges, 'NYSE'); // returns NYSE exchange
|
|
56
|
-
*/
|
|
57
|
-
export declare const findExchangeByShortName: <T extends BaseStockExchange>(exchanges: readonly T[], shortName: string) => T | undefined;
|
|
58
|
-
/**
|
|
59
|
-
* Sort stock exchanges by name
|
|
60
|
-
*
|
|
61
|
-
* @param exchanges - List of stock exchanges
|
|
62
|
-
* @param direction - Sort direction ('asc' or 'desc')
|
|
63
|
-
* @returns New sorted array of exchanges
|
|
64
|
-
*
|
|
65
|
-
* @example
|
|
66
|
-
* const exchanges = [
|
|
67
|
-
* { uuid: '2', name: 'NASDAQ', shortName: 'NASDAQ' },
|
|
68
|
-
* { uuid: '1', name: 'NYSE', shortName: 'NYSE' }
|
|
69
|
-
* ];
|
|
70
|
-
* sortExchangesByName(exchanges); // returns [NASDAQ, NYSE] (alphabetical)
|
|
71
|
-
* sortExchangesByName(exchanges, 'desc'); // returns [NYSE, NASDAQ] (reverse)
|
|
72
|
-
*/
|
|
73
|
-
export declare const sortExchangesByName: <T extends BaseStockExchange>(exchanges: readonly T[], direction?: SortDirection) => T[];
|
|
74
|
-
/**
|
|
75
|
-
* Filter stock exchanges by country code
|
|
76
|
-
*
|
|
77
|
-
* @param exchanges - List of stock exchanges
|
|
78
|
-
* @param countryCode - Country code to filter by
|
|
79
|
-
* @returns Array of exchanges in the specified country
|
|
80
|
-
*
|
|
81
|
-
* @example
|
|
82
|
-
* const exchanges = [
|
|
83
|
-
* { uuid: '1', name: 'NYSE', shortName: 'NYSE', country: { uuid: 'us', code: 'US' } },
|
|
84
|
-
* { uuid: '2', name: 'TSX', shortName: 'TSX', country: { uuid: 'ca', code: 'CA' } }
|
|
85
|
-
* ];
|
|
86
|
-
* filterExchangesByCountry(exchanges, 'US'); // returns [NYSE exchange]
|
|
87
|
-
*/
|
|
88
|
-
export declare const filterExchangesByCountry: <T extends BaseStockExchange>(exchanges: readonly T[], countryCode: string) => T[];
|
|
89
|
-
//# sourceMappingURL=stock-exchange.d.ts.map
|
package/dist/tax-residency.d.ts
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
export interface BaseTaxResidency {
|
|
2
|
-
readonly country: string;
|
|
3
|
-
readonly isPrimary: boolean;
|
|
4
|
-
readonly isExempted: boolean;
|
|
5
|
-
}
|
|
6
|
-
/**
|
|
7
|
-
* Find the primary tax residency from a list
|
|
8
|
-
*
|
|
9
|
-
* @param taxResidencies - List of tax residencies
|
|
10
|
-
* @returns The primary tax residency if found, undefined otherwise
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* const residencies = [
|
|
14
|
-
* { country: 'US', isPrimary: false, isExempted: false },
|
|
15
|
-
* { country: 'CA', isPrimary: true, isExempted: false }
|
|
16
|
-
* ];
|
|
17
|
-
* findPrimaryTaxResidency(residencies); // returns CA residency
|
|
18
|
-
*/
|
|
19
|
-
export declare const findPrimaryTaxResidency: <T extends BaseTaxResidency>(taxResidencies: readonly T[]) => T | undefined;
|
|
20
|
-
/**
|
|
21
|
-
* Filter tax residencies by country code
|
|
22
|
-
*
|
|
23
|
-
* @param taxResidencies - List of tax residencies
|
|
24
|
-
* @param countryCode - Country code to filter by
|
|
25
|
-
* @returns List of tax residencies for the specified country
|
|
26
|
-
*
|
|
27
|
-
* @example
|
|
28
|
-
* const residencies = [
|
|
29
|
-
* { country: 'US', isPrimary: true, isExempted: false },
|
|
30
|
-
* { country: 'US', isPrimary: false, isExempted: true },
|
|
31
|
-
* { country: 'CA', isPrimary: false, isExempted: false }
|
|
32
|
-
* ];
|
|
33
|
-
* filterTaxResidenciesByCountry(residencies, 'US'); // returns 2 US residencies
|
|
34
|
-
*/
|
|
35
|
-
export declare const filterTaxResidenciesByCountry: <T extends BaseTaxResidency>(taxResidencies: readonly T[], countryCode: string) => T[];
|
|
36
|
-
/**
|
|
37
|
-
* Check if user has tax residency in a specific country
|
|
38
|
-
*
|
|
39
|
-
* @param taxResidencies - List of tax residencies
|
|
40
|
-
* @param countryCode - Country code to check
|
|
41
|
-
* @returns True if user has residency in the country, false otherwise
|
|
42
|
-
*
|
|
43
|
-
* @example
|
|
44
|
-
* const residencies = [
|
|
45
|
-
* { country: 'US', isPrimary: true, isExempted: false },
|
|
46
|
-
* { country: 'CA', isPrimary: false, isExempted: false }
|
|
47
|
-
* ];
|
|
48
|
-
* hasTaxResidencyInCountry(residencies, 'US'); // returns true
|
|
49
|
-
* hasTaxResidencyInCountry(residencies, 'UK'); // returns false
|
|
50
|
-
*/
|
|
51
|
-
export declare const hasTaxResidencyInCountry: <T extends BaseTaxResidency>(taxResidencies: readonly T[], countryCode: string) => boolean;
|
|
52
|
-
/**
|
|
53
|
-
* Get all non-exempted tax residencies
|
|
54
|
-
*
|
|
55
|
-
* @param taxResidencies - List of tax residencies
|
|
56
|
-
* @returns List of non-exempted tax residencies
|
|
57
|
-
*
|
|
58
|
-
* @example
|
|
59
|
-
* const residencies = [
|
|
60
|
-
* { country: 'US', isPrimary: true, isExempted: false },
|
|
61
|
-
* { country: 'CA', isPrimary: false, isExempted: true },
|
|
62
|
-
* { country: 'UK', isPrimary: false, isExempted: false }
|
|
63
|
-
* ];
|
|
64
|
-
* getNonExemptedTaxResidencies(residencies); // returns US and UK residencies
|
|
65
|
-
*/
|
|
66
|
-
export declare const getNonExemptedTaxResidencies: <T extends BaseTaxResidency>(taxResidencies: readonly T[]) => T[];
|
|
67
|
-
//# sourceMappingURL=tax-residency.d.ts.map
|
package/dist/text.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Text manipulation utility functions
|
|
3
|
-
*
|
|
4
|
-
* This module provides pure functions for common text operations
|
|
5
|
-
* such as truncation, formatting, and manipulation.
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* Truncates text to a specified maximum length and adds ellipsis if needed
|
|
9
|
-
*
|
|
10
|
-
* @param text - The text to truncate
|
|
11
|
-
* @param maxLength - The maximum length of the text (default: 30)
|
|
12
|
-
* @returns The truncated text with ellipsis if it exceeds maxLength
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* ```typescript
|
|
16
|
-
* truncateText('This is a very long text', 10) // 'This is a...'
|
|
17
|
-
* truncateText('Short', 10) // 'Short'
|
|
18
|
-
* truncateText('', 10) // ''
|
|
19
|
-
* ```
|
|
20
|
-
*/
|
|
21
|
-
export declare function truncateText(text: string, maxLength?: number): string;
|
|
22
|
-
//# sourceMappingURL=text.d.ts.map
|