@cranberry-money/shared-services 1.1.0 → 1.2.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/dist/index.d.ts CHANGED
@@ -14,6 +14,7 @@ export * from './services/AuthService';
14
14
  export * from './services/PortfolioService';
15
15
  export * as AccountsService from './services/accounts';
16
16
  export * as AuthService from './services/auth';
17
+ export * as PortfoliosService from './services/portfolios';
17
18
  export * from './query/QueryClient';
18
19
  export * from './query/useAuth';
19
20
  export * from './query/usePortfolios';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AAGrC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,yBAAyB,CAAC;AACxC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,4BAA4B,CAAC;AAG3C,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,qBAAqB,EACrB,YAAY,EACb,MAAM,iBAAiB,CAAC;AAEzB,YAAY,EACV,UAAU,EACV,gBAAgB,EAChB,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EACjB,MAAM,aAAa,CAAC;AAGrB,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,6BAA6B,CAAC;AAG5C,OAAO,KAAK,eAAe,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,WAAW,MAAM,iBAAiB,CAAC;AAG/C,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AAGtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AAGrC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,yBAAyB,CAAC;AACxC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,4BAA4B,CAAC;AAG3C,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,qBAAqB,EACrB,YAAY,EACb,MAAM,iBAAiB,CAAC;AAEzB,YAAY,EACV,UAAU,EACV,gBAAgB,EAChB,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EACjB,MAAM,aAAa,CAAC;AAGrB,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,6BAA6B,CAAC;AAG5C,OAAO,KAAK,eAAe,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,WAAW,MAAM,iBAAiB,CAAC;AAC/C,OAAO,KAAK,iBAAiB,MAAM,uBAAuB,CAAC;AAG3D,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AAGtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC"}
package/dist/index.js CHANGED
@@ -18,6 +18,7 @@ export * from './services/PortfolioService';
18
18
  // New functional domain services
19
19
  export * as AccountsService from './services/accounts';
20
20
  export * as AuthService from './services/auth';
21
+ export * as PortfoliosService from './services/portfolios';
21
22
  // React Query integration
22
23
  export * from './query/QueryClient';
