@cranberry-money/shared-utils 8.19.7 → 8.19.10
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/allocations.d.ts +0 -15
- package/dist/allocations.d.ts.map +1 -1
- package/dist/allocations.js +0 -16
- package/dist/allocations.js.map +1 -1
- package/dist/badge-status.d.ts +0 -58
- package/dist/badge-status.d.ts.map +1 -1
- package/dist/badge-status.js +0 -60
- package/dist/badge-status.js.map +1 -1
- package/dist/badge.d.ts +0 -36
- package/dist/badge.d.ts.map +1 -1
- package/dist/badge.js +0 -46
- package/dist/badge.js.map +1 -1
- package/dist/cash-account.d.ts +0 -36
- package/dist/cash-account.d.ts.map +1 -1
- package/dist/cash-account.js +0 -33
- package/dist/cash-account.js.map +1 -1
- package/dist/currency.d.ts +0 -82
- package/dist/currency.d.ts.map +1 -1
- package/dist/currency.js +0 -82
- package/dist/currency.js.map +1 -1
- package/dist/dashboard.d.ts +0 -48
- package/dist/dashboard.d.ts.map +1 -1
- package/dist/dashboard.js +2 -52
- package/dist/dashboard.js.map +1 -1
- package/dist/date.d.ts +0 -59
- package/dist/date.d.ts.map +1 -1
- package/dist/date.js +0 -59
- package/dist/date.js.map +1 -1
- package/dist/downloads.d.ts +0 -10
- package/dist/downloads.d.ts.map +1 -1
- package/dist/downloads.js +0 -10
- package/dist/downloads.js.map +1 -1
- package/dist/filters.d.ts +0 -74
- package/dist/filters.d.ts.map +1 -1
- package/dist/filters.js +0 -74
- package/dist/filters.js.map +1 -1
- package/dist/holdings.d.ts +0 -13
- package/dist/holdings.d.ts.map +1 -1
- package/dist/holdings.js +0 -13
- package/dist/holdings.js.map +1 -1
- package/dist/index.d.ts +1 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -6
- package/dist/index.js.map +1 -1
- package/dist/instruments.d.ts +0 -14
- package/dist/instruments.d.ts.map +1 -1
- package/dist/instruments.js +1 -15
- package/dist/instruments.js.map +1 -1
- package/dist/numbers.d.ts +0 -14
- package/dist/numbers.d.ts.map +1 -1
- package/dist/numbers.js +0 -14
- package/dist/numbers.js.map +1 -1
- package/dist/portfolio-template.d.ts +0 -50
- package/dist/portfolio-template.d.ts.map +1 -1
- package/dist/portfolio-template.js +0 -47
- package/dist/portfolio-template.js.map +1 -1
- package/dist/portfolio-validation.d.ts +0 -28
- package/dist/portfolio-validation.d.ts.map +1 -1
- package/dist/portfolio-validation.js +0 -25
- package/dist/portfolio-validation.js.map +1 -1
- package/dist/portfolio.d.ts +0 -63
- package/dist/portfolio.d.ts.map +1 -1
- package/dist/portfolio.js +0 -63
- package/dist/portfolio.js.map +1 -1
- package/dist/text.d.ts +0 -20
- package/dist/text.d.ts.map +1 -1
- package/dist/text.js +0 -20
- package/dist/text.js.map +1 -1
- package/dist/user-profile-validation.d.ts +32 -0
- package/dist/user-profile-validation.d.ts.map +1 -0
- package/dist/user-profile-validation.js +179 -0
- package/dist/user-profile-validation.js.map +1 -0
- package/dist/validation.d.ts +0 -79
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +0 -82
- package/dist/validation.js.map +1 -1
- package/dist/withdrawal-status.d.ts +0 -60
- package/dist/withdrawal-status.d.ts.map +1 -1
- package/dist/withdrawal-status.js +11 -71
- package/dist/withdrawal-status.js.map +1 -1
- package/dist/withdrawal.d.ts +0 -40
- package/dist/withdrawal.d.ts.map +1 -1
- package/dist/withdrawal.js +0 -40
- package/dist/withdrawal.js.map +1 -1
- package/package.json +1 -1
package/dist/filters.js
CHANGED
|
@@ -1,109 +1,35 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared utility functions for filter operations
|
|
3
|
-
* Generic, reusable filter functions for managing filter states
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Checks if any filters are active
|
|
7
|
-
* @param filters - The filter object to check
|
|
8
|
-
* @param excludeFields - Fields to exclude from the active check (default: ['searchQuery'])
|
|
9
|
-
* @returns true if any filters are active, false otherwise
|
|
10
|
-
*/
|
|
11
1
|
export function hasActiveFilters(filters, excludeFields = ['searchQuery']) {
|
|
12
2
|
const relevantEntries = Object.entries(filters).filter(([key]) => !excludeFields.includes(key));
|
|
13
3
|
return relevantEntries.some(([, value]) => value !== undefined && value !== null && value !== '' && !(Array.isArray(value) && value.length === 0));
|
|
14
4
|
}
|
|
15
|
-
/**
|
|
16
|
-
* Counts the number of active filters
|
|
17
|
-
* @param filters - The filter object to count
|
|
18
|
-
* @param excludeFields - Fields to exclude from the count (default: ['searchQuery'])
|
|
19
|
-
* @returns The number of active filters
|
|
20
|
-
*/
|
|
21
5
|
export function countActiveFilters(filters, excludeFields = ['searchQuery']) {
|
|
22
6
|
const relevantEntries = Object.entries(filters).filter(([key]) => !excludeFields.includes(key));
|
|
23
7
|
return relevantEntries.filter(([, value]) => value !== undefined && value !== null && value !== '' && !(Array.isArray(value) && value.length === 0)).length;
|
|
24
8
|
}
|
|
25
|
-
/**
|
|
26
|
-
* Type-safe filter update helper
|
|
27
|
-
* @param currentFilters - The current filter state
|
|
28
|
-
* @param updates - The updates to apply
|
|
29
|
-
* @returns A new filter object with updates applied
|
|
30
|
-
*/
|
|
31
9
|
export function updateFilters(currentFilters, updates) {
|
|
32
10
|
return { ...currentFilters, ...updates };
|
|
33
11
|
}
|
|
34
|
-
/**
|
|
35
|
-
* Common Filter Patterns
|
|
36
|
-
* Pre-configured utilities for common filter use cases
|
|
37
|
-
*/
|
|
38
|
-
/**
|
|
39
|
-
* Check if any instrument filters are active (excluding searchQuery)
|
|
40
|
-
* Common pattern for instrument filter checking across applications
|
|
41
|
-
* @param filters - The instrument filter object to check
|
|
42
|
-
* @returns true if any non-search filters are active
|
|
43
|
-
*/
|
|
44
12
|
export function hasActiveInstrumentFilters(filters) {
|
|
45
13
|
return hasActiveFilters(filters, ['searchQuery']);
|
|
46
14
|
}
|
|
47
|
-
/**
|
|
48
|
-
* Count active instrument filters (excluding searchQuery)
|
|
49
|
-
* Common pattern for instrument filter counting across applications
|
|
50
|
-
* @param filters - The instrument filter object to count
|
|
51
|
-
* @returns number of active non-search filters
|
|
52
|
-
*/
|
|
53
15
|
export function countActiveInstrumentFilters(filters) {
|
|
54
16
|
return countActiveFilters(filters, ['searchQuery']);
|
|
55
17
|
}
|
|
56
|
-
/**
|
|
57
|
-
* Check if any trade filters are active (excluding searchQuery)
|
|
58
|
-
* Common pattern for trade filter checking across applications
|
|
59
|
-
* @param filters - The trade filter object to check
|
|
60
|
-
* @returns true if any non-search filters are active
|
|
61
|
-
*/
|
|
62
18
|
export function hasActiveTradeFilters(filters) {
|
|
63
19
|
return hasActiveFilters(filters, ['searchQuery']);
|
|
64
20
|
}
|
|
65
|
-
/**
|
|
66
|
-
* Count active trade filters (excluding searchQuery)
|
|
67
|
-
* Common pattern for trade filter counting across applications
|
|
68
|
-
* @param filters - The trade filter object to count
|
|
69
|
-
* @returns number of active non-search filters
|
|
70
|
-
*/
|
|
71
21
|
export function countActiveTradeFilters(filters) {
|
|
72
22
|
return countActiveFilters(filters, ['searchQuery']);
|
|
73
23
|
}
|
|
74
|
-
/**
|
|
75
|
-
* Check if any transaction filters are active (excluding searchQuery)
|
|
76
|
-
* Common pattern for transaction filter checking across applications
|
|
77
|
-
* @param filters - The transaction filter object to check
|
|
78
|
-
* @returns true if any non-search filters are active
|
|
79
|
-
*/
|
|
80
24
|
export function hasActiveTransactionFilters(filters) {
|
|
81
25
|
return hasActiveFilters(filters, ['searchQuery']);
|
|
82
26
|
}
|
|
83
|
-
/**
|
|
84
|
-
* Count active transaction filters (excluding searchQuery)
|
|
85
|
-
* Common pattern for transaction filter counting across applications
|
|
86
|
-
* @param filters - The transaction filter object to count
|
|
87
|
-
* @returns number of active non-search filters
|
|
88
|
-
*/
|
|
89
27
|
export function countActiveTransactionFilters(filters) {
|
|
90
28
|
return countActiveFilters(filters, ['searchQuery']);
|
|
91
29
|
}
|
|
92
|
-
/**
|
|
93
|
-
* Check if any target trade filters are active (excluding searchQuery)
|
|
94
|
-
* Common pattern for target trade filter checking across applications
|
|
95
|
-
* @param filters - The target trade filter object to check
|
|
96
|
-
* @returns true if any non-search filters are active
|
|
97
|
-
*/
|
|
98
30
|
export function hasActiveTargetTradeFilters(filters) {
|
|
99
31
|
return hasActiveFilters(filters, ['searchQuery']);
|
|
100
32
|
}
|
|
101
|
-
/**
|
|
102
|
-
* Count active target trade filters (excluding searchQuery)
|
|
103
|
-
* Common pattern for target trade filter counting across applications
|
|
104
|
-
* @param filters - The target trade filter object to count
|
|
105
|
-
* @returns number of active non-search filters
|
|
106
|
-
*/
|
|
107
33
|
export function countActiveTargetTradeFilters(filters) {
|
|
108
34
|
return countActiveFilters(filters, ['searchQuery']);
|
|
109
35
|
}
|
package/dist/filters.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filters.js","sourceRoot":"","sources":["../src/filters.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"filters.js","sourceRoot":"","sources":["../src/filters.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,gBAAgB,CAC9B,OAAU,EACV,gBAA6B,CAAC,aAAwB,CAAC;IAEvD,MAAM,eAAe,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,aAAa,CAAC,QAAQ,CAAC,GAAc,CAAC,CAAC,CAAC;IAE3G,OAAO,eAAe,CAAC,IAAI,CACzB,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,EAAE,CACZ,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,EAAE,IAAI,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC,CACzG,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,kBAAkB,CAChC,OAAU,EACV,gBAA6B,CAAC,aAAwB,CAAC;IAEvD,MAAM,eAAe,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,aAAa,CAAC,QAAQ,CAAC,GAAc,CAAC,CAAC,CAAC;IAE3G,OAAO,eAAe,CAAC,MAAM,CAC3B,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,EAAE,CACZ,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,EAAE,IAAI,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC,CACzG,CAAC,MAAM,CAAC;AACX,CAAC;AAED,MAAM,UAAU,aAAa,CAAoC,cAAiB,EAAE,OAAmB;IACrG,OAAO,EAAE,GAAG,cAAc,EAAE,GAAG,OAAO,EAAE,CAAC;AAC3C,CAAC;AAED,MAAM,UAAU,0BAA0B,CAAoC,OAAU;IACtF,OAAO,gBAAgB,CAAC,OAAO,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC;AACpD,CAAC;AAED,MAAM,UAAU,4BAA4B,CAAoC,OAAU;IACxF,OAAO,kBAAkB,CAAC,OAAO,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC;AACtD,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAoC,OAAU;IACjF,OAAO,gBAAgB,CAAC,OAAO,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC;AACpD,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAoC,OAAU;IACnF,OAAO,kBAAkB,CAAC,OAAO,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC;AACtD,CAAC;AAED,MAAM,UAAU,2BAA2B,CAAoC,OAAU;IACvF,OAAO,gBAAgB,CAAC,OAAO,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC;AACpD,CAAC;AAED,MAAM,UAAU,6BAA6B,CAAoC,OAAU;IACzF,OAAO,kBAAkB,CAAC,OAAO,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC;AACtD,CAAC;AAED,MAAM,UAAU,2BAA2B,CAAoC,OAAU;IACvF,OAAO,gBAAgB,CAAC,OAAO,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC;AACpD,CAAC;AAED,MAAM,UAAU,6BAA6B,CAAoC,OAAU;IACzF,OAAO,kBAAkB,CAAC,OAAO,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC;AACtD,CAAC"}
|
package/dist/holdings.d.ts
CHANGED
|
@@ -1,16 +1,3 @@
|
|
|
1
1
|
import type { AssetHolding } from '@cranberry-money/shared-types';
|
|
2
|
-
/**
|
|
3
|
-
* Calculates holding allocation percentages within a portfolio
|
|
4
|
-
*
|
|
5
|
-
* @param holdings - Array of asset holdings
|
|
6
|
-
* @returns Map of instrument UUIDs to their percentage allocations
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* const holdings = [
|
|
10
|
-
* { instrument: { uuid: '123' }, quantity: 100 },
|
|
11
|
-
* { instrument: { uuid: '456' }, quantity: 100 }
|
|
12
|
-
* ];
|
|
13
|
-
* calculateHoldingAllocations(holdings); // returns { '123': 50, '456': 50 }
|
|
14
|
-
*/
|
|
15
2
|
export declare const calculateHoldingAllocations: (holdings: readonly AssetHolding[]) => Record<string, number>;
|
|
16
3
|
//# sourceMappingURL=holdings.d.ts.map
|
package/dist/holdings.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"holdings.d.ts","sourceRoot":"","sources":["../src/holdings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAElE
|
|
1
|
+
{"version":3,"file":"holdings.d.ts","sourceRoot":"","sources":["../src/holdings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAElE,eAAO,MAAM,2BAA2B,GAAI,UAAU,SAAS,YAAY,EAAE,KAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAWpG,CAAC"}
|
package/dist/holdings.js
CHANGED
|
@@ -1,16 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Calculates holding allocation percentages within a portfolio
|
|
3
|
-
*
|
|
4
|
-
* @param holdings - Array of asset holdings
|
|
5
|
-
* @returns Map of instrument UUIDs to their percentage allocations
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* const holdings = [
|
|
9
|
-
* { instrument: { uuid: '123' }, quantity: 100 },
|
|
10
|
-
* { instrument: { uuid: '456' }, quantity: 100 }
|
|
11
|
-
* ];
|
|
12
|
-
* calculateHoldingAllocations(holdings); // returns { '123': 50, '456': 50 }
|
|
13
|
-
*/
|
|
14
1
|
export const calculateHoldingAllocations = (holdings) => {
|
|
15
2
|
const totalQuantity = holdings.reduce((sum, holding) => sum + holding.quantity, 0);
|
|
16
3
|
if (totalQuantity === 0)
|
package/dist/holdings.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"holdings.js","sourceRoot":"","sources":["../src/holdings.ts"],"names":[],"mappings":"AAEA
|
|
1
|
+
{"version":3,"file":"holdings.js","sourceRoot":"","sources":["../src/holdings.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,QAAiC,EAA0B,EAAE;IACvG,MAAM,aAAa,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE,CAAC,GAAG,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;IAEnF,IAAI,aAAa,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAEnC,MAAM,WAAW,GAA2B,EAAE,CAAC;IAC/C,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;QACzB,WAAW,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,QAAQ,GAAG,aAAa,CAAC,GAAG,GAAG,CAAC;IAClF,CAAC,CAAC,CAAC;IAEH,OAAO,WAAW,CAAC;AACrB,CAAC,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @cranberry-money/shared-utils
|
|
3
|
-
*
|
|
4
|
-
* Shared utility functions for the Blueberry platform.
|
|
5
|
-
* All utilities are pure functions with no side effects.
|
|
6
|
-
*/
|
|
7
1
|
export { truncateText } from './text';
|
|
8
2
|
export { formatDate, formatShortDate, formatTime, formatDateTime } from './date';
|
|
9
3
|
export { NUMBER_FORMAT_OPTIONS_CURRENCY, NUMBER_FORMAT_OPTIONS_CURRENCY_SIGNED, formatCurrency, parseCurrencyInput, formatCurrencyWithCode, formatDefaultCurrency, formatShares, } from './currency';
|
|
@@ -12,6 +6,7 @@ export { getTradeStatusBadge, getWithdrawalStatusBadge, getLiquidationStatusBadg
|
|
|
12
6
|
export { formatPortfolioValue, calculateTotalValue, getMarketAllocation, getCashAllocation } from './portfolio';
|
|
13
7
|
export { calculateLiquidationProgress, getTotalEstimatedValue } from './withdrawal';
|
|
14
8
|
export { isNumericOnly, validatePassword, isValidTokenFormat, formatVerificationToken, validateEmailConfirmation, isValidPhoneFormat, isValidFullName, isValidDateOfBirth, formatPhoneNumber, isValidInvestmentAmount, isValidSourceOfFunds, hasMinimumSelection, } from './validation';
|
|
9
|
+
export { validateUserProfileField, validateUserProfileFieldWithState, validateUserProfileFields, isUserProfileValid, type UserProfileFieldValidation, type UserProfileFieldValidationWithState, } from './user-profile-validation';
|
|
15
10
|
export { hasActiveFilters, countActiveFilters, updateFilters, hasActiveInstrumentFilters, countActiveInstrumentFilters, hasActiveTradeFilters, countActiveTradeFilters, hasActiveTransactionFilters, countActiveTransactionFilters, hasActiveTargetTradeFilters, countActiveTargetTradeFilters, } from './filters';
|
|
16
11
|
export { formatInstrumentPrice, getCurrencySymbol } from './instruments';
|
|
17
12
|
export { downloadBlob } from './downloads';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AACjF,OAAO,EACL,8BAA8B,EAC9B,qCAAqC,EACrC,cAAc,EACd,kBAAkB,EAClB,sBAAsB,EACtB,qBAAqB,EACrB,YAAY,GACb,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACnE,OAAO,EACL,mBAAmB,EACnB,wBAAwB,EACxB,yBAAyB,EACzB,yBAAyB,GAC1B,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChH,OAAO,EAAE,4BAA4B,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AACpF,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,kBAAkB,EAClB,uBAAuB,EACvB,yBAAyB,EACzB,kBAAkB,EAClB,eAAe,EACf,kBAAkB,EAClB,iBAAiB,EACjB,uBAAuB,EACvB,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,wBAAwB,EACxB,iCAAiC,EACjC,yBAAyB,EACzB,kBAAkB,EAClB,KAAK,0BAA0B,EAC/B,KAAK,mCAAmC,GACzC,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,aAAa,EACb,0BAA0B,EAC1B,4BAA4B,EAC5B,qBAAqB,EACrB,uBAAuB,EACvB,2BAA2B,EAC3B,6BAA6B,EAC7B,2BAA2B,EAC3B,6BAA6B,GAC9B,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACzE,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,2BAA2B,EAAE,MAAM,YAAY,CAAC;AACzD,OAAO,EACL,qBAAqB,EACrB,eAAe,EACf,gBAAgB,EAChB,uBAAuB,EACvB,KAAK,qBAAqB,GAC3B,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,wBAAwB,EACxB,0BAA0B,EAC1B,KAAK,4BAA4B,GAClC,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EACL,cAAc,EACd,cAAc,EACd,sBAAsB,EACtB,cAAc,EACd,yBAAyB,EACzB,yBAAyB,GAC1B,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,wBAAwB,EACxB,6BAA6B,EAC7B,sBAAsB,EACtB,KAAK,cAAc,GACpB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,aAAa,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @cranberry-money/shared-utils
|
|
3
|
-
*
|
|
4
|
-
* Shared utility functions for the Blueberry platform.
|
|
5
|
-
* All utilities are pure functions with no side effects.
|
|
6
|
-
*/
|
|
7
1
|
export { truncateText } from './text';
|
|
8
2
|
export { formatDate, formatShortDate, formatTime, formatDateTime } from './date';
|
|
9
3
|
export { NUMBER_FORMAT_OPTIONS_CURRENCY, NUMBER_FORMAT_OPTIONS_CURRENCY_SIGNED, formatCurrency, parseCurrencyInput, formatCurrencyWithCode, formatDefaultCurrency, formatShares, } from './currency';
|
|
@@ -12,6 +6,7 @@ export { getTradeStatusBadge, getWithdrawalStatusBadge, getLiquidationStatusBadg
|
|
|
12
6
|
export { formatPortfolioValue, calculateTotalValue, getMarketAllocation, getCashAllocation } from './portfolio';
|
|
13
7
|
export { calculateLiquidationProgress, getTotalEstimatedValue } from './withdrawal';
|
|
14
8
|
export { isNumericOnly, validatePassword, isValidTokenFormat, formatVerificationToken, validateEmailConfirmation, isValidPhoneFormat, isValidFullName, isValidDateOfBirth, formatPhoneNumber, isValidInvestmentAmount, isValidSourceOfFunds, hasMinimumSelection, } from './validation';
|
|
9
|
+
export { validateUserProfileField, validateUserProfileFieldWithState, validateUserProfileFields, isUserProfileValid, } from './user-profile-validation';
|
|
15
10
|
export { hasActiveFilters, countActiveFilters, updateFilters, hasActiveInstrumentFilters, countActiveInstrumentFilters, hasActiveTradeFilters, countActiveTradeFilters, hasActiveTransactionFilters, countActiveTransactionFilters, hasActiveTargetTradeFilters, countActiveTargetTradeFilters, } from './filters';
|
|
16
11
|
export { formatInstrumentPrice, getCurrencySymbol } from './instruments';
|
|
17
12
|
export { downloadBlob } from './downloads';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AACjF,OAAO,EACL,8BAA8B,EAC9B,qCAAqC,EACrC,cAAc,EACd,kBAAkB,EAClB,sBAAsB,EACtB,qBAAqB,EACrB,YAAY,GACb,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACnE,OAAO,EACL,mBAAmB,EACnB,wBAAwB,EACxB,yBAAyB,EACzB,yBAAyB,GAC1B,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChH,OAAO,EAAE,4BAA4B,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AACpF,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,kBAAkB,EAClB,uBAAuB,EACvB,yBAAyB,EACzB,kBAAkB,EAClB,eAAe,EACf,kBAAkB,EAClB,iBAAiB,EACjB,uBAAuB,EACvB,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,wBAAwB,EACxB,iCAAiC,EACjC,yBAAyB,EACzB,kBAAkB,GAGnB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,aAAa,EACb,0BAA0B,EAC1B,4BAA4B,EAC5B,qBAAqB,EACrB,uBAAuB,EACvB,2BAA2B,EAC3B,6BAA6B,EAC7B,2BAA2B,EAC3B,6BAA6B,GAC9B,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACzE,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,2BAA2B,EAAE,MAAM,YAAY,CAAC;AACzD,OAAO,EACL,qBAAqB,EACrB,eAAe,EACf,gBAAgB,EAChB,uBAAuB,GAExB,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,wBAAwB,EACxB,0BAA0B,GAE3B,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EACL,cAAc,EACd,cAAc,EACd,sBAAsB,EACtB,cAAc,EACd,yBAAyB,EACzB,yBAAyB,GAC1B,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,wBAAwB,EACxB,6BAA6B,EAC7B,sBAAsB,GAEvB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,aAAa,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/instruments.d.ts
CHANGED
|
@@ -1,17 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Instrument and market data formatting utilities
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* Format instrument price with currency symbol
|
|
6
|
-
* @param price - The price as string
|
|
7
|
-
* @param currency - The currency code
|
|
8
|
-
* @returns Formatted price with currency symbol
|
|
9
|
-
*/
|
|
10
1
|
export declare function formatInstrumentPrice(price: string, currency?: string | null): string;
|
|
11
|
-
/**
|
|
12
|
-
* Get currency symbol for display
|
|
13
|
-
* @param currency - The currency code
|
|
14
|
-
* @returns Currency symbol
|
|
15
|
-
*/
|
|
16
2
|
export declare function getCurrencySymbol(currency?: string | null): string;
|
|
17
3
|
//# sourceMappingURL=instruments.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instruments.d.ts","sourceRoot":"","sources":["../src/instruments.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"instruments.d.ts","sourceRoot":"","sources":["../src/instruments.ts"],"names":[],"mappings":"AAEA,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAMrF;AAED,wBAAgB,iBAAiB,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAalE"}
|
package/dist/instruments.js
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Instrument and market data formatting utilities
|
|
3
|
-
*/
|
|
4
1
|
import { CURRENCY_USD, CURRENCY_AUD } from '@cranberry-money/shared-constants';
|
|
5
|
-
/**
|
|
6
|
-
* Format instrument price with currency symbol
|
|
7
|
-
* @param price - The price as string
|
|
8
|
-
* @param currency - The currency code
|
|
9
|
-
* @returns Formatted price with currency symbol
|
|
10
|
-
*/
|
|
11
2
|
export function formatInstrumentPrice(price, currency) {
|
|
12
3
|
const numericPrice = parseFloat(price);
|
|
13
4
|
if (isNaN(numericPrice))
|
|
@@ -15,11 +6,6 @@ export function formatInstrumentPrice(price, currency) {
|
|
|
15
6
|
const currencySymbol = getCurrencySymbol(currency);
|
|
16
7
|
return `${currencySymbol}${numericPrice.toFixed(2)}`;
|
|
17
8
|
}
|
|
18
|
-
/**
|
|
19
|
-
* Get currency symbol for display
|
|
20
|
-
* @param currency - The currency code
|
|
21
|
-
* @returns Currency symbol
|
|
22
|
-
*/
|
|
23
9
|
export function getCurrencySymbol(currency) {
|
|
24
10
|
switch (currency) {
|
|
25
11
|
case CURRENCY_USD:
|
|
@@ -31,7 +17,7 @@ export function getCurrencySymbol(currency) {
|
|
|
31
17
|
case 'GBP':
|
|
32
18
|
return '£';
|
|
33
19
|
default:
|
|
34
|
-
return '$';
|
|
20
|
+
return '$';
|
|
35
21
|
}
|
|
36
22
|
}
|
|
37
23
|
//# sourceMappingURL=instruments.js.map
|
package/dist/instruments.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instruments.js","sourceRoot":"","sources":["../src/instruments.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"instruments.js","sourceRoot":"","sources":["../src/instruments.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAE/E,MAAM,UAAU,qBAAqB,CAAC,KAAa,EAAE,QAAwB;IAC3E,MAAM,YAAY,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;IACvC,IAAI,KAAK,CAAC,YAAY,CAAC;QAAE,OAAO,KAAK,CAAC;IAEtC,MAAM,cAAc,GAAG,iBAAiB,CAAC,QAAQ,CAAC,CAAC;IACnD,OAAO,GAAG,cAAc,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;AACvD,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,QAAwB;IACxD,QAAQ,QAAQ,EAAE,CAAC;QACjB,KAAK,YAAY;YACf,OAAO,GAAG,CAAC;QACb,KAAK,YAAY;YACf,OAAO,IAAI,CAAC;QACd,KAAK,KAAK;YACR,OAAO,GAAG,CAAC;QACb,KAAK,KAAK;YACR,OAAO,GAAG,CAAC;QACb;YACE,OAAO,GAAG,CAAC;IACf,CAAC;AACH,CAAC"}
|
package/dist/numbers.d.ts
CHANGED
|
@@ -1,16 +1,2 @@
|
|
|
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
1
|
export declare function formatQuantityWithSuffix(quantity: number, decimals?: number): string;
|
|
16
2
|
//# sourceMappingURL=numbers.d.ts.map
|
package/dist/numbers.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"numbers.d.ts","sourceRoot":"","sources":["../src/numbers.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"numbers.d.ts","sourceRoot":"","sources":["../src/numbers.ts"],"names":[],"mappings":"AAAA,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAU,GAAG,MAAM,CAWvF"}
|
package/dist/numbers.js
CHANGED
|
@@ -1,17 +1,3 @@
|
|
|
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
1
|
export function formatQuantityWithSuffix(quantity, decimals = 1) {
|
|
16
2
|
const million = 1000000;
|
|
17
3
|
const thousand = 1000;
|
package/dist/numbers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"numbers.js","sourceRoot":"","sources":["../src/numbers.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"numbers.js","sourceRoot":"","sources":["../src/numbers.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,wBAAwB,CAAC,QAAgB,EAAE,WAAmB,CAAC;IAC7E,MAAM,OAAO,GAAG,OAAO,CAAC;IACxB,MAAM,QAAQ,GAAG,IAAI,CAAC;IAEtB,IAAI,QAAQ,IAAI,OAAO,EAAE,CAAC;QACxB,OAAO,GAAG,CAAC,QAAQ,GAAG,OAAO,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC;IACtD,CAAC;SAAM,IAAI,QAAQ,IAAI,QAAQ,EAAE,CAAC;QAChC,OAAO,GAAG,CAAC,QAAQ,GAAG,QAAQ,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC;IACvD,CAAC;SAAM,CAAC;QACN,OAAO,QAAQ,CAAC,QAAQ,EAAE,CAAC;IAC7B,CAAC;AACH,CAAC"}
|
|
@@ -1,57 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Base interface for allocation objects
|
|
3
|
-
*/
|
|
4
1
|
export interface BaseAllocation {
|
|
5
2
|
readonly percentage: string;
|
|
6
3
|
}
|
|
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
4
|
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
5
|
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
6
|
export declare const formatRiskLevelDisplay: (riskLevel: string) => string;
|
|
57
7
|
//# sourceMappingURL=portfolio-template.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"portfolio-template.d.ts","sourceRoot":"","sources":["../src/portfolio-template.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"portfolio-template.d.ts","sourceRoot":"","sources":["../src/portfolio-template.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AAED,eAAO,MAAM,wBAAwB,GAAI,CAAC,SAAS,cAAc,EAAE,aAAa,SAAS,CAAC,EAAE,KAAG,MAI9F,CAAC;AAEF,eAAO,MAAM,6BAA6B,GAAI,CAAC,SAAS,cAAc,EACpE,aAAa,SAAS,CAAC,EAAE,EACzB,YAAW,MAAa,KACvB,OAGF,CAAC;AAEF,eAAO,MAAM,sBAAsB,GAAI,WAAW,MAAM,KAAG,MAG1D,CAAC"}
|
|
@@ -1,59 +1,12 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Calculate total allocation from an array of allocations
|
|
3
|
-
*
|
|
4
|
-
* @param allocations - Array of allocation objects with percentage strings
|
|
5
|
-
* @returns Total allocation as a number
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* const total = calculateTotalAllocation([
|
|
9
|
-
* { percentage: '50.5' },
|
|
10
|
-
* { percentage: '30.0' },
|
|
11
|
-
* { percentage: '19.5' }
|
|
12
|
-
* ]);
|
|
13
|
-
* // Returns 100.0
|
|
14
|
-
*/
|
|
15
1
|
export const calculateTotalAllocation = (allocations) => {
|
|
16
2
|
return allocations.reduce((total, allocation) => {
|
|
17
3
|
return total + parseFloat(allocation.percentage || '0');
|
|
18
4
|
}, 0);
|
|
19
5
|
};
|
|
20
|
-
/**
|
|
21
|
-
* Validate that allocation percentages sum to approximately 100%
|
|
22
|
-
*
|
|
23
|
-
* @param allocations - Array of allocation objects with percentage strings
|
|
24
|
-
* @param tolerance - Tolerance for percentage validation (default: 0.01)
|
|
25
|
-
* @returns True if allocations sum to approximately 100%
|
|
26
|
-
*
|
|
27
|
-
* @example
|
|
28
|
-
* const isValid = validateAllocationPercentages([
|
|
29
|
-
* { percentage: '50.0' },
|
|
30
|
-
* { percentage: '30.0' },
|
|
31
|
-
* { percentage: '20.0' }
|
|
32
|
-
* ]);
|
|
33
|
-
* // Returns true
|
|
34
|
-
*
|
|
35
|
-
* @example
|
|
36
|
-
* const isValid = validateAllocationPercentages([
|
|
37
|
-
* { percentage: '50.0' },
|
|
38
|
-
* { percentage: '30.0' },
|
|
39
|
-
* { percentage: '15.0' }
|
|
40
|
-
* ]);
|
|
41
|
-
* // Returns false (sums to 95%)
|
|
42
|
-
*/
|
|
43
6
|
export const validateAllocationPercentages = (allocations, tolerance = 0.01) => {
|
|
44
7
|
const total = calculateTotalAllocation(allocations);
|
|
45
8
|
return Math.abs(total - 100) <= tolerance;
|
|
46
9
|
};
|
|
47
|
-
/**
|
|
48
|
-
* Format risk level for display (re-export from formatting utilities)
|
|
49
|
-
*
|
|
50
|
-
* @param riskLevel - Risk level string to format
|
|
51
|
-
* @returns Formatted risk level string
|
|
52
|
-
*
|
|
53
|
-
* @example
|
|
54
|
-
* formatRiskLevelDisplay('HIGH'); // returns 'High'
|
|
55
|
-
* formatRiskLevelDisplay('moderate'); // returns 'Moderate'
|
|
56
|
-
*/
|
|
57
10
|
export const formatRiskLevelDisplay = (riskLevel) => {
|
|
58
11
|
if (!riskLevel)
|
|
59
12
|
return riskLevel;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"portfolio-template.js","sourceRoot":"","sources":["../src/portfolio-template.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"portfolio-template.js","sourceRoot":"","sources":["../src/portfolio-template.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAA2B,WAAyB,EAAU,EAAE;IACtG,OAAO,WAAW,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,UAAU,EAAE,EAAE;QAC9C,OAAO,KAAK,GAAG,UAAU,CAAC,UAAU,CAAC,UAAU,IAAI,GAAG,CAAC,CAAC;IAC1D,CAAC,EAAE,CAAC,CAAC,CAAC;AACR,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAC3C,WAAyB,EACzB,YAAoB,IAAI,EACf,EAAE;IACX,MAAM,KAAK,GAAG,wBAAwB,CAAC,WAAW,CAAC,CAAC;IACpD,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,GAAG,CAAC,IAAI,SAAS,CAAC;AAC5C,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,SAAiB,EAAU,EAAE;IAClE,IAAI,CAAC,SAAS;QAAE,OAAO,SAAS,CAAC;IACjC,OAAO,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;AAC9E,CAAC,CAAC"}
|
|
@@ -1,36 +1,8 @@
|
|
|
1
1
|
import type { MessageFieldValidation, FormValidation, PortfolioSelectionState } from '@cranberry-money/shared-types';
|
|
2
|
-
/**
|
|
3
|
-
* Portfolio selection form validation interface
|
|
4
|
-
*/
|
|
5
2
|
export interface PortfolioSelectionValidation extends FormValidation {
|
|
6
3
|
readonly selectedTemplate: MessageFieldValidation;
|
|
7
4
|
readonly isFormValid: boolean;
|
|
8
5
|
}
|
|
9
|
-
/**
|
|
10
|
-
* Validates if a portfolio template is selected
|
|
11
|
-
*
|
|
12
|
-
* @param selectedTemplateUuid - The UUID of the selected template
|
|
13
|
-
* @returns true if a template is selected, false otherwise
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* isValidTemplateSelection('123-456'); // returns true
|
|
17
|
-
* isValidTemplateSelection(null); // returns false
|
|
18
|
-
* isValidTemplateSelection(''); // returns false
|
|
19
|
-
*/
|
|
20
6
|
export declare const isValidTemplateSelection: (selectedTemplateUuid: string | null) => boolean;
|
|
21
|
-
/**
|
|
22
|
-
* Comprehensive validation for portfolio selection form
|
|
23
|
-
*
|
|
24
|
-
* @param state - The portfolio selection state
|
|
25
|
-
* @returns Validation object with field-level and form-level validity
|
|
26
|
-
*
|
|
27
|
-
* @example
|
|
28
|
-
* const state = { selectedTemplateUuid: '123-456' };
|
|
29
|
-
* validatePortfolioSelection(state);
|
|
30
|
-
* // returns {
|
|
31
|
-
* // selectedTemplate: { isValid: true, message: '' },
|
|
32
|
-
* // isFormValid: true
|
|
33
|
-
* // }
|
|
34
|
-
*/
|
|
35
7
|
export declare const validatePortfolioSelection: (state: PortfolioSelectionState) => PortfolioSelectionValidation;
|
|
36
8
|
//# 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,cAAc,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAErH
|
|
1
|
+
{"version":3,"file":"portfolio-validation.d.ts","sourceRoot":"","sources":["../src/portfolio-validation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,cAAc,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAErH,MAAM,WAAW,4BAA6B,SAAQ,cAAc;IAClE,QAAQ,CAAC,gBAAgB,EAAE,sBAAsB,CAAC;IAClD,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;CAC/B;AAED,eAAO,MAAM,wBAAwB,GAAI,sBAAsB,MAAM,GAAG,IAAI,KAAG,OAE9E,CAAC;AAEF,eAAO,MAAM,0BAA0B,GAAI,OAAO,uBAAuB,KAAG,4BAY3E,CAAC"}
|
|
@@ -1,31 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Validates if a portfolio template is selected
|
|
3
|
-
*
|
|
4
|
-
* @param selectedTemplateUuid - The UUID of the selected template
|
|
5
|
-
* @returns true if a template is selected, false otherwise
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* isValidTemplateSelection('123-456'); // returns true
|
|
9
|
-
* isValidTemplateSelection(null); // returns false
|
|
10
|
-
* isValidTemplateSelection(''); // returns false
|
|
11
|
-
*/
|
|
12
1
|
export const isValidTemplateSelection = (selectedTemplateUuid) => {
|
|
13
2
|
return Boolean(selectedTemplateUuid);
|
|
14
3
|
};
|
|
15
|
-
/**
|
|
16
|
-
* Comprehensive validation for portfolio selection form
|
|
17
|
-
*
|
|
18
|
-
* @param state - The portfolio selection state
|
|
19
|
-
* @returns Validation object with field-level and form-level validity
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
* const state = { selectedTemplateUuid: '123-456' };
|
|
23
|
-
* validatePortfolioSelection(state);
|
|
24
|
-
* // returns {
|
|
25
|
-
* // selectedTemplate: { isValid: true, message: '' },
|
|
26
|
-
* // isFormValid: true
|
|
27
|
-
* // }
|
|
28
|
-
*/
|
|
29
4
|
export const validatePortfolioSelection = (state) => {
|
|
30
5
|
const isTemplateValid = isValidTemplateSelection(state.selectedTemplateUuid);
|
|
31
6
|
const validation = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"portfolio-validation.js","sourceRoot":"","sources":["../src/portfolio-validation.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"portfolio-validation.js","sourceRoot":"","sources":["../src/portfolio-validation.ts"],"names":[],"mappings":"AAOA,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,oBAAmC,EAAW,EAAE;IACvF,OAAO,OAAO,CAAC,oBAAoB,CAAC,CAAC;AACvC,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,KAA8B,EAAgC,EAAE;IACzG,MAAM,eAAe,GAAG,wBAAwB,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC;IAE7E,MAAM,UAAU,GAAiC;QAC/C,gBAAgB,EAAE;YAChB,OAAO,EAAE,eAAe;YACxB,OAAO,EAAE,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,oCAAoC;SACrE;QACD,WAAW,EAAE,eAAe;KAC7B,CAAC;IAEF,OAAO,UAAU,CAAC;AACpB,CAAC,CAAC"}
|
package/dist/portfolio.d.ts
CHANGED
|
@@ -1,68 +1,5 @@
|
|
|
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
1
|
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
2
|
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
3
|
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
4
|
export declare function getCashAllocation(cashBalance: string | number, totalValue: string | number): number;
|
|
68
5
|
//# sourceMappingURL=portfolio.d.ts.map
|
package/dist/portfolio.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"portfolio.d.ts","sourceRoot":"","sources":["../src/portfolio.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"portfolio.d.ts","sourceRoot":"","sources":["../src/portfolio.ts"],"names":[],"mappings":"AAQA,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAMnE;AAED,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAItG;AAED,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAIrG;AAED,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAInG"}
|