@cranberry-money/shared-services 1.12.1 → 3.0.0
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/CHANGELOG.md +240 -0
- package/README.md +464 -190
- package/dist/api/functional-client.d.ts +66 -0
- package/dist/api/functional-client.d.ts.map +1 -0
- package/dist/api/functional-client.js +165 -0
- package/dist/auth/functional/auth-operations.d.ts +116 -0
- package/dist/auth/functional/auth-operations.d.ts.map +1 -0
- package/dist/auth/functional/auth-operations.js +246 -0
- package/dist/auth/functional/auth-state.d.ts +38 -0
- package/dist/auth/functional/auth-state.d.ts.map +1 -0
- package/dist/auth/functional/auth-state.js +87 -0
- package/dist/auth/functional/token-storage.d.ts +44 -0
- package/dist/auth/functional/token-storage.d.ts.map +1 -0
- package/dist/auth/functional/token-storage.js +178 -0
- package/dist/auth/react/AuthProvider.d.ts +92 -0
- package/dist/auth/react/AuthProvider.d.ts.map +1 -0
- package/dist/auth/react/AuthProvider.js +207 -0
- package/dist/index.d.ts +25 -34
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +114 -40
- package/dist/integration/blueberry-integration.d.ts +21 -0
- package/dist/integration/blueberry-integration.d.ts.map +1 -0
- package/dist/integration/blueberry-integration.js +109 -0
- package/dist/integration/index.d.ts +8 -0
- package/dist/integration/index.d.ts.map +1 -0
- package/dist/integration/index.js +18 -0
- package/dist/services/accounts.d.ts +220 -0
- package/dist/services/accounts.d.ts.map +1 -0
- package/dist/services/accounts.js +175 -0
- package/dist/services/banks.d.ts +123 -0
- package/dist/services/banks.d.ts.map +1 -0
- package/dist/services/banks.js +151 -0
- package/dist/services/cash-accounts.d.ts +112 -0
- package/dist/services/cash-accounts.d.ts.map +1 -0
- package/dist/services/cash-accounts.js +222 -0
- package/dist/services/documents.d.ts +143 -0
- package/dist/services/documents.d.ts.map +1 -0
- package/dist/services/documents.js +253 -0
- package/dist/services/factories/account-factory.d.ts +16 -0
- package/dist/services/factories/account-factory.d.ts.map +1 -0
- package/dist/services/factories/account-factory.js +79 -0
- package/dist/services/factories/auth-factory.d.ts +23 -0
- package/dist/services/factories/auth-factory.d.ts.map +1 -0
- package/dist/services/factories/auth-factory.js +75 -0
- package/dist/services/factories/bank-factory.d.ts +16 -0
- package/dist/services/factories/bank-factory.d.ts.map +1 -0
- package/dist/services/factories/bank-factory.js +72 -0
- package/dist/services/factories/cash-account-factory.d.ts +16 -0
- package/dist/services/factories/cash-account-factory.d.ts.map +1 -0
- package/dist/services/factories/cash-account-factory.js +74 -0
- package/dist/services/factories/document-factory.d.ts +16 -0
- package/dist/services/factories/document-factory.d.ts.map +1 -0
- package/dist/services/factories/document-factory.js +85 -0
- package/dist/services/factories/index.d.ts +21 -0
- package/dist/services/factories/index.d.ts.map +1 -0
- package/dist/services/factories/index.js +40 -0
- package/dist/services/factories/instrument-factory.d.ts +16 -0
- package/dist/services/factories/instrument-factory.d.ts.map +1 -0
- package/dist/services/factories/instrument-factory.js +68 -0
- package/dist/services/factories/master-factory.d.ts +74 -0
- package/dist/services/factories/master-factory.d.ts.map +1 -0
- package/dist/services/factories/master-factory.js +183 -0
- package/dist/services/factories/portfolio-factory.d.ts +16 -0
- package/dist/services/factories/portfolio-factory.d.ts.map +1 -0
- package/dist/services/factories/portfolio-factory.js +74 -0
- package/dist/services/factories/portfolio-template-factory.d.ts +16 -0
- package/dist/services/factories/portfolio-template-factory.d.ts.map +1 -0
- package/dist/services/factories/portfolio-template-factory.js +76 -0
- package/dist/services/factories/reference-data-factory.d.ts +16 -0
- package/dist/services/factories/reference-data-factory.d.ts.map +1 -0
- package/dist/services/factories/reference-data-factory.js +86 -0
- package/dist/services/factories/tax-residency-factory.d.ts +16 -0
- package/dist/services/factories/tax-residency-factory.d.ts.map +1 -0
- package/dist/services/factories/tax-residency-factory.js +73 -0
- package/dist/services/factories/trade-factory.d.ts +16 -0
- package/dist/services/factories/trade-factory.d.ts.map +1 -0
- package/dist/services/factories/trade-factory.js +79 -0
- package/dist/services/factories/types.d.ts +250 -0
- package/dist/services/factories/types.d.ts.map +1 -0
- package/dist/services/factories/types.js +32 -0
- package/dist/services/factories/withdrawal-factory.d.ts +16 -0
- package/dist/services/factories/withdrawal-factory.d.ts.map +1 -0
- package/dist/services/factories/withdrawal-factory.js +78 -0
- package/dist/services/instruments.d.ts +138 -0
- package/dist/services/instruments.d.ts.map +1 -0
- package/dist/services/instruments.js +178 -0
- package/dist/services/portfolio-templates.d.ts +142 -0
- package/dist/services/portfolio-templates.d.ts.map +1 -0
- package/dist/services/portfolio-templates.js +201 -0
- package/dist/services/portfolios.d.ts +161 -0
- package/dist/services/portfolios.d.ts.map +1 -0
- package/dist/services/portfolios.js +144 -0
- package/dist/services/reference-data.d.ts +185 -0
- package/dist/services/reference-data.d.ts.map +1 -0
- package/dist/services/reference-data.js +245 -0
- package/dist/services/tax-residencies.d.ts +83 -0
- package/dist/services/tax-residencies.d.ts.map +1 -0
- package/dist/services/tax-residencies.js +179 -0
- package/dist/services/trades.d.ts +190 -0
- package/dist/services/trades.d.ts.map +1 -0
- package/dist/services/trades.js +207 -0
- package/dist/services/withdrawals.d.ts +236 -0
- package/dist/services/withdrawals.d.ts.map +1 -0
- package/dist/services/withdrawals.js +345 -0
- package/package.json +43 -16
- package/dist/adapters/MobileApiClient.d.ts +0 -68
- package/dist/adapters/MobileApiClient.d.ts.map +0 -1
- package/dist/adapters/MobileApiClient.js +0 -240
- package/dist/adapters/MobileTokenStorage.d.ts +0 -43
- package/dist/adapters/MobileTokenStorage.d.ts.map +0 -1
- package/dist/adapters/MobileTokenStorage.js +0 -128
- package/dist/adapters/WebApiClient.d.ts +0 -28
- package/dist/adapters/WebApiClient.d.ts.map +0 -1
- package/dist/adapters/WebApiClient.js +0 -119
- package/dist/adapters/WebTokenStorage.d.ts +0 -38
- package/dist/adapters/WebTokenStorage.d.ts.map +0 -1
- package/dist/adapters/WebTokenStorage.js +0 -86
- package/dist/api/apiClient.d.ts +0 -31
- package/dist/api/apiClient.d.ts.map +0 -1
- package/dist/api/apiClient.js +0 -49
- package/dist/api/types.d.ts +0 -51
- package/dist/api/types.d.ts.map +0 -1
- package/dist/api/types.js +0 -4
- package/dist/auth/AuthManager.d.ts +0 -81
- package/dist/auth/AuthManager.d.ts.map +0 -1
- package/dist/auth/AuthManager.js +0 -223
- package/dist/auth/createAuthManager.d.ts +0 -63
- package/dist/auth/createAuthManager.d.ts.map +0 -1
- package/dist/auth/createAuthManager.js +0 -103
- package/dist/auth/useAuthManager.d.ts +0 -66
- package/dist/auth/useAuthManager.d.ts.map +0 -1
- package/dist/auth/useAuthManager.js +0 -133
- package/dist/core/BaseApiClient.d.ts +0 -82
- package/dist/core/BaseApiClient.d.ts.map +0 -1
- package/dist/core/BaseApiClient.js +0 -89
- package/dist/core/TokenStorage.d.ts +0 -45
- package/dist/core/TokenStorage.d.ts.map +0 -1
- package/dist/core/TokenStorage.js +0 -23
- package/dist/query/QueryClient.d.ts +0 -82
- package/dist/query/QueryClient.d.ts.map +0 -1
- package/dist/query/QueryClient.js +0 -136
- package/dist/query/useAuth.d.ts +0 -64
- package/dist/query/useAuth.d.ts.map +0 -1
- package/dist/query/useAuth.js +0 -144
- package/dist/query/usePortfolios.d.ts +0 -79
- package/dist/query/usePortfolios.d.ts.map +0 -1
- package/dist/query/usePortfolios.js +0 -172
- package/dist/services/AuthService.d.ts +0 -75
- package/dist/services/AuthService.d.ts.map +0 -1
- package/dist/services/AuthService.js +0 -83
- package/dist/services/BaseService.d.ts +0 -48
- package/dist/services/BaseService.d.ts.map +0 -1
- package/dist/services/BaseService.js +0 -51
- package/dist/services/PortfolioService.d.ts +0 -100
- package/dist/services/PortfolioService.d.ts.map +0 -1
- package/dist/services/PortfolioService.js +0 -68
- package/dist/services/accounts/constants.d.ts +0 -24
- package/dist/services/accounts/constants.d.ts.map +0 -1
- package/dist/services/accounts/constants.js +0 -30
- package/dist/services/accounts/index.d.ts +0 -7
- package/dist/services/accounts/index.d.ts.map +0 -1
- package/dist/services/accounts/index.js +0 -6
- package/dist/services/accounts/service.d.ts +0 -11
- package/dist/services/accounts/service.d.ts.map +0 -1
- package/dist/services/accounts/service.js +0 -19
- package/dist/services/accounts/types.d.ts +0 -15
- package/dist/services/accounts/types.d.ts.map +0 -1
- package/dist/services/accounts/types.js +0 -4
- package/dist/services/auth/constants.d.ts +0 -30
- package/dist/services/auth/constants.d.ts.map +0 -1
- package/dist/services/auth/constants.js +0 -37
- package/dist/services/auth/index.d.ts +0 -8
- package/dist/services/auth/index.d.ts.map +0 -1
- package/dist/services/auth/index.js +0 -7
- package/dist/services/auth/service.d.ts +0 -8
- package/dist/services/auth/service.d.ts.map +0 -1
- package/dist/services/auth/service.js +0 -23
- package/dist/services/auth/types.d.ts +0 -38
- package/dist/services/auth/types.d.ts.map +0 -1
- package/dist/services/auth/types.js +0 -1
- package/dist/services/auth/utils.d.ts +0 -46
- package/dist/services/auth/utils.d.ts.map +0 -1
- package/dist/services/auth/utils.js +0 -113
- package/dist/services/banks/constants.d.ts +0 -47
- package/dist/services/banks/constants.d.ts.map +0 -1
- package/dist/services/banks/constants.js +0 -98
- package/dist/services/banks/index.d.ts +0 -8
- package/dist/services/banks/index.d.ts.map +0 -1
- package/dist/services/banks/index.js +0 -7
- package/dist/services/banks/service.d.ts +0 -9
- package/dist/services/banks/service.d.ts.map +0 -1
- package/dist/services/banks/service.js +0 -38
- package/dist/services/banks/types.d.ts +0 -36
- package/dist/services/banks/types.d.ts.map +0 -1
- package/dist/services/banks/types.js +0 -4
- package/dist/services/cash_accounts/constants.d.ts +0 -7
- package/dist/services/cash_accounts/constants.d.ts.map +0 -1
- package/dist/services/cash_accounts/constants.js +0 -7
- package/dist/services/cash_accounts/index.d.ts +0 -5
- package/dist/services/cash_accounts/index.d.ts.map +0 -1
- package/dist/services/cash_accounts/index.js +0 -6
- package/dist/services/cash_accounts/service.d.ts +0 -8
- package/dist/services/cash_accounts/service.d.ts.map +0 -1
- package/dist/services/cash_accounts/service.js +0 -32
- package/dist/services/cash_accounts/transactions/constants.d.ts +0 -18
- package/dist/services/cash_accounts/transactions/constants.d.ts.map +0 -1
- package/dist/services/cash_accounts/transactions/constants.js +0 -25
- package/dist/services/cash_accounts/transactions/index.d.ts +0 -5
- package/dist/services/cash_accounts/transactions/index.d.ts.map +0 -1
- package/dist/services/cash_accounts/transactions/index.js +0 -6
- package/dist/services/cash_accounts/transactions/service.d.ts +0 -13
- package/dist/services/cash_accounts/transactions/service.d.ts.map +0 -1
- package/dist/services/cash_accounts/transactions/service.js +0 -75
- package/dist/services/cash_accounts/transactions/types.d.ts +0 -38
- package/dist/services/cash_accounts/transactions/types.d.ts.map +0 -1
- package/dist/services/cash_accounts/transactions/types.js +0 -11
- package/dist/services/cash_accounts/types.d.ts +0 -24
- package/dist/services/cash_accounts/types.d.ts.map +0 -1
- package/dist/services/cash_accounts/types.js +0 -4
- package/dist/services/countries/constants.d.ts +0 -9
- package/dist/services/countries/constants.d.ts.map +0 -1
- package/dist/services/countries/constants.js +0 -10
- package/dist/services/countries/index.d.ts +0 -5
- package/dist/services/countries/index.d.ts.map +0 -1
- package/dist/services/countries/index.js +0 -6
- package/dist/services/countries/service.d.ts +0 -18
- package/dist/services/countries/service.d.ts.map +0 -1
- package/dist/services/countries/service.js +0 -32
- package/dist/services/countries/types.d.ts +0 -24
- package/dist/services/countries/types.d.ts.map +0 -1
- package/dist/services/countries/types.js +0 -1
- package/dist/services/countries/utils.d.ts +0 -38
- package/dist/services/countries/utils.d.ts.map +0 -1
- package/dist/services/countries/utils.js +0 -62
- package/dist/services/documents/constants.d.ts +0 -55
- package/dist/services/documents/constants.d.ts.map +0 -1
- package/dist/services/documents/constants.js +0 -50
- package/dist/services/documents/index.d.ts +0 -6
- package/dist/services/documents/index.d.ts.map +0 -1
- package/dist/services/documents/index.js +0 -6
- package/dist/services/documents/service.d.ts +0 -50
- package/dist/services/documents/service.d.ts.map +0 -1
- package/dist/services/documents/service.js +0 -116
- package/dist/services/documents/types.d.ts +0 -47
- package/dist/services/documents/types.d.ts.map +0 -1
- package/dist/services/documents/types.js +0 -1
- package/dist/services/documents/utils.d.ts +0 -26
- package/dist/services/documents/utils.d.ts.map +0 -1
- package/dist/services/documents/utils.js +0 -37
- package/dist/services/industries/constants.d.ts +0 -8
- package/dist/services/industries/constants.d.ts.map +0 -1
- package/dist/services/industries/constants.js +0 -9
- package/dist/services/industries/index.d.ts +0 -6
- package/dist/services/industries/index.d.ts.map +0 -1
- package/dist/services/industries/index.js +0 -6
- package/dist/services/industries/service.d.ts +0 -18
- package/dist/services/industries/service.d.ts.map +0 -1
- package/dist/services/industries/service.js +0 -43
- package/dist/services/industries/types.d.ts +0 -21
- package/dist/services/industries/types.d.ts.map +0 -1
- package/dist/services/industries/types.js +0 -1
- package/dist/services/industries/utils.d.ts +0 -47
- package/dist/services/industries/utils.d.ts.map +0 -1
- package/dist/services/industries/utils.js +0 -86
- package/dist/services/instruments/constants.d.ts +0 -38
- package/dist/services/instruments/constants.d.ts.map +0 -1
- package/dist/services/instruments/constants.js +0 -36
- package/dist/services/instruments/index.d.ts +0 -5
- package/dist/services/instruments/index.d.ts.map +0 -1
- package/dist/services/instruments/index.js +0 -6
- package/dist/services/instruments/service.d.ts +0 -54
- package/dist/services/instruments/service.d.ts.map +0 -1
- package/dist/services/instruments/service.js +0 -106
- package/dist/services/instruments/types.d.ts +0 -83
- package/dist/services/instruments/types.d.ts.map +0 -1
- package/dist/services/instruments/types.js +0 -1
- package/dist/services/instruments/utils.d.ts +0 -50
- package/dist/services/instruments/utils.d.ts.map +0 -1
- package/dist/services/instruments/utils.js +0 -111
- package/dist/services/portfolio_templates/constants.d.ts +0 -8
- package/dist/services/portfolio_templates/constants.d.ts.map +0 -1
- package/dist/services/portfolio_templates/constants.js +0 -8
- package/dist/services/portfolio_templates/index.d.ts +0 -5
- package/dist/services/portfolio_templates/index.d.ts.map +0 -1
- package/dist/services/portfolio_templates/index.js +0 -5
- package/dist/services/portfolio_templates/service.d.ts +0 -6
- package/dist/services/portfolio_templates/service.d.ts.map +0 -1
- package/dist/services/portfolio_templates/service.js +0 -14
- package/dist/services/portfolio_templates/types.d.ts +0 -49
- package/dist/services/portfolio_templates/types.d.ts.map +0 -1
- package/dist/services/portfolio_templates/types.js +0 -1
- package/dist/services/portfolio_templates/utils.d.ts +0 -8
- package/dist/services/portfolio_templates/utils.d.ts.map +0 -1
- package/dist/services/portfolio_templates/utils.js +0 -13
- package/dist/services/portfolios/allocations/index.d.ts +0 -7
- package/dist/services/portfolios/allocations/index.d.ts.map +0 -1
- package/dist/services/portfolios/allocations/index.js +0 -6
- package/dist/services/portfolios/allocations/service.d.ts +0 -6
- package/dist/services/portfolios/allocations/service.d.ts.map +0 -1
- package/dist/services/portfolios/allocations/service.js +0 -19
- package/dist/services/portfolios/allocations/types.d.ts +0 -17
- package/dist/services/portfolios/allocations/types.d.ts.map +0 -1
- package/dist/services/portfolios/allocations/types.js +0 -4
- package/dist/services/portfolios/allocations/utils.d.ts +0 -3
- package/dist/services/portfolios/allocations/utils.d.ts.map +0 -1
- package/dist/services/portfolios/allocations/utils.js +0 -7
- package/dist/services/portfolios/constants.d.ts +0 -45
- package/dist/services/portfolios/constants.d.ts.map +0 -1
- package/dist/services/portfolios/constants.js +0 -57
- package/dist/services/portfolios/holdings/index.d.ts +0 -7
- package/dist/services/portfolios/holdings/index.d.ts.map +0 -1
- package/dist/services/portfolios/holdings/index.js +0 -6
- package/dist/services/portfolios/holdings/service.d.ts +0 -10
- package/dist/services/portfolios/holdings/service.d.ts.map +0 -1
- package/dist/services/portfolios/holdings/service.js +0 -53
- package/dist/services/portfolios/holdings/types.d.ts +0 -42
- package/dist/services/portfolios/holdings/types.d.ts.map +0 -1
- package/dist/services/portfolios/holdings/types.js +0 -4
- package/dist/services/portfolios/holdings/utils.d.ts +0 -8
- package/dist/services/portfolios/holdings/utils.d.ts.map +0 -1
- package/dist/services/portfolios/holdings/utils.js +0 -82
- package/dist/services/portfolios/index.d.ts +0 -10
- package/dist/services/portfolios/index.d.ts.map +0 -1
- package/dist/services/portfolios/index.js +0 -10
- package/dist/services/portfolios/service.d.ts +0 -7
- package/dist/services/portfolios/service.d.ts.map +0 -1
- package/dist/services/portfolios/service.js +0 -19
- package/dist/services/portfolios/types.d.ts +0 -29
- package/dist/services/portfolios/types.d.ts.map +0 -1
- package/dist/services/portfolios/types.js +0 -1
- package/dist/services/portfolios/utils.d.ts +0 -5
- package/dist/services/portfolios/utils.d.ts.map +0 -1
- package/dist/services/portfolios/utils.js +0 -26
- package/dist/services/sectors/constants.d.ts +0 -7
- package/dist/services/sectors/constants.d.ts.map +0 -1
- package/dist/services/sectors/constants.js +0 -7
- package/dist/services/sectors/index.d.ts +0 -6
- package/dist/services/sectors/index.d.ts.map +0 -1
- package/dist/services/sectors/index.js +0 -6
- package/dist/services/sectors/service.d.ts +0 -14
- package/dist/services/sectors/service.d.ts.map +0 -1
- package/dist/services/sectors/service.js +0 -32
- package/dist/services/sectors/types.d.ts +0 -19
- package/dist/services/sectors/types.d.ts.map +0 -1
- package/dist/services/sectors/types.js +0 -1
- package/dist/services/sectors/utils.d.ts +0 -31
- package/dist/services/sectors/utils.d.ts.map +0 -1
- package/dist/services/sectors/utils.js +0 -54
- package/dist/services/stock_exchanges/constants.d.ts +0 -7
- package/dist/services/stock_exchanges/constants.d.ts.map +0 -1
- package/dist/services/stock_exchanges/constants.js +0 -7
- package/dist/services/stock_exchanges/index.d.ts +0 -6
- package/dist/services/stock_exchanges/index.d.ts.map +0 -1
- package/dist/services/stock_exchanges/index.js +0 -6
- package/dist/services/stock_exchanges/service.d.ts +0 -4
- package/dist/services/stock_exchanges/service.d.ts.map +0 -1
- package/dist/services/stock_exchanges/service.js +0 -26
- package/dist/services/stock_exchanges/types.d.ts +0 -28
- package/dist/services/stock_exchanges/types.d.ts.map +0 -1
- package/dist/services/stock_exchanges/types.js +0 -1
- package/dist/services/stock_exchanges/utils.d.ts +0 -8
- package/dist/services/stock_exchanges/utils.d.ts.map +0 -1
- package/dist/services/stock_exchanges/utils.js +0 -37
- package/dist/services/tax_residencies/constants.d.ts +0 -7
- package/dist/services/tax_residencies/constants.d.ts.map +0 -1
- package/dist/services/tax_residencies/constants.js +0 -7
- package/dist/services/tax_residencies/index.d.ts +0 -10
- package/dist/services/tax_residencies/index.d.ts.map +0 -1
- package/dist/services/tax_residencies/index.js +0 -11
- package/dist/services/tax_residencies/service.d.ts +0 -6
- package/dist/services/tax_residencies/service.d.ts.map +0 -1
- package/dist/services/tax_residencies/service.js +0 -20
- package/dist/services/tax_residencies/types.d.ts +0 -26
- package/dist/services/tax_residencies/types.d.ts.map +0 -1
- package/dist/services/tax_residencies/types.js +0 -4
- package/dist/services/tax_residencies/utils.d.ts +0 -9
- package/dist/services/tax_residencies/utils.d.ts.map +0 -1
- package/dist/services/tax_residencies/utils.js +0 -19
- package/dist/services/trades/constants.d.ts +0 -47
- package/dist/services/trades/constants.d.ts.map +0 -1
- package/dist/services/trades/constants.js +0 -61
- package/dist/services/trades/index.d.ts +0 -4
- package/dist/services/trades/index.d.ts.map +0 -1
- package/dist/services/trades/index.js +0 -12
- package/dist/services/trades/service.d.ts +0 -19
- package/dist/services/trades/service.d.ts.map +0 -1
- package/dist/services/trades/service.js +0 -177
- package/dist/services/trades/types.d.ts +0 -114
- package/dist/services/trades/types.d.ts.map +0 -1
- package/dist/services/trades/types.js +0 -1
- package/dist/services/users/constants.d.ts +0 -7
- package/dist/services/users/constants.d.ts.map +0 -1
- package/dist/services/users/constants.js +0 -8
- package/dist/services/users/index.d.ts +0 -9
- package/dist/services/users/index.d.ts.map +0 -1
- package/dist/services/users/index.js +0 -9
- package/dist/services/users/investment_preferences/constants.d.ts +0 -7
- package/dist/services/users/investment_preferences/constants.d.ts.map +0 -1
- package/dist/services/users/investment_preferences/constants.js +0 -7
- package/dist/services/users/investment_preferences/index.d.ts +0 -7
- package/dist/services/users/investment_preferences/index.d.ts.map +0 -1
- package/dist/services/users/investment_preferences/index.js +0 -6
- package/dist/services/users/investment_preferences/service.d.ts +0 -5
- package/dist/services/users/investment_preferences/service.d.ts.map +0 -1
- package/dist/services/users/investment_preferences/service.js +0 -12
- package/dist/services/users/investment_preferences/types.d.ts +0 -23
- package/dist/services/users/investment_preferences/types.d.ts.map +0 -1
- package/dist/services/users/investment_preferences/types.js +0 -1
- package/dist/services/users/service.d.ts +0 -6
- package/dist/services/users/service.d.ts.map +0 -1
- package/dist/services/users/service.js +0 -15
- package/dist/services/users/types.d.ts +0 -32
- package/dist/services/users/types.d.ts.map +0 -1
- package/dist/services/users/types.js +0 -1
- package/dist/services/users/utils.d.ts +0 -2
- package/dist/services/users/utils.d.ts.map +0 -1
- package/dist/services/users/utils.js +0 -6
- package/dist/services/withdrawals/constants.d.ts +0 -67
- package/dist/services/withdrawals/constants.d.ts.map +0 -1
- package/dist/services/withdrawals/constants.js +0 -91
- package/dist/services/withdrawals/index.d.ts +0 -6
- package/dist/services/withdrawals/index.d.ts.map +0 -1
- package/dist/services/withdrawals/index.js +0 -7
- package/dist/services/withdrawals/service.d.ts +0 -4
- package/dist/services/withdrawals/service.d.ts.map +0 -1
- package/dist/services/withdrawals/service.js +0 -5
- package/dist/services/withdrawals/types.d.ts +0 -81
- package/dist/services/withdrawals/types.d.ts.map +0 -1
- package/dist/services/withdrawals/types.js +0 -1
- package/dist/services/withdrawals/utils.d.ts +0 -20
- package/dist/services/withdrawals/utils.d.ts.map +0 -1
- package/dist/services/withdrawals/utils.js +0 -110
- package/dist/services/withdrawals/withdrawal_liquidations/index.d.ts +0 -3
- package/dist/services/withdrawals/withdrawal_liquidations/index.d.ts.map +0 -1
- package/dist/services/withdrawals/withdrawal_liquidations/index.js +0 -2
- package/dist/services/withdrawals/withdrawal_liquidations/service.d.ts +0 -8
- package/dist/services/withdrawals/withdrawal_liquidations/service.d.ts.map +0 -1
- package/dist/services/withdrawals/withdrawal_liquidations/service.js +0 -68
- package/dist/services/withdrawals/withdrawal_liquidations/types.d.ts +0 -2
- package/dist/services/withdrawals/withdrawal_liquidations/types.d.ts.map +0 -1
- package/dist/services/withdrawals/withdrawal_liquidations/types.js +0 -1
- package/dist/services/withdrawals/withdrawal_requests/index.d.ts +0 -3
- package/dist/services/withdrawals/withdrawal_requests/index.d.ts.map +0 -1
- package/dist/services/withdrawals/withdrawal_requests/index.js +0 -2
- package/dist/services/withdrawals/withdrawal_requests/service.d.ts +0 -7
- package/dist/services/withdrawals/withdrawal_requests/service.d.ts.map +0 -1
- package/dist/services/withdrawals/withdrawal_requests/service.js +0 -55
- package/dist/services/withdrawals/withdrawal_requests/types.d.ts +0 -2
- package/dist/services/withdrawals/withdrawal_requests/types.d.ts.map +0 -1
- package/dist/services/withdrawals/withdrawal_requests/types.js +0 -1
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Withdrawal Services - Pure Functional Implementation
|
|
4
|
+
*
|
|
5
|
+
* Complete withdrawal request and liquidation workflow system.
|
|
6
|
+
* Pure functions with explicit dependencies for withdrawal management.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.canProcessWithdrawal = exports.canCreateLiquidations = exports.isWithdrawalCancellable = exports.isWithdrawalEditable = exports.formatSharesQuantity = exports.getTotalEstimatedValue = exports.calculateLiquidationProgress = exports.getLiquidationStatusColor = exports.getWithdrawalStatusColor = exports.formatWithdrawalAmount = exports.LIQUIDATION_STATUS_LABELS = exports.LIQUIDATION_STATUS = exports.WITHDRAWAL_REASON_LABELS = exports.WITHDRAWAL_REASON = exports.WITHDRAWAL_TYPE_LABELS = exports.WITHDRAWAL_TYPE = exports.WITHDRAWAL_STATUS_LABELS = exports.WITHDRAWAL_STATUS = exports.executeLiquidationTrades = exports.createTradesForLiquidation = exports.getLiquidationsByWithdrawalRequest = exports.deleteWithdrawalLiquidation = exports.updateWithdrawalLiquidation = exports.createWithdrawalLiquidation = exports.getWithdrawalLiquidation = exports.getWithdrawalLiquidations = exports.processWithdrawalRequest = exports.cancelWithdrawalRequest = exports.rejectWithdrawalRequest = exports.approveWithdrawalRequest = exports.deleteWithdrawalRequest = exports.updateWithdrawalRequest = exports.createWithdrawalRequest = exports.getWithdrawalRequest = exports.getWithdrawalRequests = void 0;
|
|
10
|
+
// =============================
|
|
11
|
+
// WITHDRAWAL REQUEST OPERATIONS
|
|
12
|
+
// =============================
|
|
13
|
+
const getWithdrawalRequests = async ({ apiClient }, filters) => {
|
|
14
|
+
const params = {};
|
|
15
|
+
if (filters?.account)
|
|
16
|
+
params.account = filters.account;
|
|
17
|
+
if (filters?.status)
|
|
18
|
+
params.status = filters.status;
|
|
19
|
+
if (filters?.withdrawalType)
|
|
20
|
+
params.withdrawal_type = filters.withdrawalType;
|
|
21
|
+
if (filters?.startDate)
|
|
22
|
+
params.start_date = filters.startDate;
|
|
23
|
+
if (filters?.endDate)
|
|
24
|
+
params.end_date = filters.endDate;
|
|
25
|
+
if (filters?.minAmount)
|
|
26
|
+
params.min_amount = filters.minAmount;
|
|
27
|
+
if (filters?.maxAmount)
|
|
28
|
+
params.max_amount = filters.maxAmount;
|
|
29
|
+
if (filters?.ordering)
|
|
30
|
+
params.order_by = filters.ordering;
|
|
31
|
+
if (filters?.page)
|
|
32
|
+
params.page = String(filters.page);
|
|
33
|
+
if (filters?.pageSize)
|
|
34
|
+
params.page_size = String(filters.pageSize);
|
|
35
|
+
return apiClient.get('/api/withdrawal-requests/', { params });
|
|
36
|
+
};
|
|
37
|
+
exports.getWithdrawalRequests = getWithdrawalRequests;
|
|
38
|
+
const getWithdrawalRequest = async ({ apiClient }, uuid) => {
|
|
39
|
+
if (!uuid?.trim()) {
|
|
40
|
+
throw new Error('Withdrawal request UUID is required');
|
|
41
|
+
}
|
|
42
|
+
return apiClient.get(`/api/withdrawal-requests/${uuid}/`);
|
|
43
|
+
};
|
|
44
|
+
exports.getWithdrawalRequest = getWithdrawalRequest;
|
|
45
|
+
const createWithdrawalRequest = async ({ apiClient }, data) => {
|
|
46
|
+
// Validation
|
|
47
|
+
if (!data.account?.trim()) {
|
|
48
|
+
throw new Error('Account UUID is required');
|
|
49
|
+
}
|
|
50
|
+
if (!data.requestedAmount || parseFloat(data.requestedAmount) <= 0) {
|
|
51
|
+
throw new Error('Requested amount must be greater than 0');
|
|
52
|
+
}
|
|
53
|
+
return apiClient.post('/api/withdrawal-requests/', data);
|
|
54
|
+
};
|
|
55
|
+
exports.createWithdrawalRequest = createWithdrawalRequest;
|
|
56
|
+
const updateWithdrawalRequest = async ({ apiClient }, uuid, data) => {
|
|
57
|
+
if (!uuid?.trim()) {
|
|
58
|
+
throw new Error('Withdrawal request UUID is required');
|
|
59
|
+
}
|
|
60
|
+
if (data.requestedAmount && parseFloat(data.requestedAmount) <= 0) {
|
|
61
|
+
throw new Error('Requested amount must be greater than 0');
|
|
62
|
+
}
|
|
63
|
+
return apiClient.patch(`/api/withdrawal-requests/${uuid}/`, data);
|
|
64
|
+
};
|
|
65
|
+
exports.updateWithdrawalRequest = updateWithdrawalRequest;
|
|
66
|
+
const deleteWithdrawalRequest = async ({ apiClient }, uuid) => {
|
|
67
|
+
if (!uuid?.trim()) {
|
|
68
|
+
throw new Error('Withdrawal request UUID is required');
|
|
69
|
+
}
|
|
70
|
+
await apiClient.delete(`/api/withdrawal-requests/${uuid}/`);
|
|
71
|
+
};
|
|
72
|
+
exports.deleteWithdrawalRequest = deleteWithdrawalRequest;
|
|
73
|
+
// Workflow operations
|
|
74
|
+
const approveWithdrawalRequest = async ({ apiClient }, uuid) => {
|
|
75
|
+
if (!uuid?.trim()) {
|
|
76
|
+
throw new Error('Withdrawal request UUID is required');
|
|
77
|
+
}
|
|
78
|
+
return apiClient.post(`/api/withdrawal-requests/${uuid}/approve/`, {});
|
|
79
|
+
};
|
|
80
|
+
exports.approveWithdrawalRequest = approveWithdrawalRequest;
|
|
81
|
+
const rejectWithdrawalRequest = async ({ apiClient }, uuid, reason) => {
|
|
82
|
+
if (!uuid?.trim()) {
|
|
83
|
+
throw new Error('Withdrawal request UUID is required');
|
|
84
|
+
}
|
|
85
|
+
return apiClient.post(`/api/withdrawal-requests/${uuid}/reject/`, { reason });
|
|
86
|
+
};
|
|
87
|
+
exports.rejectWithdrawalRequest = rejectWithdrawalRequest;
|
|
88
|
+
const cancelWithdrawalRequest = async ({ apiClient }, uuid) => {
|
|
89
|
+
if (!uuid?.trim()) {
|
|
90
|
+
throw new Error('Withdrawal request UUID is required');
|
|
91
|
+
}
|
|
92
|
+
return apiClient.post(`/api/withdrawal-requests/${uuid}/cancel/`, {});
|
|
93
|
+
};
|
|
94
|
+
exports.cancelWithdrawalRequest = cancelWithdrawalRequest;
|
|
95
|
+
const processWithdrawalRequest = async ({ apiClient }, uuid) => {
|
|
96
|
+
if (!uuid?.trim()) {
|
|
97
|
+
throw new Error('Withdrawal request UUID is required');
|
|
98
|
+
}
|
|
99
|
+
return apiClient.post(`/api/withdrawal-requests/${uuid}/process/`, {});
|
|
100
|
+
};
|
|
101
|
+
exports.processWithdrawalRequest = processWithdrawalRequest;
|
|
102
|
+
// =============================
|
|
103
|
+
// WITHDRAWAL LIQUIDATION OPERATIONS
|
|
104
|
+
// =============================
|
|
105
|
+
const getWithdrawalLiquidations = async ({ apiClient }, filters) => {
|
|
106
|
+
const params = {};
|
|
107
|
+
if (filters?.withdrawalRequest)
|
|
108
|
+
params.withdrawal_request = filters.withdrawalRequest;
|
|
109
|
+
if (filters?.assetHolding)
|
|
110
|
+
params.asset_holding = filters.assetHolding;
|
|
111
|
+
if (filters?.liquidationStatus)
|
|
112
|
+
params.liquidation_status = filters.liquidationStatus;
|
|
113
|
+
if (filters?.targetCompletionStartDate)
|
|
114
|
+
params.target_completion_start_date = filters.targetCompletionStartDate;
|
|
115
|
+
if (filters?.targetCompletionEndDate)
|
|
116
|
+
params.target_completion_end_date = filters.targetCompletionEndDate;
|
|
117
|
+
if (filters?.expectedSettlementStartDate)
|
|
118
|
+
params.expected_settlement_start_date = filters.expectedSettlementStartDate;
|
|
119
|
+
if (filters?.expectedSettlementEndDate)
|
|
120
|
+
params.expected_settlement_end_date = filters.expectedSettlementEndDate;
|
|
121
|
+
if (filters?.targetTrade)
|
|
122
|
+
params.target_trade = filters.targetTrade;
|
|
123
|
+
if (filters?.minValue)
|
|
124
|
+
params.min_value = filters.minValue;
|
|
125
|
+
if (filters?.maxValue)
|
|
126
|
+
params.max_value = filters.maxValue;
|
|
127
|
+
if (filters?.ordering)
|
|
128
|
+
params.order_by = filters.ordering;
|
|
129
|
+
if (filters?.page)
|
|
130
|
+
params.page = String(filters.page);
|
|
131
|
+
if (filters?.pageSize)
|
|
132
|
+
params.page_size = String(filters.pageSize);
|
|
133
|
+
return apiClient.get('/api/withdrawal-liquidations/', { params });
|
|
134
|
+
};
|
|
135
|
+
exports.getWithdrawalLiquidations = getWithdrawalLiquidations;
|
|
136
|
+
const getWithdrawalLiquidation = async ({ apiClient }, uuid) => {
|
|
137
|
+
if (!uuid?.trim()) {
|
|
138
|
+
throw new Error('Withdrawal liquidation UUID is required');
|
|
139
|
+
}
|
|
140
|
+
return apiClient.get(`/api/withdrawal-liquidations/${uuid}/`);
|
|
141
|
+
};
|
|
142
|
+
exports.getWithdrawalLiquidation = getWithdrawalLiquidation;
|
|
143
|
+
const createWithdrawalLiquidation = async ({ apiClient }, data) => {
|
|
144
|
+
// Validation
|
|
145
|
+
if (!data.withdrawalRequest?.trim()) {
|
|
146
|
+
throw new Error('Withdrawal request UUID is required');
|
|
147
|
+
}
|
|
148
|
+
if (!data.assetHolding?.trim()) {
|
|
149
|
+
throw new Error('Asset holding UUID is required');
|
|
150
|
+
}
|
|
151
|
+
if (!data.sharesToLiquidate || data.sharesToLiquidate <= 0) {
|
|
152
|
+
throw new Error('Shares to liquidate must be greater than 0');
|
|
153
|
+
}
|
|
154
|
+
if (!data.estimatedValue || parseFloat(data.estimatedValue) <= 0) {
|
|
155
|
+
throw new Error('Estimated value must be greater than 0');
|
|
156
|
+
}
|
|
157
|
+
return apiClient.post('/api/withdrawal-liquidations/', data);
|
|
158
|
+
};
|
|
159
|
+
exports.createWithdrawalLiquidation = createWithdrawalLiquidation;
|
|
160
|
+
const updateWithdrawalLiquidation = async ({ apiClient }, uuid, data) => {
|
|
161
|
+
if (!uuid?.trim()) {
|
|
162
|
+
throw new Error('Withdrawal liquidation UUID is required');
|
|
163
|
+
}
|
|
164
|
+
if (data.sharesToLiquidate !== undefined && data.sharesToLiquidate <= 0) {
|
|
165
|
+
throw new Error('Shares to liquidate must be greater than 0');
|
|
166
|
+
}
|
|
167
|
+
if (data.estimatedValue !== undefined && parseFloat(data.estimatedValue) <= 0) {
|
|
168
|
+
throw new Error('Estimated value must be greater than 0');
|
|
169
|
+
}
|
|
170
|
+
return apiClient.patch(`/api/withdrawal-liquidations/${uuid}/`, data);
|
|
171
|
+
};
|
|
172
|
+
exports.updateWithdrawalLiquidation = updateWithdrawalLiquidation;
|
|
173
|
+
const deleteWithdrawalLiquidation = async ({ apiClient }, uuid) => {
|
|
174
|
+
if (!uuid?.trim()) {
|
|
175
|
+
throw new Error('Withdrawal liquidation UUID is required');
|
|
176
|
+
}
|
|
177
|
+
await apiClient.delete(`/api/withdrawal-liquidations/${uuid}/`);
|
|
178
|
+
};
|
|
179
|
+
exports.deleteWithdrawalLiquidation = deleteWithdrawalLiquidation;
|
|
180
|
+
// Helper functions
|
|
181
|
+
const getLiquidationsByWithdrawalRequest = async ({ apiClient }, withdrawalRequestUuid) => {
|
|
182
|
+
if (!withdrawalRequestUuid?.trim()) {
|
|
183
|
+
throw new Error('Withdrawal request UUID is required');
|
|
184
|
+
}
|
|
185
|
+
return (0, exports.getWithdrawalLiquidations)({ apiClient }, {
|
|
186
|
+
withdrawalRequest: withdrawalRequestUuid,
|
|
187
|
+
ordering: '-created_at',
|
|
188
|
+
});
|
|
189
|
+
};
|
|
190
|
+
exports.getLiquidationsByWithdrawalRequest = getLiquidationsByWithdrawalRequest;
|
|
191
|
+
const createTradesForLiquidation = async ({ apiClient }, uuid) => {
|
|
192
|
+
if (!uuid?.trim()) {
|
|
193
|
+
throw new Error('Withdrawal liquidation UUID is required');
|
|
194
|
+
}
|
|
195
|
+
return apiClient.post(`/api/withdrawal-liquidations/${uuid}/create-trades/`, {});
|
|
196
|
+
};
|
|
197
|
+
exports.createTradesForLiquidation = createTradesForLiquidation;
|
|
198
|
+
const executeLiquidationTrades = async ({ apiClient }, uuid) => {
|
|
199
|
+
if (!uuid?.trim()) {
|
|
200
|
+
throw new Error('Withdrawal liquidation UUID is required');
|
|
201
|
+
}
|
|
202
|
+
return apiClient.post(`/api/withdrawal-liquidations/${uuid}/execute-trades/`, {});
|
|
203
|
+
};
|
|
204
|
+
exports.executeLiquidationTrades = executeLiquidationTrades;
|
|
205
|
+
// =============================
|
|
206
|
+
// UTILITY FUNCTIONS & CONSTANTS
|
|
207
|
+
// =============================
|
|
208
|
+
// Status constants
|
|
209
|
+
exports.WITHDRAWAL_STATUS = {
|
|
210
|
+
PENDING_REVIEW: 'PENDING_REVIEW',
|
|
211
|
+
APPROVED: 'APPROVED',
|
|
212
|
+
REJECTED: 'REJECTED',
|
|
213
|
+
PROCESSING: 'PROCESSING',
|
|
214
|
+
AWAITING_LIQUIDATION: 'AWAITING_LIQUIDATION',
|
|
215
|
+
LIQUIDATION_IN_PROGRESS: 'LIQUIDATION_IN_PROGRESS',
|
|
216
|
+
COMPLETED: 'COMPLETED',
|
|
217
|
+
CANCELLED: 'CANCELLED',
|
|
218
|
+
FAILED: 'FAILED',
|
|
219
|
+
};
|
|
220
|
+
exports.WITHDRAWAL_STATUS_LABELS = {
|
|
221
|
+
PENDING_REVIEW: 'Pending Review',
|
|
222
|
+
APPROVED: 'Approved',
|
|
223
|
+
REJECTED: 'Rejected',
|
|
224
|
+
PROCESSING: 'Processing',
|
|
225
|
+
AWAITING_LIQUIDATION: 'Awaiting Liquidation',
|
|
226
|
+
LIQUIDATION_IN_PROGRESS: 'Liquidation In Progress',
|
|
227
|
+
COMPLETED: 'Completed',
|
|
228
|
+
CANCELLED: 'Cancelled',
|
|
229
|
+
FAILED: 'Failed',
|
|
230
|
+
};
|
|
231
|
+
exports.WITHDRAWAL_TYPE = {
|
|
232
|
+
FULL_CASH: 'FULL_CASH',
|
|
233
|
+
PARTIAL_CASH: 'PARTIAL_CASH',
|
|
234
|
+
};
|
|
235
|
+
exports.WITHDRAWAL_TYPE_LABELS = {
|
|
236
|
+
FULL_CASH: 'Full Cash Withdrawal',
|
|
237
|
+
PARTIAL_CASH: 'Partial Cash Withdrawal',
|
|
238
|
+
};
|
|
239
|
+
exports.WITHDRAWAL_REASON = {
|
|
240
|
+
INVESTMENT_STRATEGY: 'INVESTMENT_STRATEGY',
|
|
241
|
+
PERSONAL_EXPENSES: 'PERSONAL_EXPENSES',
|
|
242
|
+
EMERGENCY: 'EMERGENCY',
|
|
243
|
+
OTHER: 'OTHER',
|
|
244
|
+
};
|
|
245
|
+
exports.WITHDRAWAL_REASON_LABELS = {
|
|
246
|
+
INVESTMENT_STRATEGY: 'Investment Strategy',
|
|
247
|
+
PERSONAL_EXPENSES: 'Personal Expenses',
|
|
248
|
+
EMERGENCY: 'Emergency',
|
|
249
|
+
OTHER: 'Other',
|
|
250
|
+
};
|
|
251
|
+
exports.LIQUIDATION_STATUS = {
|
|
252
|
+
PENDING: 'PENDING',
|
|
253
|
+
TRADES_CREATED: 'TRADES_CREATED',
|
|
254
|
+
EXECUTED: 'EXECUTED',
|
|
255
|
+
SETTLED: 'SETTLED',
|
|
256
|
+
FAILED: 'FAILED',
|
|
257
|
+
};
|
|
258
|
+
exports.LIQUIDATION_STATUS_LABELS = {
|
|
259
|
+
PENDING: 'Pending',
|
|
260
|
+
TRADES_CREATED: 'Trades Created',
|
|
261
|
+
EXECUTED: 'Executed',
|
|
262
|
+
SETTLED: 'Settled',
|
|
263
|
+
FAILED: 'Failed',
|
|
264
|
+
};
|
|
265
|
+
// Utility functions
|
|
266
|
+
const formatWithdrawalAmount = (amount) => {
|
|
267
|
+
const numValue = typeof amount === 'string' ? parseFloat(amount) : amount;
|
|
268
|
+
return new Intl.NumberFormat('en-AU', {
|
|
269
|
+
style: 'currency',
|
|
270
|
+
currency: 'AUD',
|
|
271
|
+
}).format(numValue);
|
|
272
|
+
};
|
|
273
|
+
exports.formatWithdrawalAmount = formatWithdrawalAmount;
|
|
274
|
+
const getWithdrawalStatusColor = (status) => {
|
|
275
|
+
const statusColors = {
|
|
276
|
+
PENDING_REVIEW: 'text-warning-600',
|
|
277
|
+
APPROVED: 'text-success-600',
|
|
278
|
+
REJECTED: 'text-error-600',
|
|
279
|
+
PROCESSING: 'text-primary-600',
|
|
280
|
+
AWAITING_LIQUIDATION: 'text-warning-600',
|
|
281
|
+
LIQUIDATION_IN_PROGRESS: 'text-primary-600',
|
|
282
|
+
COMPLETED: 'text-success-600',
|
|
283
|
+
CANCELLED: 'text-content-muted',
|
|
284
|
+
FAILED: 'text-error-600',
|
|
285
|
+
};
|
|
286
|
+
return statusColors[status] || 'text-content-muted';
|
|
287
|
+
};
|
|
288
|
+
exports.getWithdrawalStatusColor = getWithdrawalStatusColor;
|
|
289
|
+
const getLiquidationStatusColor = (status) => {
|
|
290
|
+
const statusColors = {
|
|
291
|
+
PENDING: 'text-warning-600',
|
|
292
|
+
TRADES_CREATED: 'text-primary-600',
|
|
293
|
+
EXECUTED: 'text-accent-secondary',
|
|
294
|
+
SETTLED: 'text-success-600',
|
|
295
|
+
FAILED: 'text-error-600',
|
|
296
|
+
};
|
|
297
|
+
return statusColors[status] || 'text-content-muted';
|
|
298
|
+
};
|
|
299
|
+
exports.getLiquidationStatusColor = getLiquidationStatusColor;
|
|
300
|
+
const calculateLiquidationProgress = (liquidations) => {
|
|
301
|
+
const total = liquidations.length;
|
|
302
|
+
const pending = liquidations.filter(l => l.liquidationStatus === 'PENDING').length;
|
|
303
|
+
const inProgress = liquidations.filter(l => ['TRADES_CREATED', 'EXECUTED'].includes(l.liquidationStatus)).length;
|
|
304
|
+
const completed = liquidations.filter(l => l.liquidationStatus === 'SETTLED').length;
|
|
305
|
+
const failed = liquidations.filter(l => l.liquidationStatus === 'FAILED').length;
|
|
306
|
+
const completionRate = total > 0 ? (completed / total) * 100 : 0;
|
|
307
|
+
return {
|
|
308
|
+
total,
|
|
309
|
+
pending,
|
|
310
|
+
inProgress,
|
|
311
|
+
completed,
|
|
312
|
+
failed,
|
|
313
|
+
completionRate,
|
|
314
|
+
};
|
|
315
|
+
};
|
|
316
|
+
exports.calculateLiquidationProgress = calculateLiquidationProgress;
|
|
317
|
+
const getTotalEstimatedValue = (liquidations) => {
|
|
318
|
+
return liquidations.reduce((total, liquidation) => {
|
|
319
|
+
return total + parseFloat(liquidation.estimatedValue || '0');
|
|
320
|
+
}, 0);
|
|
321
|
+
};
|
|
322
|
+
exports.getTotalEstimatedValue = getTotalEstimatedValue;
|
|
323
|
+
const formatSharesQuantity = (shares) => {
|
|
324
|
+
return new Intl.NumberFormat('en-AU', {
|
|
325
|
+
minimumFractionDigits: 0,
|
|
326
|
+
maximumFractionDigits: 4,
|
|
327
|
+
}).format(shares);
|
|
328
|
+
};
|
|
329
|
+
exports.formatSharesQuantity = formatSharesQuantity;
|
|
330
|
+
const isWithdrawalEditable = (status) => {
|
|
331
|
+
return ['PENDING_REVIEW', 'APPROVED'].includes(status);
|
|
332
|
+
};
|
|
333
|
+
exports.isWithdrawalEditable = isWithdrawalEditable;
|
|
334
|
+
const isWithdrawalCancellable = (status) => {
|
|
335
|
+
return ['PENDING_REVIEW', 'APPROVED', 'AWAITING_LIQUIDATION'].includes(status);
|
|
336
|
+
};
|
|
337
|
+
exports.isWithdrawalCancellable = isWithdrawalCancellable;
|
|
338
|
+
const canCreateLiquidations = (status) => {
|
|
339
|
+
return status === 'AWAITING_LIQUIDATION';
|
|
340
|
+
};
|
|
341
|
+
exports.canCreateLiquidations = canCreateLiquidations;
|
|
342
|
+
const canProcessWithdrawal = (status) => {
|
|
343
|
+
return status === 'APPROVED';
|
|
344
|
+
};
|
|
345
|
+
exports.canProcessWithdrawal = canProcessWithdrawal;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cranberry-money/shared-services",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
|
+
"description": "Functional architecture shared services with pure functions, dependency injection, and comprehensive TypeScript support for the MyPortfolio platform",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"exports": {
|
|
@@ -12,46 +12,73 @@
|
|
|
12
12
|
}
|
|
13
13
|
},
|
|
14
14
|
"files": [
|
|
15
|
-
"dist"
|
|
15
|
+
"dist",
|
|
16
|
+
"README.md",
|
|
17
|
+
"CHANGELOG.md",
|
|
18
|
+
"docs"
|
|
16
19
|
],
|
|
17
20
|
"scripts": {
|
|
18
21
|
"build": "tsc",
|
|
19
22
|
"clean": "rm -rf dist",
|
|
20
23
|
"typecheck": "tsc --noEmit",
|
|
21
|
-
"dev": "tsc --watch"
|
|
24
|
+
"dev": "tsc --watch",
|
|
25
|
+
"lint": "eslint src --ext .ts,.tsx",
|
|
26
|
+
"lint:fix": "eslint src --ext .ts,.tsx --fix",
|
|
27
|
+
"validate": "tsx scripts/validate-package.ts",
|
|
28
|
+
"prepare-release": "tsx scripts/prepare-release.ts",
|
|
29
|
+
"release": "npm run prepare-release && npm publish",
|
|
30
|
+
"release:dry-run": "npm run prepare-release -- --dry-run"
|
|
22
31
|
},
|
|
23
32
|
"dependencies": {
|
|
24
|
-
"@cranberry-money/shared-constants": "^1.0.1",
|
|
25
|
-
"@cranberry-money/shared-types": "^1.0.1",
|
|
26
33
|
"axios": "^1.7.0"
|
|
27
34
|
},
|
|
28
35
|
"peerDependencies": {
|
|
29
|
-
"
|
|
30
|
-
"typescript": ">=5.0
|
|
36
|
+
"react": ">=18.0.0",
|
|
37
|
+
"typescript": ">=4.5.0"
|
|
38
|
+
},
|
|
39
|
+
"peerDependenciesMeta": {
|
|
40
|
+
"react": {
|
|
41
|
+
"optional": false
|
|
42
|
+
}
|
|
31
43
|
},
|
|
32
44
|
"devDependencies": {
|
|
33
|
-
"@
|
|
34
|
-
"@types/react": "^
|
|
35
|
-
"@
|
|
45
|
+
"@types/node": "^20.0.0",
|
|
46
|
+
"@types/react": "^18.0.0",
|
|
47
|
+
"@typescript-eslint/eslint-plugin": "^6.0.0",
|
|
48
|
+
"@typescript-eslint/parser": "^6.0.0",
|
|
49
|
+
"eslint": "^8.0.0",
|
|
50
|
+
"react": "^18.0.0",
|
|
51
|
+
"tsx": "^4.0.0",
|
|
36
52
|
"typescript": "^5.0.0"
|
|
37
53
|
},
|
|
38
54
|
"keywords": [
|
|
55
|
+
"functional-programming",
|
|
56
|
+
"dependency-injection",
|
|
57
|
+
"react",
|
|
39
58
|
"typescript",
|
|
40
|
-
"api",
|
|
41
|
-
"
|
|
42
|
-
"shared",
|
|
59
|
+
"api-client",
|
|
60
|
+
"authentication",
|
|
43
61
|
"portfolio",
|
|
44
|
-
"
|
|
62
|
+
"services",
|
|
63
|
+
"pure-functions"
|
|
45
64
|
],
|
|
46
65
|
"author": "MyPortfolio Team",
|
|
47
66
|
"license": "MIT",
|
|
48
67
|
"publishConfig": {
|
|
49
|
-
"access": "
|
|
68
|
+
"access": "public",
|
|
50
69
|
"registry": "https://registry.npmjs.org/"
|
|
51
70
|
},
|
|
52
71
|
"repository": {
|
|
53
72
|
"type": "git",
|
|
54
73
|
"url": "git+https://github.com/your-org/cranberry.git",
|
|
55
74
|
"directory": "packages/shared-services"
|
|
75
|
+
},
|
|
76
|
+
"bugs": {
|
|
77
|
+
"url": "https://github.com/your-org/cranberry/issues"
|
|
78
|
+
},
|
|
79
|
+
"homepage": "https://github.com/your-org/cranberry/tree/main/packages/shared-services#readme",
|
|
80
|
+
"engines": {
|
|
81
|
+
"node": ">=16.0.0",
|
|
82
|
+
"npm": ">=8.0.0"
|
|
56
83
|
}
|
|
57
84
|
}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Mobile-specific API client implementation
|
|
3
|
-
*
|
|
4
|
-
* This implementation is designed for React Native environments
|
|
5
|
-
* and includes mobile-specific features like network state awareness,
|
|
6
|
-
* offline capability, and retry logic.
|
|
7
|
-
*/
|
|
8
|
-
import { BaseApiClient, type RequestConfig, type ApiResponse, type ApiClientConfig } from '../core/BaseApiClient';
|
|
9
|
-
export interface MobileApiClientConfig extends ApiClientConfig {
|
|
10
|
-
retryAttempts?: number;
|
|
11
|
-
retryDelay?: number;
|
|
12
|
-
offlineQueueEnabled?: boolean;
|
|
13
|
-
}
|
|
14
|
-
export declare class MobileApiClient extends BaseApiClient {
|
|
15
|
-
private retryAttempts;
|
|
16
|
-
private retryDelay;
|
|
17
|
-
private offlineQueueEnabled;
|
|
18
|
-
private offlineQueue;
|
|
19
|
-
private isOnline;
|
|
20
|
-
constructor(config: MobileApiClientConfig);
|
|
21
|
-
request<T = unknown>(config: RequestConfig): Promise<ApiResponse<T>>;
|
|
22
|
-
private executeRequest;
|
|
23
|
-
/**
|
|
24
|
-
* Queue request for when back online
|
|
25
|
-
*/
|
|
26
|
-
private queueRequest;
|
|
27
|
-
/**
|
|
28
|
-
* Process offline queue when back online
|
|
29
|
-
*/
|
|
30
|
-
syncWhenOnline(): Promise<void>;
|
|
31
|
-
/**
|
|
32
|
-
* Enable offline mode
|
|
33
|
-
*/
|
|
34
|
-
enableOfflineMode(): void;
|
|
35
|
-
/**
|
|
36
|
-
* Enable online mode and sync queue
|
|
37
|
-
*/
|
|
38
|
-
enableOnlineMode(): Promise<void>;
|
|
39
|
-
/**
|
|
40
|
-
* Set network state
|
|
41
|
-
*/
|
|
42
|
-
setNetworkState(isOnline: boolean): void;
|
|
43
|
-
/**
|
|
44
|
-
* Parse response data based on content type
|
|
45
|
-
*/
|
|
46
|
-
private parseResponseData;
|
|
47
|
-
/**
|
|
48
|
-
* Convert Headers to plain object
|
|
49
|
-
*/
|
|
50
|
-
private parseResponseHeaders;
|
|
51
|
-
/**
|
|
52
|
-
* Check if error is an API error
|
|
53
|
-
*/
|
|
54
|
-
private isApiError;
|
|
55
|
-
/**
|
|
56
|
-
* Determine if request should be retried
|
|
57
|
-
*/
|
|
58
|
-
private shouldRetry;
|
|
59
|
-
/**
|
|
60
|
-
* Handle token refresh for mobile (secure storage based)
|
|
61
|
-
*/
|
|
62
|
-
protected handleTokenRefresh(): Promise<boolean>;
|
|
63
|
-
/**
|
|
64
|
-
* Utility delay function
|
|
65
|
-
*/
|
|
66
|
-
private delay;
|
|
67
|
-
}
|
|
68
|
-
//# sourceMappingURL=MobileApiClient.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MobileApiClient.d.ts","sourceRoot":"","sources":["../../src/adapters/MobileApiClient.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,aAAa,EAAE,KAAK,aAAa,EAAE,KAAK,WAAW,EAAE,KAAK,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAElH,MAAM,WAAW,qBAAsB,SAAQ,eAAe;IAC5D,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B;AAED,qBAAa,eAAgB,SAAQ,aAAa;IAChD,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,mBAAmB,CAAU;IACrC,OAAO,CAAC,YAAY,CAAuB;IAC3C,OAAO,CAAC,QAAQ,CAAiB;gBAErB,MAAM,EAAE,qBAAqB;IAcnC,OAAO,CAAC,CAAC,GAAG,OAAO,EAAE,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;YAS5D,cAAc;IAwF5B;;OAEG;YACW,YAAY;IAU1B;;OAEG;IACG,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC;IAgBrC;;OAEG;IACH,iBAAiB,IAAI,IAAI;IAIzB;;OAEG;IACG,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC;IAOvC;;OAEG;IACH,eAAe,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI;IAUxC;;OAEG;YACW,iBAAiB;IAe/B;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAQ5B;;OAEG;IACH,OAAO,CAAC,UAAU;IAOlB;;OAEG;IACH,OAAO,CAAC,WAAW;IAsBnB;;OAEG;cACa,kBAAkB,IAAI,OAAO,CAAC,OAAO,CAAC;IAyBtD;;OAEG;IACH,OAAO,CAAC,KAAK;CAGd"}
|