23
24
  export * from './query/useAuth';
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Portfolios service exports
3
+ */
4
+ export * from './constants';
5
+ export * from './types';
6
+ export * from './service';
7
+ export * from './utils';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/portfolios/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Portfolios service exports
3
+ */
4
+ export * from './constants';
5
+ export * from './types';
6
+ export * from './service';
7
+ export * from './utils';
@@ -0,0 +1,7 @@
1
+ import type { Portfolio, PaginatedPortfolios, PortfolioPayload, RebalancingTradesGenerationResponse } from './types';
2
+ export declare const getPortfolios: () => Promise<import("axios").AxiosResponse<PaginatedPortfolios, any>>;
3
+ export declare const createPortfolio: (data: PortfolioPayload) => Promise<import("axios").AxiosResponse<Portfolio, any>>;
4
+ export declare const updatePortfolio: (uuid: string, data: Partial<PortfolioPayload>) => Promise<import("axios").AxiosResponse<Portfolio, any>>;
5
+ export declare const getPortfolioByUuid: (uuid: string) => Promise<import("axios").AxiosResponse<Portfolio, any>>;
6
+ export declare const generateRebalancingTrades: (portfolioUuid: string) => Promise<import("axios").AxiosResponse<RebalancingTradesGenerationResponse, any>>;
7
+ //# sourceMappingURL=service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../src/services/portfolios/service.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,mCAAmC,EAAE,MAAM,SAAS,CAAC;AAGrH,eAAO,MAAM,aAAa,wEAEzB,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,MAAM,gBAAgB,2DAErD,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,MAAM,MAAM,EAAE,MAAM,OAAO,CAAC,gBAAgB,CAAC,2DAE5E,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,MAAM,MAAM,2DAE9C,CAAC;AAGF,eAAO,MAAM,yBAAyB,GAAI,eAAe,MAAM,qFAI9D,CAAC"}
@@ -0,0 +1,19 @@
1
+ import { webApiClient } from '../../api/apiClient';
2
+ import { API_ENDPOINTS } from './constants';
3
+ // Portfolio CRUD operations
4
+ export const getPortfolios = () => {
5
+ return webApiClient.get(API_ENDPOINTS.PORTFOLIOS);
6
+ };
7
+ export const createPortfolio = (data) => {
8
+ return webApiClient.post(API_ENDPOINTS.PORTFOLIOS, data);
9
+ };
10
+ export const updatePortfolio = (uuid, data) => {
11
+ return webApiClient.patch(`${API_ENDPOINTS.PORTFOLIOS}${uuid}/`, data);
12
+ };
13
+ export const getPortfolioByUuid = (uuid) => {
14
+ return webApiClient.get(`${API_ENDPOINTS.PORTFOLIOS}${uuid}/`);
15
+ };
16
+ // Portfolio rebalancing operations
17
+ export const generateRebalancingTrades = (portfolioUuid) => {
18
+ return webApiClient.post(`${API_ENDPOINTS.PORTFOLIOS}${portfolioUuid}/generate-rebalancing-trades/`);
19
+ };
@@ -0,0 +1,29 @@
1
+ import type { PaginatedResponse } from '../../api/types';
2
+ export interface Portfolio {
3
+ uuid: string;
4
+ account: string;
5
+ name: string;
6
+ template: string | null;
7
+ marketValue: string;
8
+ createdAt?: string;
9
+ updatedAt?: string;
10
+ }
11
+ export type PaginatedPortfolios = PaginatedResponse<Portfolio>;
12
+ export interface PortfolioPayload {
13
+ account: string;
14
+ name: string;
15
+ template?: string | null;
16
+ }
17
+ export interface RebalancingTradesGenerationResponse {
18
+ status: string;
19
+ message: string;
20
+ tradeCount?: number;
21
+ buyTradeCount?: number;
22
+ sellTradeCount?: number;
23
+ totalTradeValue?: number;
24
+ netCashImpact?: number;
25
+ availableCash?: number;
26
+ requiredMinimum?: number;
27
+ errorType?: 'business_logic' | 'permission' | 'server';
28
+ }
29
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/services/portfolios/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEzD,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,MAAM,mBAAmB,GAAG,iBAAiB,CAAC,SAAS,CAAC,CAAC;AAE/D,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAED,MAAM,WAAW,mCAAmC;IAClD,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,EAAE,gBAAgB,GAAG,YAAY,GAAG,QAAQ,CAAC;CACxD"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ export declare const formatPortfolioValue: (value: string | number) => string;
2
+ export declare const calculateTotalValue: (marketValue: string | number, cashBalance: string | number) => number;
3
+ export declare const getMarketAllocation: (marketValue: string | number, totalValue: string | number) => number;
4
+ export declare const getCashAllocation: (cashBalance: string | number, totalValue: string | number) => number;
5
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/services/portfolios/utils.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,oBAAoB,GAAI,OAAO,MAAM,GAAG,MAAM,KAAG,MAQ7D,CAAC;AAGF,eAAO,MAAM,mBAAmB,GAAI,aAAa,MAAM,GAAG,MAAM,EAAE,aAAa,MAAM,GAAG,MAAM,KAAG,MAIhG,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAI,aAAa,MAAM,GAAG,MAAM,EAAE,YAAY,MAAM,GAAG,MAAM,KAAG,MAI/F,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,aAAa,MAAM,GAAG,MAAM,EAAE,YAAY,MAAM,GAAG,MAAM,KAAG,MAI7F,CAAC"}
@@ -0,0 +1,26 @@
1
+ // Portfolio formatting utilities
2
+ export const formatPortfolioValue = (value) => {
3
+ const numValue = typeof value === 'string' ? parseFloat(value) : value;
4
+ return new Intl.NumberFormat('en-AU', {
5
+ style: 'currency',
6
+ currency: 'AUD',
7
+ minimumFractionDigits: 2,
8
+ maximumFractionDigits: 2,
9
+ }).format(numValue);
10
+ };
11
+ // Portfolio calculation utilities
12
+ export const calculateTotalValue = (marketValue, cashBalance) => {
13
+ const market = typeof marketValue === 'string' ? parseFloat(marketValue || '0') : marketValue;
14
+ const cash = typeof cashBalance === 'string' ? parseFloat(cashBalance || '0') : cashBalance;
15
+ return market + cash;
16
+ };
17
+ export const getMarketAllocation = (marketValue, totalValue) => {
18
+ const market = typeof marketValue === 'string' ? parseFloat(marketValue || '0') : marketValue;
19
+ const total = typeof totalValue === 'string' ? parseFloat(totalValue || '0') : totalValue;
20
+ return total > 0 ? (market / total) * 100 : 0;
21
+ };
22
+ export const getCashAllocation = (cashBalance, totalValue) => {
23
+ const cash = typeof cashBalance === 'string' ? parseFloat(cashBalance || '0') : cashBalance;
24
+ const total = typeof totalValue === 'string' ? parseFloat(totalValue || '0') : totalValue;
25
+ return total > 0 ? (cash / total) * 100 : 0;
26
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cranberry-money/shared-services",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "Shared API services and client for MyPortfolio platform",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",