@cranberry-money/shared-services 1.9.0 → 1.10.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
@@ -18,6 +18,7 @@ export * as CashAccountsService from './services/cash_accounts';
18
18
  export * as InstrumentsService from './services/instruments';
19
19
  export * as PortfoliosService from './services/portfolios';
20
20
  export * as PortfolioTemplatesService from './services/portfolio_templates';
21
+ export * as TaxResidenciesService from './services/tax_residencies';
21
22
  export * as UsersService from './services/users';
22
23
  export * as TradesService from './services/trades';
23
24
  export * as WithdrawalsService from './services/withdrawals';
@@ -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;AAC/C,OAAO,KAAK,mBAAmB,MAAM,0BAA0B,CAAC;AAChE,OAAO,KAAK,kBAAkB,MAAM,wBAAwB,CAAC;AAC7D,OAAO,KAAK,iBAAiB,MAAM,uBAAuB,CAAC;AAC3D,OAAO,KAAK,yBAAyB,MAAM,gCAAgC,CAAC;AAC5E,OAAO,KAAK,YAAY,MAAM,kB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AAwB,CAAC;AAG7D,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
@@ -22,6 +22,7 @@ export * as CashAccountsService from './services/cash_accounts';
22
22
  export * as InstrumentsService from './services/instruments';
23
23
  export * as PortfoliosService from './services/portfolios';
24
24
  export * as PortfolioTemplatesService from './services/portfolio_templates';
25
+ export * as TaxResidenciesService from './services/tax_residencies';
25
26
  export * as UsersService from './services/users';
26
27
  export * as TradesService from './services/trades';
