@cranberry-money/shared-utils 8.17.6 → 8.17.7
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/dist/auth.d.ts +1 -25
- package/dist/auth.d.ts.map +1 -1
- package/dist/badge-status.d.ts +2 -6
- package/dist/badge-status.d.ts.map +1 -1
- package/dist/badge.d.ts +1 -9
- package/dist/badge.d.ts.map +1 -1
- package/dist/instruments.d.ts +1 -33
- package/dist/instruments.d.ts.map +1 -1
- package/dist/portfolio-validation.d.ts +1 -5
- package/dist/portfolio-validation.d.ts.map +1 -1
- package/dist/validation.d.ts +1 -13
- package/dist/validation.d.ts.map +1 -1
- package/dist/withdrawal.d.ts +1 -9
- package/dist/withdrawal.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/allocations.d.ts +0 -18
- package/dist/allocations.js +0 -20
- package/dist/cash-account.d.ts +0 -43
- package/dist/cash-account.d.ts.map +0 -1
- package/dist/cash-account.js +0 -52
- package/dist/collections.d.ts +0 -81
- package/dist/collections.d.ts.map +0 -1
- package/dist/collections.js +0 -127
- package/dist/country.d.ts +0 -108
- package/dist/country.d.ts.map +0 -1
- package/dist/country.js +0 -116
- package/dist/currency.d.ts +0 -99
- package/dist/currency.d.ts.map +0 -1
- package/dist/currency.js +0 -128
- package/dist/dashboard.d.ts +0 -72
- package/dist/dashboard.js +0 -121
- package/dist/date.d.ts.map +0 -1
- package/dist/date.js +0 -91
- package/dist/document.d.ts +0 -38
- package/dist/document.d.ts.map +0 -1
- package/dist/document.js +0 -56
- package/dist/downloads.d.ts +0 -46
- package/dist/downloads.d.ts.map +0 -1
- package/dist/downloads.js +0 -91
- package/dist/filters.d.ts +0 -121
- package/dist/filters.d.ts.map +0 -1
- package/dist/filters.js +0 -206
- package/dist/formatting.d.ts +0 -59
- package/dist/formatting.d.ts.map +0 -1
- package/dist/formatting.js +0 -81
- package/dist/holdings.d.ts +0 -79
- package/dist/holdings.js +0 -139
- package/dist/index.d.ts +0 -36
- package/dist/index.js +0 -68
- package/dist/industry.d.ts +0 -128
- package/dist/industry.d.ts.map +0 -1
- package/dist/industry.js +0 -152
- package/dist/investment-preference.d.ts +0 -25
- package/dist/investment-preference.js +0 -33
- package/dist/numbers.d.ts +0 -72
- package/dist/numbers.d.ts.map +0 -1
- package/dist/numbers.js +0 -101
- package/dist/portfolio-template.d.ts +0 -57
- package/dist/portfolio-template.d.ts.map +0 -1
- package/dist/portfolio-template.js +0 -60
- package/dist/portfolio.d.ts +0 -68
- package/dist/portfolio.d.ts.map +0 -1
- package/dist/portfolio.js +0 -87
- package/dist/sector.d.ts +0 -124
- package/dist/sector.d.ts.map +0 -1
- package/dist/sector.js +0 -134
- package/dist/stock-exchange.d.ts +0 -89
- package/dist/stock-exchange.d.ts.map +0 -1
- package/dist/stock-exchange.js +0 -101
- package/dist/tax-residency.d.ts +0 -67
- package/dist/tax-residency.d.ts.map +0 -1
- package/dist/tax-residency.js +0 -70
- package/dist/text.d.ts.map +0 -1
- package/dist/text.js +0 -25
- package/dist/withdrawal-status.d.ts +0 -72
- package/dist/withdrawal-status.d.ts.map +0 -1
- package/dist/withdrawal-status.js +0 -127
package/dist/auth.d.ts
CHANGED
|
@@ -1,30 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Authentication and token management utilities
|
|
3
3
|
*/
|
|
4
|
-
|
|
5
|
-
browser: string;
|
|
6
|
-
os: string;
|
|
7
|
-
}
|
|
8
|
-
interface TokenRefreshResponse {
|
|
9
|
-
status?: number;
|
|
10
|
-
data?: {
|
|
11
|
-
access?: string;
|
|
12
|
-
refresh?: string;
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
interface TokenRefreshError {
|
|
16
|
-
response?: {
|
|
17
|
-
data?: {
|
|
18
|
-
detail?: string;
|
|
19
|
-
message?: string;
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
message?: string;
|
|
23
|
-
}
|
|
24
|
-
interface AutoRefreshHandler {
|
|
25
|
-
start: () => void;
|
|
26
|
-
stop: () => void;
|
|
27
|
-
}
|
|
4
|
+
import type { DeviceInfo, TokenRefreshResponse, TokenRefreshError, AutoRefreshHandler } from '@cranberry-money/shared-types';
|
|
28
5
|
/**
|
|
29
6
|
* Check if a token has expired based on its expiration timestamp
|
|
30
7
|
* @param expiresAt - The expiration timestamp
|
|
@@ -75,5 +52,4 @@ export declare function getRefreshErrorMessage(error: TokenRefreshError): string
|
|
|
75
52
|
* @returns Auto refresh handler with start/stop methods
|
|
76
53
|
*/
|
|
77
54
|
export declare function createAutoRefreshHandler(refreshCallback: () => Promise<void>, checkInterval?: number): AutoRefreshHandler;
|
|
78
|
-
export {};
|
|
79
55
|
//# sourceMappingURL=auth.d.ts.map
|
package/dist/auth.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EACV,UAAU,EACV,oBAAoB,EACpB,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,+BAA+B,CAAC;AAkBvC;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAIzD;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,MAAM,EACjB,mBAAmB,GAAE,MAA6C,GACjE,OAAO,CAMT;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAU5D;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAkB/D;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,UAAU,CAwB7D;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,oBAAoB,GAAG,OAAO,CAExE;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM,CAWvE;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,eAAe,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,EACpC,aAAa,GAAE,MAAc,GAC5B,kBAAkB,CAiBpB"}
|
package/dist/badge-status.d.ts
CHANGED
|
@@ -4,11 +4,8 @@
|
|
|
4
4
|
* This module provides pre-configured badge functions for common status types
|
|
5
5
|
* in the MyPortfolio platform. It builds on top of the core badge system.
|
|
6
6
|
*/
|
|
7
|
-
import type {
|
|
8
|
-
|
|
9
|
-
displayText: string;
|
|
10
|
-
}
|
|
11
|
-
type BadgeSize = 'sm' | 'md' | 'lg';
|
|
7
|
+
import type { StatusBadgeStyle, TradeStatus, WithdrawalStatus, LiquidationStatus, TargetTradeStatus } from '@cranberry-money/shared-types';
|
|
8
|
+
import type { BadgeSize } from '@cranberry-money/shared-types';
|
|
12
9
|
/**
|
|
13
10
|
* Creates a badge for trade status
|
|
14
11
|
*
|
|
@@ -65,5 +62,4 @@ export declare function getLiquidationStatusBadge(status: LiquidationStatus, siz
|
|
|
65
62
|
* ```
|
|
66
63
|
*/
|
|
67
64
|
export declare function getTargetTradeStatusBadge(status: TargetTradeStatus, size?: BadgeSize): StatusBadgeStyle;
|
|
68
|
-
export {};
|
|
69
65
|
//# sourceMappingURL=badge-status.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"badge-status.d.ts","sourceRoot":"","sources":["../src/badge-status.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EACV,
|
|
1
|
+
{"version":3,"file":"badge-status.d.ts","sourceRoot":"","sources":["../src/badge-status.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EACV,gBAAgB,EAChB,WAAW,EACX,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,+BAA+B,CAAC;AAmDvC,OAAO,KAAK,EAAgB,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAiF7E;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,WAAW,EAAE,IAAI,GAAE,SAAgB,GAAG,gBAAgB,CAUjG;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,gBAAgB,EAAE,IAAI,GAAE,SAAgB,GAAG,gBAAgB,CAU3G;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,iBAAiB,EAAE,IAAI,GAAE,SAAgB,GAAG,gBAAgB,CAU7G;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,iBAAiB,EAAE,IAAI,GAAE,SAAgB,GAAG,gBAAgB,CAU7G"}
|
package/dist/badge.d.ts
CHANGED
|
@@ -8,14 +8,7 @@
|
|
|
8
8
|
* Note: The actual style classes are designed to work with Tailwind CSS
|
|
9
9
|
* and assume a specific color system is in place.
|
|
10
10
|
*/
|
|
11
|
-
import type { BadgeStyle } from '@cranberry-money/shared-types';
|
|
12
|
-
type BadgeVariant = 'default' | 'primary' | 'secondary' | 'success' | 'warning' | 'error' | 'info' | 'neutral';
|
|
13
|
-
type BadgeSize = 'sm' | 'md' | 'lg';
|
|
14
|
-
interface BadgeConfig {
|
|
15
|
-
variant: BadgeVariant;
|
|
16
|
-
size?: BadgeSize;
|
|
17
|
-
className?: string;
|
|
18
|
-
}
|
|
11
|
+
import type { BadgeVariant, BadgeSize, BadgeConfig, BadgeStyle } from '@cranberry-money/shared-types';
|
|
19
12
|
/**
|
|
20
13
|
* Creates a badge style configuration with appropriate CSS classes
|
|
21
14
|
*
|
|
@@ -45,5 +38,4 @@ export declare function createBadge({ variant, size, className }: BadgeConfig, v
|
|
|
45
38
|
*/
|
|
46
39
|
export declare const BADGE_VARIANTS: Record<BadgeVariant, string>;
|
|
47
40
|
export declare const BADGE_SIZES: Record<BadgeSize, string>;
|
|
48
|
-
export {};
|
|
49
41
|
//# sourceMappingURL=badge.d.ts.map
|
package/dist/badge.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"badge.d.ts","sourceRoot":"","sources":["../src/badge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"badge.d.ts","sourceRoot":"","sources":["../src/badge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AA+BtG;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,WAAW,CACzB,EAAE,OAAO,EAAE,IAAW,EAAE,SAAc,EAAE,EAAE,WAAW,EACrD,aAAa,GAAE,MAAM,CAAC,YAAY,EAAE,MAAM,CAA0B,EACpE,UAAU,GAAE,MAAM,CAAC,SAAS,EAAE,MAAM,CAAuB,GAC1D,UAAU,CAQZ;AAED;;;GAGG;AACH,eAAO,MAAM,cAAc,8BAAyB,CAAC;AACrD,eAAO,MAAM,WAAW,2BAAsB,CAAC"}
|
package/dist/instruments.d.ts
CHANGED
|
@@ -1,38 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Instrument and market data formatting utilities
|
|
3
3
|
*/
|
|
4
|
-
|
|
5
|
-
openPrice?: string | null;
|
|
6
|
-
dayHigh?: string | null;
|
|
7
|
-
dayLow?: string | null;
|
|
8
|
-
volume?: number | null;
|
|
9
|
-
}
|
|
10
|
-
interface TradeableInstrument {
|
|
11
|
-
isActive: boolean;
|
|
12
|
-
isActivelyTrading: boolean;
|
|
13
|
-
}
|
|
14
|
-
interface InstrumentTypeInfo {
|
|
15
|
-
isEtf?: boolean;
|
|
16
|
-
isFund?: boolean;
|
|
17
|
-
}
|
|
18
|
-
interface InstrumentBasicInfo {
|
|
19
|
-
symbol: string;
|
|
20
|
-
name: string;
|
|
21
|
-
}
|
|
22
|
-
interface PriceChangeResult {
|
|
23
|
-
change: number;
|
|
24
|
-
changePercent: number;
|
|
25
|
-
isPositive: boolean;
|
|
26
|
-
}
|
|
27
|
-
interface PriceSnapshot {
|
|
28
|
-
change: string;
|
|
29
|
-
changePercent: string;
|
|
30
|
-
}
|
|
31
|
-
interface FormattedPriceChange {
|
|
32
|
-
changeText: string;
|
|
33
|
-
changePercentText: string;
|
|
34
|
-
colorClass: string;
|
|
35
|
-
}
|
|
4
|
+
import type { InstrumentTypeInfo, InstrumentBasicInfo, PriceChangeResult, PriceSnapshot, FormattedPriceChange, TradeableInstrument, MarketDataInfo } from '@cranberry-money/shared-types';
|
|
36
5
|
/**
|
|
37
6
|
* Format instrument price with currency symbol
|
|
38
7
|
* @param price - The price as string
|
|
@@ -94,5 +63,4 @@ export declare function formatVolume(volume: number): string;
|
|
|
94
63
|
* @returns true if market data is available, false otherwise
|
|
95
64
|
*/
|
|
96
65
|
export declare function hasMarketData(marketData: MarketDataInfo): boolean;
|
|
97
|
-
export {};
|
|
98
66
|
//# sourceMappingURL=instruments.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instruments.d.ts","sourceRoot":"","sources":["../src/instruments.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,
|
|
1
|
+
{"version":3,"file":"instruments.d.ts","sourceRoot":"","sources":["../src/instruments.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EACV,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,aAAa,EACb,oBAAoB,EACpB,mBAAmB,EACnB,cAAc,EACf,MAAM,+BAA+B,CAAC;AAUvC;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAMrF;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAalE;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,kBAAkB,GAAG,MAAM,CAIxE;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,mBAAmB,GAAG,MAAM,CAE5E;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,aAAa,GAAG,iBAAiB,CAS/E;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,aAAa,GAAG,oBAAoB,CAY/E;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,mBAAmB,GAAG,OAAO,CAE9E;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,CAU5E;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAKnD;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,UAAU,EAAE,cAAc,GAAG,OAAO,CAEjE"}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import type { MessageFieldValidation } from '@cranberry-money/shared-types';
|
|
2
|
-
interface BaseFormValidation {
|
|
3
|
-
isFormValid: boolean;
|
|
4
|
-
}
|
|
1
|
+
import type { MessageFieldValidation, BaseFormValidation } from '@cranberry-money/shared-types';
|
|
5
2
|
/**
|
|
6
3
|
* Portfolio selection form validation interface
|
|
7
4
|
*/
|
|
@@ -42,5 +39,4 @@ export declare const isValidTemplateSelection: (selectedTemplateUuid: string | n
|
|
|
42
39
|
* // }
|
|
43
40
|
*/
|
|
44
41
|
export declare const validatePortfolioSelection: (state: PortfolioSelectionState) => PortfolioSelectionValidation;
|
|
45
|
-
export {};
|
|
46
42
|
//# sourceMappingURL=portfolio-validation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"portfolio-validation.d.ts","sourceRoot":"","sources":["../src/portfolio-validation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"portfolio-validation.d.ts","sourceRoot":"","sources":["../src/portfolio-validation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAEhG;;GAEG;AACH,MAAM,WAAW,4BAA6B,SAAQ,kBAAkB;IACtE,QAAQ,CAAC,gBAAgB,EAAE,sBAAsB,CAAC;CACnD;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,oBAAoB,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7C,QAAQ,CAAC,qBAAqB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAChD;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,wBAAwB,GAAI,sBAAsB,MAAM,GAAG,IAAI,KAAG,OAE9E,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,0BAA0B,GAAI,OAAO,uBAAuB,KAAG,4BAa3E,CAAC"}
|
package/dist/validation.d.ts
CHANGED
|
@@ -1,18 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Validation utility functions
|
|
3
3
|
*/
|
|
4
|
-
import type { PasswordValidation } from '@cranberry-money/shared-types';
|
|
5
|
-
interface EmailConfirmationValidation {
|
|
6
|
-
isValid: boolean;
|
|
7
|
-
isEmpty: boolean;
|
|
8
|
-
isValidFormat: boolean;
|
|
9
|
-
}
|
|
10
|
-
interface ExtendedPasswordValidation extends PasswordValidation {
|
|
11
|
-
hasUppercase: boolean;
|
|
12
|
-
hasLowercase: boolean;
|
|
13
|
-
hasSpecialCharacter: boolean;
|
|
14
|
-
hasDigit: boolean;
|
|
15
|
-
}
|
|
4
|
+
import type { PasswordValidation, EmailConfirmationValidation, ExtendedPasswordValidation } from '@cranberry-money/shared-types';
|
|
16
5
|
/**
|
|
17
6
|
* Checks if a string contains only numeric characters
|
|
18
7
|
* @param str - The string to validate
|
|
@@ -246,5 +235,4 @@ export declare function isInNumberRange(value: number, min: number, max: number)
|
|
|
246
235
|
* isValidPercentage(-10) // false
|
|
247
236
|
*/
|
|
248
237
|
export declare function isValidPercentage(percentage: number): boolean;
|
|
249
|
-
export {};
|
|
250
238
|
//# sourceMappingURL=validation.d.ts.map
|
package/dist/validation.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../src/validation.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../src/validation.ts"],"names":[],"mappings":"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"}
|
package/dist/withdrawal.d.ts
CHANGED
|
@@ -5,14 +5,7 @@
|
|
|
5
5
|
* calculating liquidation progress, and other withdrawal-related operations.
|
|
6
6
|
* Functions are designed to work with generic types to maintain flexibility.
|
|
7
7
|
*/
|
|
8
|
-
|
|
9
|
-
total: number;
|
|
10
|
-
pending: number;
|
|
11
|
-
inProgress: number;
|
|
12
|
-
completed: number;
|
|
13
|
-
failed: number;
|
|
14
|
-
completionRate: number;
|
|
15
|
-
}
|
|
8
|
+
import type { LiquidationProgress } from '@cranberry-money/shared-types';
|
|
16
9
|
/**
|
|
17
10
|
* Formats a withdrawal amount as currency
|
|
18
11
|
*
|
|
@@ -91,5 +84,4 @@ export declare function calculateLiquidationProgress<T extends {
|
|
|
91
84
|
export declare function getTotalEstimatedValue<T extends {
|
|
92
85
|
estimatedValue?: string | null;
|
|
93
86
|
}>(liquidations: T[]): number;
|
|
94
|
-
export {};
|
|
95
87
|
//# sourceMappingURL=withdrawal.d.ts.map
|
package/dist/withdrawal.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withdrawal.d.ts","sourceRoot":"","sources":["../src/withdrawal.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,
|
|
1
|
+
{"version":3,"file":"withdrawal.d.ts","sourceRoot":"","sources":["../src/withdrawal.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAazE;;;;;;;;;;;GAWG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAMtE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAMrE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAK3D;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,4BAA4B,CAAC,CAAC,SAAS;IAAE,iBAAiB,EAAE,MAAM,CAAA;CAAE,EAClF,YAAY,EAAE,CAAC,EAAE,GAChB,mBAAmB,CAkBrB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,SAAS;IAAE,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,EAAE,YAAY,EAAE,CAAC,EAAE,GAAG,MAAM,CAI9G"}
|
package/package.json
CHANGED
package/dist/allocations.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { AssetAllocation } from '@cranberry-money/shared-types';
|
|
2
|
-
/**
|
|
3
|
-
* Validates if allocation percentages sum to 100%
|
|
4
|
-
* Allows for small floating point errors (e.g., 99.99 or 100.01)
|
|
5
|
-
*
|
|
6
|
-
* @param allocations - Array of asset allocations to validate
|
|
7
|
-
* @returns true if allocations sum to approximately 100%, false otherwise
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* const allocations = [
|
|
11
|
-
* { percentage: '50.00' },
|
|
12
|
-
* { percentage: '30.00' },
|
|
13
|
-
* { percentage: '20.00' }
|
|
14
|
-
* ];
|
|
15
|
-
* validateAllocations(allocations); // returns true
|
|
16
|
-
*/
|
|
17
|
-
export declare const validateAllocations: (allocations: readonly AssetAllocation[]) => boolean;
|
|
18
|
-
//# sourceMappingURL=allocations.d.ts.map
|
package/dist/allocations.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Validates if allocation percentages sum to 100%
|
|
3
|
-
* Allows for small floating point errors (e.g., 99.99 or 100.01)
|
|
4
|
-
*
|
|
5
|
-
* @param allocations - Array of asset allocations to validate
|
|
6
|
-
* @returns true if allocations sum to approximately 100%, false otherwise
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* const allocations = [
|
|
10
|
-
* { percentage: '50.00' },
|
|
11
|
-
* { percentage: '30.00' },
|
|
12
|
-
* { percentage: '20.00' }
|
|
13
|
-
* ];
|
|
14
|
-
* validateAllocations(allocations); // returns true
|
|
15
|
-
*/
|
|
16
|
-
export const validateAllocations = (allocations) => {
|
|
17
|
-
const totalPercentage = allocations.reduce((sum, allocation) => sum + parseFloat(allocation.percentage), 0);
|
|
18
|
-
// Allow for small floating point errors (e.g., 99.99 or 100.01)
|
|
19
|
-
return Math.abs(totalPercentage - 100) < 0.01;
|
|
20
|
-
};
|
package/dist/cash-account.d.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Base transaction type interface for type flexibility
|
|
3
|
-
*/
|
|
4
|
-
export interface BaseTransactionType {
|
|
5
|
-
readonly [key: string]: string;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* Format cash account balance with AUD currency formatting
|
|
9
|
-
*
|
|
10
|
-
* @param balance - Balance value to format (string or number)
|
|
11
|
-
* @returns Formatted currency string using Australian locale and AUD currency
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* formatBalance(1234.56); // returns '$1,234.56'
|
|
15
|
-
* formatBalance('1000'); // returns '$1,000.00'
|
|
16
|
-
* formatBalance(0); // returns '$0.00'
|
|
17
|
-
*/
|
|
18
|
-
export declare const formatBalance: (balance: string | number) => string;
|
|
19
|
-
/**
|
|
20
|
-
* Format transaction amount with signed currency formatting (shows + or -)
|
|
21
|
-
*
|
|
22
|
-
* @param amount - Transaction amount to format (string or number)
|
|
23
|
-
* @returns Formatted signed currency string using Australian locale and AUD currency
|
|
24
|
-
*
|
|
25
|
-
* @example
|
|
26
|
-
* formatTransactionAmount(1234.56); // returns '+$1,234.56'
|
|
27
|
-
* formatTransactionAmount(-500); // returns '-$500.00'
|
|
28
|
-
* formatTransactionAmount('1000'); // returns '+$1,000.00'
|
|
29
|
-
*/
|
|
30
|
-
export declare const formatTransactionAmount: (amount: string | number) => string;
|
|
31
|
-
/**
|
|
32
|
-
* Get human-readable label for transaction type
|
|
33
|
-
*
|
|
34
|
-
* @param transactionType - Transaction type key
|
|
35
|
-
* @param labels - Optional custom transaction type labels (defaults to shared constants)
|
|
36
|
-
* @returns Human-readable transaction type label
|
|
37
|
-
*
|
|
38
|
-
* @example
|
|
39
|
-
* getTransactionTypeLabel('DEPOSIT'); // returns transaction type label from constants
|
|
40
|
-
* getTransactionTypeLabel('WITHDRAWAL'); // returns transaction type label from constants
|
|
41
|
-
*/
|
|
42
|
-
export declare const getTransactionTypeLabel: <T extends string>(transactionType: T, labels?: Record<T, string>) => string;
|
|
43
|
-
//# sourceMappingURL=cash-account.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cash-account.d.ts","sourceRoot":"","sources":["../src/cash-account.ts"],"names":[],"mappings":"AAOA;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;CAChC;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,aAAa,GAAI,SAAS,MAAM,GAAG,MAAM,KAAG,MAMxD,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,uBAAuB,GAAI,QAAQ,MAAM,GAAG,MAAM,KAAG,MAMjE,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,uBAAuB,GAAI,CAAC,SAAS,MAAM,EACtD,iBAAiB,CAAC,EAClB,SAAQ,MAAM,CAAC,CAAC,EAAE,MAAM,CAA6D,KACpF,MAEF,CAAC"}
|
package/dist/cash-account.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { LOCALE_AUSTRALIA, CURRENCY_AUD, CASH_ACCOUNT_TRANSACTION_TYPE_LABELS, } from '@cranberry-money/shared-constants';
|
|
2
|
-
import { NUMBER_FORMAT_OPTIONS_CURRENCY, NUMBER_FORMAT_OPTIONS_CURRENCY_SIGNED } from './currency';
|
|
3
|
-
/**
|
|
4
|
-
* Format cash account balance with AUD currency formatting
|
|
5
|
-
*
|
|
6
|
-
* @param balance - Balance value to format (string or number)
|
|
7
|
-
* @returns Formatted currency string using Australian locale and AUD currency
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* formatBalance(1234.56); // returns '$1,234.56'
|
|
11
|
-
* formatBalance('1000'); // returns '$1,000.00'
|
|
12
|
-
* formatBalance(0); // returns '$0.00'
|
|
13
|
-
*/
|
|
14
|
-
export const formatBalance = (balance) => {
|
|
15
|
-
const numBalance = typeof balance === 'string' ? parseFloat(balance) : balance;
|
|
16
|
-
return new Intl.NumberFormat(LOCALE_AUSTRALIA, {
|
|
17
|
-
...NUMBER_FORMAT_OPTIONS_CURRENCY,
|
|
18
|
-
currency: CURRENCY_AUD,
|
|
19
|
-
}).format(numBalance);
|
|
20
|
-
};
|
|
21
|
-
/**
|
|
22
|
-
* Format transaction amount with signed currency formatting (shows + or -)
|
|
23
|
-
*
|
|
24
|
-
* @param amount - Transaction amount to format (string or number)
|
|
25
|
-
* @returns Formatted signed currency string using Australian locale and AUD currency
|
|
26
|
-
*
|
|
27
|
-
* @example
|
|
28
|
-
* formatTransactionAmount(1234.56); // returns '+$1,234.56'
|
|
29
|
-
* formatTransactionAmount(-500); // returns '-$500.00'
|
|
30
|
-
* formatTransactionAmount('1000'); // returns '+$1,000.00'
|
|
31
|
-
*/
|
|
32
|
-
export const formatTransactionAmount = (amount) => {
|
|
33
|
-
const numAmount = typeof amount === 'string' ? parseFloat(amount) : amount;
|
|
34
|
-
return new Intl.NumberFormat(LOCALE_AUSTRALIA, {
|
|
35
|
-
...NUMBER_FORMAT_OPTIONS_CURRENCY_SIGNED,
|
|
36
|
-
currency: CURRENCY_AUD,
|
|
37
|
-
}).format(numAmount);
|
|
38
|
-
};
|
|
39
|
-
/**
|
|
40
|
-
* Get human-readable label for transaction type
|
|
41
|
-
*
|
|
42
|
-
* @param transactionType - Transaction type key
|
|
43
|
-
* @param labels - Optional custom transaction type labels (defaults to shared constants)
|
|
44
|
-
* @returns Human-readable transaction type label
|
|
45
|
-
*
|
|
46
|
-
* @example
|
|
47
|
-
* getTransactionTypeLabel('DEPOSIT'); // returns transaction type label from constants
|
|
48
|
-
* getTransactionTypeLabel('WITHDRAWAL'); // returns transaction type label from constants
|
|
49
|
-
*/
|
|
50
|
-
export const getTransactionTypeLabel = (transactionType, labels = CASH_ACCOUNT_TRANSACTION_TYPE_LABELS) => {
|
|
51
|
-
return labels[transactionType];
|
|
52
|
-
};
|
package/dist/collections.d.ts
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Generic collection and array utilities
|
|
3
|
-
* Pure functions for common array operations with type safety
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Sort array of objects by a string field
|
|
7
|
-
* @param items - Array of objects to sort
|
|
8
|
-
* @param fieldName - Name of the field to sort by
|
|
9
|
-
* @returns New sorted array
|
|
10
|
-
*/
|
|
11
|
-
export declare function sortByStringField<T>(items: T[], fieldName: keyof T): T[];
|
|
12
|
-
/**
|
|
13
|
-
* Filter array by text search in a specific field (case-insensitive)
|
|
14
|
-
* @param items - Array of objects to filter
|
|
15
|
-
* @param fieldName - Name of the field to search in
|
|
16
|
-
* @param searchTerm - Search term
|
|
17
|
-
* @returns Filtered array
|
|
18
|
-
*/
|
|
19
|
-
export declare function filterByTextSearch<T>(items: T[], fieldName: keyof T, searchTerm: string): T[];
|
|
20
|
-
/**
|
|
21
|
-
* Filter array by boolean field
|
|
22
|
-
* @param items - Array of objects to filter
|
|
23
|
-
* @param fieldName - Name of the boolean field
|
|
24
|
-
* @param value - Boolean value to filter by
|
|
25
|
-
* @returns Filtered array
|
|
26
|
-
*/
|
|
27
|
-
export declare function filterByBooleanField<T>(items: T[], fieldName: keyof T, value: boolean): T[];
|
|
28
|
-
/**
|
|
29
|
-
* Find item by exact field match
|
|
30
|
-
* @param items - Array of objects to search
|
|
31
|
-
* @param fieldName - Name of the field to match
|
|
32
|
-
* @param value - Value to match
|
|
33
|
-
* @returns Found item or undefined
|
|
34
|
-
*/
|
|
35
|
-
export declare function findByField<T>(items: T[], fieldName: keyof T, value: unknown): T | undefined;
|
|
36
|
-
/**
|
|
37
|
-
* Find item by case-insensitive string field match
|
|
38
|
-
* @param items - Array of objects to search
|
|
39
|
-
* @param fieldName - Name of the string field to match
|
|
40
|
-
* @param value - String value to match (case-insensitive)
|
|
41
|
-
* @returns Found item or undefined
|
|
42
|
-
*/
|
|
43
|
-
export declare function findByStringField<T>(items: T[], fieldName: keyof T, value: string): T | undefined;
|
|
44
|
-
/**
|
|
45
|
-
* Extract values from a specific field and sort them
|
|
46
|
-
* @param items - Array of objects
|
|
47
|
-
* @param fieldName - Name of the field to extract
|
|
48
|
-
* @returns Sorted array of extracted values
|
|
49
|
-
*/
|
|
50
|
-
export declare function extractAndSortField<T, K extends keyof T>(items: T[], fieldName: K): T[K][];
|
|
51
|
-
/**
|
|
52
|
-
* Group array items by the first character of a string field
|
|
53
|
-
* @param items - Array of objects to group
|
|
54
|
-
* @param fieldName - Name of the string field to group by
|
|
55
|
-
* @returns Object with first letters as keys and arrays of items as values
|
|
56
|
-
*/
|
|
57
|
-
export declare function groupByFirstLetter<T>(items: T[], fieldName: keyof T): Record<string, T[]>;
|
|
58
|
-
/**
|
|
59
|
-
* Group array items by a field value
|
|
60
|
-
* @param items - Array of objects to group
|
|
61
|
-
* @param fieldName - Name of the field to group by
|
|
62
|
-
* @returns Object with field values as keys and arrays of items as values
|
|
63
|
-
*/
|
|
64
|
-
export declare function groupByField<T, K extends keyof T>(items: T[], fieldName: K): Record<string, T[]>;
|
|
65
|
-
/**
|
|
66
|
-
* Check if any item in array has a specific boolean field value
|
|
67
|
-
* @param items - Array of objects to check
|
|
68
|
-
* @param fieldName - Name of the boolean field
|
|
69
|
-
* @param value - Boolean value to check for
|
|
70
|
-
* @returns true if any item matches, false otherwise
|
|
71
|
-
*/
|
|
72
|
-
export declare function hasItemWithFieldValue<T>(items: T[], fieldName: keyof T, value: unknown): boolean;
|
|
73
|
-
/**
|
|
74
|
-
* Count items that match a field value
|
|
75
|
-
* @param items - Array of objects to count
|
|
76
|
-
* @param fieldName - Name of the field to check
|
|
77
|
-
* @param value - Value to count
|
|
78
|
-
* @returns Number of matching items
|
|
79
|
-
*/
|
|
80
|
-
export declare function countByFieldValue<T>(items: T[], fieldName: keyof T, value: unknown): number;
|
|
81
|
-
//# sourceMappingURL=collections.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"collections.d.ts","sourceRoot":"","sources":["../src/collections.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,SAAS,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,CAMxE;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,SAAS,EAAE,MAAM,CAAC,EAAE,UAAU,EAAE,MAAM,GAAG,CAAC,EAAE,CAM7F;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,SAAS,EAAE,MAAM,CAAC,EAAE,KAAK,EAAE,OAAO,GAAG,CAAC,EAAE,CAE3F;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,SAAS,EAAE,MAAM,CAAC,EAAE,KAAK,EAAE,OAAO,GAAG,CAAC,GAAG,SAAS,CAE5F;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,SAAS,EAAE,MAAM,CAAC,EAAE,KAAK,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS,CAMjG;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,SAAS,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAE1F;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,SAAS,EAAE,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,CAazF;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,SAAS,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,CAYhG;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,SAAS,EAAE,MAAM,CAAC,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAEhG;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,SAAS,EAAE,MAAM,CAAC,EAAE,KAAK,EAAE,OAAO,GAAG,MAAM,CAE3F"}
|
package/dist/collections.js
DELETED
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Generic collection and array utilities
|
|
3
|
-
* Pure functions for common array operations with type safety
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Sort array of objects by a string field
|
|
7
|
-
* @param items - Array of objects to sort
|
|
8
|
-
* @param fieldName - Name of the field to sort by
|
|
9
|
-
* @returns New sorted array
|
|
10
|
-
*/
|
|
11
|
-
export function sortByStringField(items, fieldName) {
|
|
12
|
-
return [...items].sort((a, b) => {
|
|
13
|
-
const aValue = String(a[fieldName]);
|
|
14
|
-
const bValue = String(b[fieldName]);
|
|
15
|
-
return aValue.localeCompare(bValue);
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Filter array by text search in a specific field (case-insensitive)
|
|
20
|
-
* @param items - Array of objects to filter
|
|
21
|
-
* @param fieldName - Name of the field to search in
|
|
22
|
-
* @param searchTerm - Search term
|
|
23
|
-
* @returns Filtered array
|
|
24
|
-
*/
|
|
25
|
-
export function filterByTextSearch(items, fieldName, searchTerm) {
|
|
26
|
-
const lowercaseSearch = searchTerm.toLowerCase();
|
|
27
|
-
return items.filter(item => {
|
|
28
|
-
const fieldValue = String(item[fieldName]).toLowerCase();
|
|
29
|
-
return fieldValue.includes(lowercaseSearch);
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Filter array by boolean field
|
|
34
|
-
* @param items - Array of objects to filter
|
|
35
|
-
* @param fieldName - Name of the boolean field
|
|
36
|
-
* @param value - Boolean value to filter by
|
|
37
|
-
* @returns Filtered array
|
|
38
|
-
*/
|
|
39
|
-
export function filterByBooleanField(items, fieldName, value) {
|
|
40
|
-
return items.filter(item => Boolean(item[fieldName]) === value);
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Find item by exact field match
|
|
44
|
-
* @param items - Array of objects to search
|
|
45
|
-
* @param fieldName - Name of the field to match
|
|
46
|
-
* @param value - Value to match
|
|
47
|
-
* @returns Found item or undefined
|
|
48
|
-
*/
|
|
49
|
-
export function findByField(items, fieldName, value) {
|
|
50
|
-
return items.find(item => item[fieldName] === value);
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Find item by case-insensitive string field match
|
|
54
|
-
* @param items - Array of objects to search
|
|
55
|
-
* @param fieldName - Name of the string field to match
|
|
56
|
-
* @param value - String value to match (case-insensitive)
|
|
57
|
-
* @returns Found item or undefined
|
|
58
|
-
*/
|
|
59
|
-
export function findByStringField(items, fieldName, value) {
|
|
60
|
-
const lowercaseValue = value.toLowerCase();
|
|
61
|
-
return items.find(item => {
|
|
62
|
-
const fieldValue = String(item[fieldName]).toLowerCase();
|
|
63
|
-
return fieldValue === lowercaseValue;
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Extract values from a specific field and sort them
|
|
68
|
-
* @param items - Array of objects
|
|
69
|
-
* @param fieldName - Name of the field to extract
|
|
70
|
-
* @returns Sorted array of extracted values
|
|
71
|
-
*/
|
|
72
|
-
export function extractAndSortField(items, fieldName) {
|
|
73
|
-
return items.map(item => item[fieldName]).sort();
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Group array items by the first character of a string field
|
|
77
|
-
* @param items - Array of objects to group
|
|
78
|
-
* @param fieldName - Name of the string field to group by
|
|
79
|
-
* @returns Object with first letters as keys and arrays of items as values
|
|
80
|
-
*/
|
|
81
|
-
export function groupByFirstLetter(items, fieldName) {
|
|
82
|
-
return items.reduce((groups, item) => {
|
|
83
|
-
const fieldValue = String(item[fieldName]);
|
|
84
|
-
const firstLetter = fieldValue.charAt(0).toUpperCase();
|
|
85
|
-
if (!groups[firstLetter]) {
|
|
86
|
-
groups[firstLetter] = [];
|
|
87
|
-
}
|
|
88
|
-
groups[firstLetter].push(item);
|
|
89
|
-
return groups;
|
|
90
|
-
}, {});
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Group array items by a field value
|
|
94
|
-
* @param items - Array of objects to group
|
|
95
|
-
* @param fieldName - Name of the field to group by
|
|
96
|
-
* @returns Object with field values as keys and arrays of items as values
|
|
97
|
-
*/
|
|
98
|
-
export function groupByField(items, fieldName) {
|
|
99
|
-
return items.reduce((groups, item) => {
|
|
100
|
-
const fieldValue = String(item[fieldName]);
|
|
101
|
-
if (!groups[fieldValue]) {
|
|
102
|
-
groups[fieldValue] = [];
|
|
103
|
-
}
|
|
104
|
-
groups[fieldValue].push(item);
|
|
105
|
-
return groups;
|
|
106
|
-
}, {});
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Check if any item in array has a specific boolean field value
|
|
110
|
-
* @param items - Array of objects to check
|
|
111
|
-
* @param fieldName - Name of the boolean field
|
|
112
|
-
* @param value - Boolean value to check for
|
|
113
|
-
* @returns true if any item matches, false otherwise
|
|
114
|
-
*/
|
|
115
|
-
export function hasItemWithFieldValue(items, fieldName, value) {
|
|
116
|
-
return items.some(item => item[fieldName] === value);
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* Count items that match a field value
|
|
120
|
-
* @param items - Array of objects to count
|
|
121
|
-
* @param fieldName - Name of the field to check
|
|
122
|
-
* @param value - Value to count
|
|
123
|
-
* @returns Number of matching items
|
|
124
|
-
*/
|
|
125
|
-
export function countByFieldValue(items, fieldName, value) {
|
|
126
|
-
return items.filter(item => item[fieldName] === value).length;
|
|
127
|
-
}
|