27
28
  export * as WithdrawalsService from './services/withdrawals';
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Tax Residency API constants
3
+ */
4
+ export declare const API_ENDPOINTS: {
5
+ readonly TAX_RESIDENCIES: "/api/tax-residencies/";
6
+ };
7
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/services/tax_residencies/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,eAAO,MAAM,aAAa;;CAEhB,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Tax Residency API constants
3
+ */
4
+ // API Endpoints
5
+ export const API_ENDPOINTS = {
6
+ TAX_RESIDENCIES: '/api/tax-residencies/',
7
+ };
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Tax Residencies domain exports
3
+ *
4
+ * Centralizes all tax residencies-related exports for easy importing
5
+ */
6
+ export type { TaxResidency, TaxResidencyPayload, PaginatedTaxResidencies } from './types';
7
+ export { createTaxResidency, updateTaxResidency, deleteTaxResidency, getTaxResidencies } from './service';
8
+ export { findPrimaryTaxResidency, filterTaxResidenciesByCountry, hasTaxResidencyInCountry, getNonExemptedTaxResidencies, } from './utils';
9
+ export { API_ENDPOINTS } from './constants';
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/tax_residencies/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,YAAY,EAAE,YAAY,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAG1F,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAG1G,OAAO,EACL,uBAAuB,EACvB,6BAA6B,EAC7B,wBAAwB,EACxB,4BAA4B,GAC7B,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Tax Residencies domain exports
3
+ *
4
+ * Centralizes all tax residencies-related exports for easy importing
5
+ */
6
+ // Service functions
7
+ export { createTaxResidency, updateTaxResidency, deleteTaxResidency, getTaxResidencies } from './service';
8
+ // Utility functions
9
+ export { findPrimaryTaxResidency, filterTaxResidenciesByCountry, hasTaxResidencyInCountry, getNonExemptedTaxResidencies, } from './utils';
10
+ // Constants
11
+ export { API_ENDPOINTS } from './constants';
@@ -0,0 +1,6 @@
1
+ import type { TaxResidency, TaxResidencyPayload, PaginatedTaxResidencies } from './types';
2
+ export declare const createTaxResidency: (data: TaxResidencyPayload) => Promise<import("axios").AxiosResponse<TaxResidency, any>>;
3
+ export declare const updateTaxResidency: (uuid: string, data: TaxResidencyPayload) => Promise<import("axios").AxiosResponse<TaxResidency, any>>;
4
+ export declare const deleteTaxResidency: (uuid: string) => Promise<import("axios").AxiosResponse<void, any>>;
5
+ export declare const getTaxResidencies: () => Promise<import("axios").AxiosResponse<PaginatedTaxResidencies, any>>;
6
+ //# sourceMappingURL=service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../src/services/tax_residencies/service.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAE1F,eAAO,MAAM,kBAAkB,GAAI,MAAM,mBAAmB,8DAE3D,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,MAAM,MAAM,EAAE,MAAM,mBAAmB,8DAEzE,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,MAAM,MAAM,sDAE9C,CAAC;AAIF,eAAO,MAAM,iBAAiB,4EAM7B,CAAC"}
@@ -0,0 +1,20 @@
1
+ import { webApiClient } from '../../api/apiClient';
2
+ import { API_ENDPOINTS } from './constants';
3
+ export const createTaxResidency = (data) => {
4
+ return webApiClient.post(API_ENDPOINTS.TAX_RESIDENCIES, data);
5
+ };
6
+ export const updateTaxResidency = (uuid, data) => {
7
+ return webApiClient.patch(`${API_ENDPOINTS.TAX_RESIDENCIES}${uuid}/`, data);
8
+ };
9
+ export const deleteTaxResidency = (uuid) => {
10
+ return webApiClient.delete(`${API_ENDPOINTS.TAX_RESIDENCIES}${uuid}/`);
11
+ };
12
+ // Fetch list of tax residencies with optional filtering
13
+ // Orders by is_primary descending (primary first), then by country name
14
+ export const getTaxResidencies = () => {
15
+ return webApiClient.get(API_ENDPOINTS.TAX_RESIDENCIES, {
16
+ params: {
17
+ order_by: '-is_primary,country',
18
+ },
19
+ });
20
+ };
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Tax Residency types and interfaces
3
+ */
4
+ export interface TaxResidency {
5
+ uuid: string;
6
+ userProfile: string;
7
+ country: string;
8
+ isPrimary: boolean;
9
+ taxNumber: string;
10
+ isExempted: boolean;
11
+ exemptionReason: string | null;
12
+ }
13
+ export interface TaxResidencyPayload {
14
+ country: string;
15
+ isPrimary: boolean;
16
+ taxNumber: string;
17
+ isExempted: boolean;
18
+ exemptionReason: string | null;
19
+ }
20
+ export interface PaginatedTaxResidencies {
21
+ count: number;
22
+ next: string | null;
23
+ previous: string | null;
24
+ results: TaxResidency[];
25
+ }
26
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/services/tax_residencies/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,OAAO,CAAC;IACpB,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;CAChC;AAED,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,OAAO,CAAC;IACpB,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;CAChC;AAED,MAAM,WAAW,uBAAuB;IACtC,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,OAAO,EAAE,YAAY,EAAE,CAAC;CACzB"}
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Tax Residency types and interfaces
3
+ */
4
+ export {};
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Tax Residency utility functions
3
+ */
4
+ import type { TaxResidency } from './types';
5
+ export declare const findPrimaryTaxResidency: (taxResidencies: TaxResidency[]) => TaxResidency | undefined;
6
+ export declare const filterTaxResidenciesByCountry: (taxResidencies: TaxResidency[], countryCode: string) => TaxResidency[];
7
+ export declare const hasTaxResidencyInCountry: (taxResidencies: TaxResidency[], countryCode: string) => boolean;
8
+ export declare const getNonExemptedTaxResidencies: (taxResidencies: TaxResidency[]) => TaxResidency[];
9
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/services/tax_residencies/utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAG5C,eAAO,MAAM,uBAAuB,GAAI,gBAAgB,YAAY,EAAE,KAAG,YAAY,GAAG,SAEvF,CAAC;AAGF,eAAO,MAAM,6BAA6B,GAAI,gBAAgB,YAAY,EAAE,EAAE,aAAa,MAAM,KAAG,YAAY,EAE/G,CAAC;AAGF,eAAO,MAAM,wBAAwB,GAAI,gBAAgB,YAAY,EAAE,EAAE,aAAa,MAAM,KAAG,OAE9F,CAAC;AAGF,eAAO,MAAM,4BAA4B,GAAI,gBAAgB,YAAY,EAAE,KAAG,YAAY,EAEzF,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Tax Residency utility functions
3
+ */
4
+ // Find primary tax residency
5
+ export const findPrimaryTaxResidency = (taxResidencies) => {
6
+ return taxResidencies.find((residency) => residency.isPrimary);
7
+ };
8
+ // Filter tax residencies by country
9
+ export const filterTaxResidenciesByCountry = (taxResidencies, countryCode) => {
10
+ return taxResidencies.filter((residency) => residency.country === countryCode);
11
+ };
12
+ // Check if user has tax residency in specific country
13
+ export const hasTaxResidencyInCountry = (taxResidencies, countryCode) => {
14
+ return taxResidencies.some((residency) => residency.country === countryCode);
15
+ };
16
+ // Get non-exempted tax residencies
17
+ export const getNonExemptedTaxResidencies = (taxResidencies) => {
18
+ return taxResidencies.filter((residency) => !residency.isExempted);
19
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cranberry-money/shared-services",
3
- "version": "1.9.0",
3
+ "version": "1.10.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",