Fix TypeScript build errors
- Remove duplicate EscalationLevel export from regulatory.ts - Add missing logger.ts and reports.ts files to audit package - Fix treasury package type issues - Clean dist folders and rebuild
This commit is contained in:
3
apps/web/src/App.d.ts
vendored
Normal file
3
apps/web/src/App.d.ts
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
declare function App(): import("react/jsx-runtime").JSX.Element;
|
||||
export default App;
|
||||
//# sourceMappingURL=App.d.ts.map
|
||||
1
apps/web/src/App.d.ts.map
Normal file
1
apps/web/src/App.d.ts.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"App.d.ts","sourceRoot":"","sources":["App.tsx"],"names":[],"mappings":"AAMA,iBAAS,GAAG,4CAuDX;AAED,eAAe,GAAG,CAAC"}
|
||||
11
apps/web/src/App.js
Normal file
11
apps/web/src/App.js
Normal file
@@ -0,0 +1,11 @@
|
||||
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
||||
import { BrowserRouter, Routes, Route, Link } from 'react-router-dom';
|
||||
import DashboardPage from './pages/DashboardPage';
|
||||
import TransactionsPage from './pages/TransactionsPage';
|
||||
import TreasuryPage from './pages/TreasuryPage';
|
||||
import ReportsPage from './pages/ReportsPage';
|
||||
function App() {
|
||||
return (_jsx(BrowserRouter, { children: _jsxs("div", { className: "min-h-screen bg-gray-50", children: [_jsx("nav", { className: "bg-white shadow-sm border-b", children: _jsx("div", { className: "max-w-7xl mx-auto px-4 sm:px-6 lg:px-8", children: _jsx("div", { className: "flex justify-between h-16", children: _jsxs("div", { className: "flex", children: [_jsx("div", { className: "flex-shrink-0 flex items-center", children: _jsx("h1", { className: "text-xl font-bold text-gray-900", children: "Brazil SWIFT Operations" }) }), _jsxs("div", { className: "hidden sm:ml-6 sm:flex sm:space-x-8", children: [_jsx(Link, { to: "/", className: "border-transparent text-gray-500 hover:border-gray-300 hover:text-gray-700 inline-flex items-center px-1 pt-1 border-b-2 text-sm font-medium", children: "Dashboard" }), _jsx(Link, { to: "/transactions", className: "border-transparent text-gray-500 hover:border-gray-300 hover:text-gray-700 inline-flex items-center px-1 pt-1 border-b-2 text-sm font-medium", children: "Transactions" }), _jsx(Link, { to: "/treasury", className: "border-transparent text-gray-500 hover:border-gray-300 hover:text-gray-700 inline-flex items-center px-1 pt-1 border-b-2 text-sm font-medium", children: "Treasury" }), _jsx(Link, { to: "/reports", className: "border-transparent text-gray-500 hover:border-gray-300 hover:text-gray-700 inline-flex items-center px-1 pt-1 border-b-2 text-sm font-medium", children: "Reports" })] })] }) }) }) }), _jsx("main", { className: "max-w-7xl mx-auto py-6 sm:px-6 lg:px-8", children: _jsxs(Routes, { children: [_jsx(Route, { path: "/", element: _jsx(DashboardPage, {}) }), _jsx(Route, { path: "/transactions", element: _jsx(TransactionsPage, {}) }), _jsx(Route, { path: "/treasury", element: _jsx(TreasuryPage, {}) }), _jsx(Route, { path: "/reports", element: _jsx(ReportsPage, {}) })] }) })] }) }));
|
||||
}
|
||||
export default App;
|
||||
//# sourceMappingURL=App.js.map
|
||||
1
apps/web/src/App.js.map
Normal file
1
apps/web/src/App.js.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"App.js","sourceRoot":"","sources":["App.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,aAAa,MAAM,uBAAuB,CAAC;AAClD,OAAO,gBAAgB,MAAM,0BAA0B,CAAC;AACxD,OAAO,YAAY,MAAM,sBAAsB,CAAC;AAChD,OAAO,WAAW,MAAM,qBAAqB,CAAC;AAE9C,SAAS,GAAG;IACV,OAAO,CACL,KAAC,aAAa,cACZ,eAAK,SAAS,EAAC,yBAAyB,aACtC,cAAK,SAAS,EAAC,6BAA6B,YAC1C,cAAK,SAAS,EAAC,wCAAwC,YACrD,cAAK,SAAS,EAAC,2BAA2B,YACxC,eAAK,SAAS,EAAC,MAAM,aACnB,cAAK,SAAS,EAAC,iCAAiC,YAC9C,aAAI,SAAS,EAAC,iCAAiC,wCAE1C,GACD,EACN,eAAK,SAAS,EAAC,qCAAqC,aAClD,KAAC,IAAI,IACH,EAAE,EAAC,GAAG,EACN,SAAS,EAAC,8IAA8I,0BAGnJ,EACP,KAAC,IAAI,IACH,EAAE,EAAC,eAAe,EAClB,SAAS,EAAC,8IAA8I,6BAGnJ,EACP,KAAC,IAAI,IACH,EAAE,EAAC,WAAW,EACd,SAAS,EAAC,8IAA8I,yBAGnJ,EACP,KAAC,IAAI,IACH,EAAE,EAAC,UAAU,EACb,SAAS,EAAC,8IAA8I,wBAGnJ,IACH,IACF,GACF,GACF,GACF,EAEN,eAAM,SAAS,EAAC,wCAAwC,YACtD,MAAC,MAAM,eACL,KAAC,KAAK,IAAC,IAAI,EAAC,GAAG,EAAC,OAAO,EAAE,KAAC,aAAa,KAAG,GAAI,EAC9C,KAAC,KAAK,IAAC,IAAI,EAAC,eAAe,EAAC,OAAO,EAAE,KAAC,gBAAgB,KAAG,GAAI,EAC7D,KAAC,KAAK,IAAC,IAAI,EAAC,WAAW,EAAC,OAAO,EAAE,KAAC,YAAY,KAAG,GAAI,EACrD,KAAC,KAAK,IAAC,IAAI,EAAC,UAAU,EAAC,OAAO,EAAE,KAAC,WAAW,KAAG,GAAI,IAC5C,GACJ,IACH,GACQ,CACjB,CAAC;AACJ,CAAC;AAED,eAAe,GAAG,CAAC"}
|
||||
2
apps/web/src/main.d.ts
vendored
Normal file
2
apps/web/src/main.d.ts
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import './index.css';
|
||||
//# sourceMappingURL=main.d.ts.map
|
||||
1
apps/web/src/main.d.ts.map
Normal file
1
apps/web/src/main.d.ts.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["main.tsx"],"names":[],"mappings":"AAGA,OAAO,aAAa,CAAC"}
|
||||
7
apps/web/src/main.js
Normal file
7
apps/web/src/main.js
Normal file
@@ -0,0 +1,7 @@
|
||||
import { jsx as _jsx } from "react/jsx-runtime";
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom/client';
|
||||
import App from './App';
|
||||
import './index.css';
|
||||
ReactDOM.createRoot(document.getElementById('root')).render(_jsx(React.StrictMode, { children: _jsx(App, {}) }));
|
||||
//# sourceMappingURL=main.js.map
|
||||
1
apps/web/src/main.js.map
Normal file
1
apps/web/src/main.js.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"main.js","sourceRoot":"","sources":["main.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,QAAQ,MAAM,kBAAkB,CAAC;AACxC,OAAO,GAAG,MAAM,OAAO,CAAC;AACxB,OAAO,aAAa,CAAC;AAErB,QAAQ,CAAC,UAAU,CAAC,QAAQ,CAAC,cAAc,CAAC,MAAM,CAAE,CAAC,CAAC,MAAM,CAC1D,KAAC,KAAK,CAAC,UAAU,cACf,KAAC,GAAG,KAAG,GACU,CACpB,CAAC"}
|
||||
2
apps/web/src/pages/DashboardPage.d.ts
vendored
Normal file
2
apps/web/src/pages/DashboardPage.d.ts
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
export default function DashboardPage(): import("react/jsx-runtime").JSX.Element;
|
||||
//# sourceMappingURL=DashboardPage.d.ts.map
|
||||
1
apps/web/src/pages/DashboardPage.d.ts.map
Normal file
1
apps/web/src/pages/DashboardPage.d.ts.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"DashboardPage.d.ts","sourceRoot":"","sources":["DashboardPage.tsx"],"names":[],"mappings":"AAEA,MAAM,CAAC,OAAO,UAAU,aAAa,4CASpC"}
|
||||
5
apps/web/src/pages/DashboardPage.js
Normal file
5
apps/web/src/pages/DashboardPage.js
Normal file
@@ -0,0 +1,5 @@
|
||||
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
||||
export default function DashboardPage() {
|
||||
return (_jsx("div", { className: "px-4 py-6 sm:px-0", children: _jsxs("div", { className: "border-4 border-dashed border-gray-200 rounded-lg h-96 p-8", children: [_jsx("h1", { className: "text-2xl font-bold mb-4", children: "Dashboard" }), _jsx("p", { className: "text-gray-600", children: "Brazil SWIFT Operations Platform" })] }) }));
|
||||
}
|
||||
//# sourceMappingURL=DashboardPage.js.map
|
||||
1
apps/web/src/pages/DashboardPage.js.map
Normal file
1
apps/web/src/pages/DashboardPage.js.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"DashboardPage.js","sourceRoot":"","sources":["DashboardPage.tsx"],"names":[],"mappings":";AAEA,MAAM,CAAC,OAAO,UAAU,aAAa;IACnC,OAAO,CACL,cAAK,SAAS,EAAC,mBAAmB,YAChC,eAAK,SAAS,EAAC,4DAA4D,aACzE,aAAI,SAAS,EAAC,yBAAyB,0BAAe,EACtD,YAAG,SAAS,EAAC,eAAe,iDAAqC,IAC7D,GACF,CACP,CAAC;AACJ,CAAC"}
|
||||
2
apps/web/src/pages/ReportsPage.d.ts
vendored
Normal file
2
apps/web/src/pages/ReportsPage.d.ts
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
export default function ReportsPage(): import("react/jsx-runtime").JSX.Element;
|
||||
//# sourceMappingURL=ReportsPage.d.ts.map
|
||||
1
apps/web/src/pages/ReportsPage.d.ts.map
Normal file
1
apps/web/src/pages/ReportsPage.d.ts.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"ReportsPage.d.ts","sourceRoot":"","sources":["ReportsPage.tsx"],"names":[],"mappings":"AAEA,MAAM,CAAC,OAAO,UAAU,WAAW,4CAOlC"}
|
||||
5
apps/web/src/pages/ReportsPage.js
Normal file
5
apps/web/src/pages/ReportsPage.js
Normal file
@@ -0,0 +1,5 @@
|
||||
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
||||
export default function ReportsPage() {
|
||||
return (_jsxs("div", { className: "px-4 py-6 sm:px-0", children: [_jsx("h1", { className: "text-2xl font-bold mb-4", children: "ReportsPage" }), _jsx("p", { className: "text-gray-600", children: "ReportsPage interface" })] }));
|
||||
}
|
||||
//# sourceMappingURL=ReportsPage.js.map
|
||||
1
apps/web/src/pages/ReportsPage.js.map
Normal file
1
apps/web/src/pages/ReportsPage.js.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"ReportsPage.js","sourceRoot":"","sources":["ReportsPage.tsx"],"names":[],"mappings":";AAEA,MAAM,CAAC,OAAO,UAAU,WAAW;IACjC,OAAO,CACL,eAAK,SAAS,EAAC,mBAAmB,aAChC,aAAI,SAAS,EAAC,yBAAyB,4BAAiB,EACxD,YAAG,SAAS,EAAC,eAAe,sCAA0B,IAClD,CACP,CAAC;AACJ,CAAC"}
|
||||
2
apps/web/src/pages/TransactionsPage.d.ts
vendored
Normal file
2
apps/web/src/pages/TransactionsPage.d.ts
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
export default function TransactionsPage(): import("react/jsx-runtime").JSX.Element;
|
||||
//# sourceMappingURL=TransactionsPage.d.ts.map
|
||||
1
apps/web/src/pages/TransactionsPage.d.ts.map
Normal file
1
apps/web/src/pages/TransactionsPage.d.ts.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"TransactionsPage.d.ts","sourceRoot":"","sources":["TransactionsPage.tsx"],"names":[],"mappings":"AAEA,MAAM,CAAC,OAAO,UAAU,gBAAgB,4CAOvC"}
|
||||
5
apps/web/src/pages/TransactionsPage.js
Normal file
5
apps/web/src/pages/TransactionsPage.js
Normal file
@@ -0,0 +1,5 @@
|
||||
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
||||
export default function TransactionsPage() {
|
||||
return (_jsxs("div", { className: "px-4 py-6 sm:px-0", children: [_jsx("h1", { className: "text-2xl font-bold mb-4", children: "TransactionsPage" }), _jsx("p", { className: "text-gray-600", children: "TransactionsPage interface" })] }));
|
||||
}
|
||||
//# sourceMappingURL=TransactionsPage.js.map
|
||||
1
apps/web/src/pages/TransactionsPage.js.map
Normal file
1
apps/web/src/pages/TransactionsPage.js.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"TransactionsPage.js","sourceRoot":"","sources":["TransactionsPage.tsx"],"names":[],"mappings":";AAEA,MAAM,CAAC,OAAO,UAAU,gBAAgB;IACtC,OAAO,CACL,eAAK,SAAS,EAAC,mBAAmB,aAChC,aAAI,SAAS,EAAC,yBAAyB,iCAAsB,EAC7D,YAAG,SAAS,EAAC,eAAe,2CAA+B,IACvD,CACP,CAAC;AACJ,CAAC"}
|
||||
2
apps/web/src/pages/TreasuryPage.d.ts
vendored
Normal file
2
apps/web/src/pages/TreasuryPage.d.ts
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
export default function TreasuryPage(): import("react/jsx-runtime").JSX.Element;
|
||||
//# sourceMappingURL=TreasuryPage.d.ts.map
|
||||
1
apps/web/src/pages/TreasuryPage.d.ts.map
Normal file
1
apps/web/src/pages/TreasuryPage.d.ts.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"TreasuryPage.d.ts","sourceRoot":"","sources":["TreasuryPage.tsx"],"names":[],"mappings":"AAEA,MAAM,CAAC,OAAO,UAAU,YAAY,4CAOnC"}
|
||||
5
apps/web/src/pages/TreasuryPage.js
Normal file
5
apps/web/src/pages/TreasuryPage.js
Normal file
@@ -0,0 +1,5 @@
|
||||
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
||||
export default function TreasuryPage() {
|
||||
return (_jsxs("div", { className: "px-4 py-6 sm:px-0", children: [_jsx("h1", { className: "text-2xl font-bold mb-4", children: "TreasuryPage" }), _jsx("p", { className: "text-gray-600", children: "TreasuryPage interface" })] }));
|
||||
}
|
||||
//# sourceMappingURL=TreasuryPage.js.map
|
||||
1
apps/web/src/pages/TreasuryPage.js.map
Normal file
1
apps/web/src/pages/TreasuryPage.js.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"TreasuryPage.js","sourceRoot":"","sources":["TreasuryPage.tsx"],"names":[],"mappings":";AAEA,MAAM,CAAC,OAAO,UAAU,YAAY;IAClC,OAAO,CACL,eAAK,SAAS,EAAC,mBAAmB,aAChC,aAAI,SAAS,EAAC,yBAAyB,6BAAkB,EACzD,YAAG,SAAS,EAAC,eAAe,uCAA2B,IACnD,CACP,CAAC;AACJ,CAAC"}
|
||||
10
apps/web/src/stores/transactionStore.d.ts
vendored
Normal file
10
apps/web/src/stores/transactionStore.d.ts
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
import type { Transaction, BrazilRegulatoryResult } from '@brazil-swift-ops/types';
|
||||
interface TransactionStore {
|
||||
transactions: Transaction[];
|
||||
results: Map<string, BrazilRegulatoryResult>;
|
||||
addTransaction: (txn: Transaction) => void;
|
||||
evaluateTransaction: (txn: Transaction) => BrazilRegulatoryResult;
|
||||
}
|
||||
export declare const useTransactionStore: import("zustand").UseBoundStore<import("zustand").StoreApi<TransactionStore>>;
|
||||
export {};
|
||||
//# sourceMappingURL=transactionStore.d.ts.map
|
||||
1
apps/web/src/stores/transactionStore.d.ts.map
Normal file
1
apps/web/src/stores/transactionStore.d.ts.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"transactionStore.d.ts","sourceRoot":"","sources":["transactionStore.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAGnF,UAAU,gBAAgB;IACxB,YAAY,EAAE,WAAW,EAAE,CAAC;IAC5B,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAAC;IAC7C,cAAc,EAAE,CAAC,GAAG,EAAE,WAAW,KAAK,IAAI,CAAC;IAC3C,mBAAmB,EAAE,CAAC,GAAG,EAAE,WAAW,KAAK,sBAAsB,CAAC;CACnE;AAED,eAAO,MAAM,mBAAmB,+EAiB7B,CAAC"}
|
||||
21
apps/web/src/stores/transactionStore.js
Normal file
21
apps/web/src/stores/transactionStore.js
Normal file
@@ -0,0 +1,21 @@
|
||||
import { create } from 'zustand';
|
||||
import { evaluateTransaction } from '@brazil-swift-ops/rules-engine';
|
||||
export const useTransactionStore = create((set) => ({
|
||||
transactions: [],
|
||||
results: new Map(),
|
||||
addTransaction: (txn) => {
|
||||
const result = evaluateTransaction(txn);
|
||||
set((state) => ({
|
||||
transactions: [...state.transactions, txn],
|
||||
results: new Map(state.results).set(txn.id, result),
|
||||
}));
|
||||
},
|
||||
evaluateTransaction: (txn) => {
|
||||
const result = evaluateTransaction(txn);
|
||||
set((state) => ({
|
||||
results: new Map(state.results).set(txn.id, result),
|
||||
}));
|
||||
return result;
|
||||
},
|
||||
}));
|
||||
//# sourceMappingURL=transactionStore.js.map
|
||||
1
apps/web/src/stores/transactionStore.js.map
Normal file
1
apps/web/src/stores/transactionStore.js.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"transactionStore.js","sourceRoot":"","sources":["transactionStore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEjC,OAAO,EAAE,mBAAmB,EAAiB,MAAM,gCAAgC,CAAC;AASpF,MAAM,CAAC,MAAM,mBAAmB,GAAG,MAAM,CAAmB,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;IACpE,YAAY,EAAE,EAAE;IAChB,OAAO,EAAE,IAAI,GAAG,EAAE;IAClB,cAAc,EAAE,CAAC,GAAG,EAAE,EAAE;QACtB,MAAM,MAAM,GAAG,mBAAmB,CAAC,GAAG,CAAC,CAAC;QACxC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;YACd,YAAY,EAAE,CAAC,GAAG,KAAK,CAAC,YAAY,EAAE,GAAG,CAAC;YAC1C,OAAO,EAAE,IAAI,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,EAAE,MAAM,CAAC;SACpD,CAAC,CAAC,CAAC;IACN,CAAC;IACD,mBAAmB,EAAE,CAAC,GAAG,EAAE,EAAE;QAC3B,MAAM,MAAM,GAAG,mBAAmB,CAAC,GAAG,CAAC,CAAC;QACxC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;YACd,OAAO,EAAE,IAAI,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,EAAE,MAAM,CAAC;SACpD,CAAC,CAAC,CAAC;QACJ,OAAO,MAAM,CAAC;IAChB,CAAC;CACF,CAAC,CAAC,CAAC"}
|
||||
5
packages/audit/src/index.d.ts
vendored
Normal file
5
packages/audit/src/index.d.ts
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
export * from './logger';
|
||||
export * from './reports';
|
||||
export * from './retention';
|
||||
export * from './versions';
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
1
packages/audit/src/index.d.ts.map
Normal file
1
packages/audit/src/index.d.ts.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC"}
|
||||
5
packages/audit/src/index.js
Normal file
5
packages/audit/src/index.js
Normal file
@@ -0,0 +1,5 @@
|
||||
export * from './logger';
|
||||
export * from './reports';
|
||||
export * from './retention';
|
||||
export * from './versions';
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
packages/audit/src/index.js.map
Normal file
1
packages/audit/src/index.js.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC"}
|
||||
13
packages/audit/src/logger.d.ts
vendored
Normal file
13
packages/audit/src/logger.d.ts
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
import type { AuditLog, BrazilRegulatoryResult } from '@brazil-swift-ops/types';
|
||||
declare class AuditLogStore {
|
||||
private logs;
|
||||
add(log: AuditLog): void;
|
||||
get(id: string): AuditLog | undefined;
|
||||
getByTransaction(transactionId: string): AuditLog[];
|
||||
getByDateRange(startDate: Date, endDate: Date): AuditLog[];
|
||||
getAll(): AuditLog[];
|
||||
}
|
||||
export declare function getAuditLogStore(): AuditLogStore;
|
||||
export declare function createAuditLog(result: BrazilRegulatoryResult, action?: string, userId?: string, ipAddress?: string): AuditLog;
|
||||
export {};
|
||||
//# sourceMappingURL=logger.d.ts.map
|
||||
1
packages/audit/src/logger.d.ts.map
Normal file
1
packages/audit/src/logger.d.ts.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["logger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAEhF,cAAM,aAAa;IACjB,OAAO,CAAC,IAAI,CAAkB;IAE9B,GAAG,CAAC,GAAG,EAAE,QAAQ,GAAG,IAAI;IAIxB,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS;IAIrC,gBAAgB,CAAC,aAAa,EAAE,MAAM,GAAG,QAAQ,EAAE;IAInD,cAAc,CAAC,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,GAAG,QAAQ,EAAE;IAM1D,MAAM,IAAI,QAAQ,EAAE;CAGrB;AAID,wBAAgB,gBAAgB,IAAI,aAAa,CAEhD;AAED,wBAAgB,cAAc,CAC5B,MAAM,EAAE,sBAAsB,EAC9B,MAAM,GAAE,MAAgC,EACxC,MAAM,CAAC,EAAE,MAAM,EACf,SAAS,CAAC,EAAE,MAAM,GACjB,QAAQ,CAwBV"}
|
||||
47
packages/audit/src/logger.js
Normal file
47
packages/audit/src/logger.js
Normal file
@@ -0,0 +1,47 @@
|
||||
class AuditLogStore {
|
||||
logs = [];
|
||||
add(log) {
|
||||
this.logs.push(log);
|
||||
}
|
||||
get(id) {
|
||||
return this.logs.find((log) => log.id === id);
|
||||
}
|
||||
getByTransaction(transactionId) {
|
||||
return this.logs.filter((log) => log.transactionId === transactionId);
|
||||
}
|
||||
getByDateRange(startDate, endDate) {
|
||||
return this.logs.filter((log) => log.timestamp >= startDate && log.timestamp <= endDate);
|
||||
}
|
||||
getAll() {
|
||||
return [...this.logs];
|
||||
}
|
||||
}
|
||||
const auditLogStore = new AuditLogStore();
|
||||
export function getAuditLogStore() {
|
||||
return auditLogStore;
|
||||
}
|
||||
export function createAuditLog(result, action = 'transaction_processed', userId, ipAddress) {
|
||||
const log = {
|
||||
id: `AUDIT-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`,
|
||||
timestamp: result.timestamp,
|
||||
transactionId: result.transactionId,
|
||||
ruleSetVersion: result.ruleSetVersion,
|
||||
inputs: {
|
||||
transactionId: result.transactionId,
|
||||
},
|
||||
outputs: {
|
||||
overallDecision: result.overallDecision,
|
||||
overallSeverity: result.overallSeverity,
|
||||
rules: result.rules,
|
||||
},
|
||||
decision: result.overallDecision,
|
||||
severity: result.overallSeverity,
|
||||
rationale: result.rules.map((r) => r.rationale).join('; '),
|
||||
userId,
|
||||
ipAddress,
|
||||
action,
|
||||
};
|
||||
auditLogStore.add(log);
|
||||
return log;
|
||||
}
|
||||
//# sourceMappingURL=logger.js.map
|
||||
1
packages/audit/src/logger.js.map
Normal file
1
packages/audit/src/logger.js.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"logger.js","sourceRoot":"","sources":["logger.ts"],"names":[],"mappings":"AAEA,MAAM,aAAa;IACT,IAAI,GAAe,EAAE,CAAC;IAE9B,GAAG,CAAC,GAAa;QACf,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACtB,CAAC;IAED,GAAG,CAAC,EAAU;QACZ,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI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AAM,CAAC,eAAe;QAChC,QAAQ,EAAE,MAAM,CAAC,eAAe;QAChC,SAAS,EAAE,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;QAC1D,MAAM;QACN,SAAS;QACT,MAAM;KACP,CAAC;IAEF,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACvB,OAAO,GAAG,CAAC;AACb,CAAC"}
|
||||
64
packages/audit/src/logger.ts
Normal file
64
packages/audit/src/logger.ts
Normal file
@@ -0,0 +1,64 @@
|
||||
import type { AuditLog, BrazilRegulatoryResult } from '@brazil-swift-ops/types';
|
||||
|
||||
class AuditLogStore {
|
||||
private logs: AuditLog[] = [];
|
||||
|
||||
add(log: AuditLog): void {
|
||||
this.logs.push(log);
|
||||
}
|
||||
|
||||
get(id: string): AuditLog | undefined {
|
||||
return this.logs.find((log) => log.id === id);
|
||||
}
|
||||
|
||||
getByTransaction(transactionId: string): AuditLog[] {
|
||||
return this.logs.filter((log) => log.transactionId === transactionId);
|
||||
}
|
||||
|
||||
getByDateRange(startDate: Date, endDate: Date): AuditLog[] {
|
||||
return this.logs.filter(
|
||||
(log) => log.timestamp >= startDate && log.timestamp <= endDate
|
||||
);
|
||||
}
|
||||
|
||||
getAll(): AuditLog[] {
|
||||
return [...this.logs];
|
||||
}
|
||||
}
|
||||
|
||||
const auditLogStore = new AuditLogStore();
|
||||
|
||||
export function getAuditLogStore(): AuditLogStore {
|
||||
return auditLogStore;
|
||||
}
|
||||
|
||||
export function createAuditLog(
|
||||
result: BrazilRegulatoryResult,
|
||||
action: string = 'transaction_processed',
|
||||
userId?: string,
|
||||
ipAddress?: string
|
||||
): AuditLog {
|
||||
const log: AuditLog = {
|
||||
id: `AUDIT-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`,
|
||||
timestamp: result.timestamp,
|
||||
transactionId: result.transactionId,
|
||||
ruleSetVersion: result.ruleSetVersion,
|
||||
inputs: {
|
||||
transactionId: result.transactionId,
|
||||
},
|
||||
outputs: {
|
||||
overallDecision: result.overallDecision,
|
||||
overallSeverity: result.overallSeverity,
|
||||
rules: result.rules,
|
||||
},
|
||||
decision: result.overallDecision,
|
||||
severity: result.overallSeverity,
|
||||
rationale: result.rules.map((r) => r.rationale).join('; '),
|
||||
userId,
|
||||
ipAddress,
|
||||
action,
|
||||
};
|
||||
|
||||
auditLogStore.add(log);
|
||||
return log;
|
||||
}
|
||||
4
packages/audit/src/reports.d.ts
vendored
Normal file
4
packages/audit/src/reports.d.ts
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
import type { BCBReport, Transaction, BrazilRegulatoryResult } from '@brazil-swift-ops/types';
|
||||
export declare function generateBCBReport(transactions: Transaction[], results: BrazilRegulatoryResult[], reportType?: 'transaction' | 'batch' | 'periodic', periodStart?: Date, periodEnd?: Date): BCBReport;
|
||||
export declare function exportBCBReportToCSV(report: BCBReport): string;
|
||||
//# sourceMappingURL=reports.d.ts.map
|
||||
1
packages/audit/src/reports.d.ts.map
Normal file
1
packages/audit/src/reports.d.ts.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"reports.d.ts","sourceRoot":"","sources":["reports.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EAGT,WAAW,EACX,sBAAsB,EACvB,MAAM,yBAAyB,CAAC;AAGjC,wBAAgB,iBAAiB,CAC/B,YAAY,EAAE,WAAW,EAAE,EAC3B,OAAO,EAAE,sBAAsB,EAAE,EACjC,UAAU,GAAE,aAAa,GAAG,OAAO,GAAG,UAA0B,EAChE,WAAW,CAAC,EAAE,IAAI,EAClB,SAAS,CAAC,EAAE,IAAI,GACf,SAAS,CA6DX;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,SAAS,GAAG,MAAM,CAqC9D"}
|
||||
95
packages/audit/src/reports.js
Normal file
95
packages/audit/src/reports.js
Normal file
@@ -0,0 +1,95 @@
|
||||
import { getDefaultConverter } from '@brazil-swift-ops/utils';
|
||||
export function generateBCBReport(transactions, results, reportType = 'transaction', periodStart, periodEnd) {
|
||||
const converter = getDefaultConverter();
|
||||
const reportTransactions = transactions.map((txn, index) => {
|
||||
const result = results[index];
|
||||
const usdEquivalent = converter.getUSDEquivalent(txn.amount, txn.currency);
|
||||
return {
|
||||
transactionId: txn.id,
|
||||
executionDate: txn.createdAt,
|
||||
direction: txn.direction,
|
||||
amount: txn.amount,
|
||||
currency: txn.currency,
|
||||
usdEquivalent,
|
||||
orderingCustomer: {
|
||||
name: txn.orderingCustomer.name,
|
||||
taxId: txn.orderingCustomer.taxId,
|
||||
country: txn.orderingCustomer.country,
|
||||
},
|
||||
beneficiary: {
|
||||
name: txn.beneficiary.name,
|
||||
taxId: txn.beneficiary.taxId,
|
||||
country: txn.beneficiary.country,
|
||||
accountNumber: txn.beneficiary.accountNumber,
|
||||
},
|
||||
purposeOfPayment: txn.purposeOfPayment,
|
||||
fxContractId: txn.fxContractId,
|
||||
iofAmount: result.iofCalculation?.iofAmount,
|
||||
reportingRequired: result.thresholdCheck?.requiresReporting ?? false,
|
||||
};
|
||||
});
|
||||
const summary = {
|
||||
totalTransactions: reportTransactions.length,
|
||||
totalAmount: reportTransactions.reduce((sum, t) => sum + t.amount, 0),
|
||||
totalUsdEquivalent: reportTransactions.reduce((sum, t) => sum + t.usdEquivalent, 0),
|
||||
inboundCount: reportTransactions.filter((t) => t.direction === 'inbound').length,
|
||||
inboundAmount: reportTransactions
|
||||
.filter((t) => t.direction === 'inbound')
|
||||
.reduce((sum, t) => sum + t.amount, 0),
|
||||
outboundCount: reportTransactions.filter((t) => t.direction === 'outbound').length,
|
||||
outboundAmount: reportTransactions
|
||||
.filter((t) => t.direction === 'outbound')
|
||||
.reduce((sum, t) => sum + t.amount, 0),
|
||||
reportingRequiredCount: reportTransactions.filter((t) => t.reportingRequired).length,
|
||||
totalIOF: reportTransactions.reduce((sum, t) => sum + (t.iofAmount || 0), 0),
|
||||
};
|
||||
const report = {
|
||||
reportId: `BCB-${Date.now()}`,
|
||||
reportType,
|
||||
generatedAt: new Date(),
|
||||
periodStart,
|
||||
periodEnd,
|
||||
transactions: reportTransactions,
|
||||
summary,
|
||||
format: 'json',
|
||||
data: JSON.stringify({ transactions: reportTransactions, summary }, null, 2),
|
||||
};
|
||||
return report;
|
||||
}
|
||||
export function exportBCBReportToCSV(report) {
|
||||
const headers = [
|
||||
'Transaction ID',
|
||||
'Execution Date',
|
||||
'Direction',
|
||||
'Amount',
|
||||
'Currency',
|
||||
'USD Equivalent',
|
||||
'Ordering Customer',
|
||||
'Ordering Tax ID',
|
||||
'Beneficiary',
|
||||
'Beneficiary Tax ID',
|
||||
'Purpose',
|
||||
'FX Contract ID',
|
||||
'IOF Amount',
|
||||
'Reporting Required',
|
||||
];
|
||||
const rows = report.transactions.map((t) => [
|
||||
t.transactionId,
|
||||
t.executionDate.toISOString(),
|
||||
t.direction,
|
||||
t.amount.toString(),
|
||||
t.currency,
|
||||
t.usdEquivalent.toString(),
|
||||
t.orderingCustomer.name,
|
||||
t.orderingCustomer.taxId || '',
|
||||
t.beneficiary.name,
|
||||
t.beneficiary.taxId || '',
|
||||
t.purposeOfPayment || '',
|
||||
t.fxContractId || '',
|
||||
(t.iofAmount || 0).toString(),
|
||||
t.reportingRequired ? 'Yes' : 'No',
|
||||
]);
|
||||
const csv = [headers.join(','), ...rows.map((row) => row.join(','))].join('\n');
|
||||
return csv;
|
||||
}
|
||||
//# sourceMappingURL=reports.js.map
|
||||
1
packages/audit/src/reports.js.map
Normal file
1
packages/audit/src/reports.js.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"reports.js","sourceRoot":"","sources":["reports.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAE9D,MAAM,UAAU,iBAAiB,CAC/B,YAA2B,EAC3B,OAAiC,EACjC,aAAmD,aAAa,EAChE,WAA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Q,EAAE;QAC7B,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI;KACnC,CAAC,CAAC;IAEH,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAChF,OAAO,GAAG,CAAC;AACb,CAAC"}
|
||||
116
packages/audit/src/reports.ts
Normal file
116
packages/audit/src/reports.ts
Normal file
@@ -0,0 +1,116 @@
|
||||
import type {
|
||||
BCBReport,
|
||||
BCBReportTransaction,
|
||||
BCBReportSummary,
|
||||
Transaction,
|
||||
BrazilRegulatoryResult,
|
||||
} from '@brazil-swift-ops/types';
|
||||
import { getDefaultConverter } from '@brazil-swift-ops/utils';
|
||||
|
||||
export function generateBCBReport(
|
||||
transactions: Transaction[],
|
||||
results: BrazilRegulatoryResult[],
|
||||
reportType: 'transaction' | 'batch' | 'periodic' = 'transaction',
|
||||
periodStart?: Date,
|
||||
periodEnd?: Date
|
||||
): BCBReport {
|
||||
const converter = getDefaultConverter();
|
||||
|
||||
const reportTransactions: BCBReportTransaction[] = transactions.map((txn, index) => {
|
||||
const result = results[index];
|
||||
const usdEquivalent = converter.getUSDEquivalent(txn.amount, txn.currency);
|
||||
|
||||
return {
|
||||
transactionId: txn.id,
|
||||
executionDate: txn.createdAt,
|
||||
direction: txn.direction,
|
||||
amount: txn.amount,
|
||||
currency: txn.currency,
|
||||
usdEquivalent,
|
||||
orderingCustomer: {
|
||||
name: txn.orderingCustomer.name,
|
||||
taxId: txn.orderingCustomer.taxId,
|
||||
country: txn.orderingCustomer.country,
|
||||
},
|
||||
beneficiary: {
|
||||
name: txn.beneficiary.name,
|
||||
taxId: txn.beneficiary.taxId,
|
||||
country: txn.beneficiary.country,
|
||||
accountNumber: txn.beneficiary.accountNumber,
|
||||
},
|
||||
purposeOfPayment: txn.purposeOfPayment,
|
||||
fxContractId: txn.fxContractId,
|
||||
iofAmount: result.iofCalculation?.iofAmount,
|
||||
reportingRequired: result.thresholdCheck?.requiresReporting ?? false,
|
||||
};
|
||||
});
|
||||
|
||||
const summary: BCBReportSummary = {
|
||||
totalTransactions: reportTransactions.length,
|
||||
totalAmount: reportTransactions.reduce((sum, t) => sum + t.amount, 0),
|
||||
totalUsdEquivalent: reportTransactions.reduce((sum, t) => sum + t.usdEquivalent, 0),
|
||||
inboundCount: reportTransactions.filter((t) => t.direction === 'inbound').length,
|
||||
inboundAmount: reportTransactions
|
||||
.filter((t) => t.direction === 'inbound')
|
||||
.reduce((sum, t) => sum + t.amount, 0),
|
||||
outboundCount: reportTransactions.filter((t) => t.direction === 'outbound').length,
|
||||
outboundAmount: reportTransactions
|
||||
.filter((t) => t.direction === 'outbound')
|
||||
.reduce((sum, t) => sum + t.amount, 0),
|
||||
reportingRequiredCount: reportTransactions.filter((t) => t.reportingRequired).length,
|
||||
totalIOF: reportTransactions.reduce((sum, t) => sum + (t.iofAmount || 0), 0),
|
||||
};
|
||||
|
||||
const report: BCBReport = {
|
||||
reportId: `BCB-${Date.now()}`,
|
||||
reportType,
|
||||
generatedAt: new Date(),
|
||||
periodStart,
|
||||
periodEnd,
|
||||
transactions: reportTransactions,
|
||||
summary,
|
||||
format: 'json',
|
||||
data: JSON.stringify({ transactions: reportTransactions, summary }, null, 2),
|
||||
};
|
||||
|
||||
return report;
|
||||
}
|
||||
|
||||
export function exportBCBReportToCSV(report: BCBReport): string {
|
||||
const headers = [
|
||||
'Transaction ID',
|
||||
'Execution Date',
|
||||
'Direction',
|
||||
'Amount',
|
||||
'Currency',
|
||||
'USD Equivalent',
|
||||
'Ordering Customer',
|
||||
'Ordering Tax ID',
|
||||
'Beneficiary',
|
||||
'Beneficiary Tax ID',
|
||||
'Purpose',
|
||||
'FX Contract ID',
|
||||
'IOF Amount',
|
||||
'Reporting Required',
|
||||
];
|
||||
|
||||
const rows = report.transactions.map((t) => [
|
||||
t.transactionId,
|
||||
t.executionDate.toISOString(),
|
||||
t.direction,
|
||||
t.amount.toString(),
|
||||
t.currency,
|
||||
t.usdEquivalent.toString(),
|
||||
t.orderingCustomer.name,
|
||||
t.orderingCustomer.taxId || '',
|
||||
t.beneficiary.name,
|
||||
t.beneficiary.taxId || '',
|
||||
t.purposeOfPayment || '',
|
||||
t.fxContractId || '',
|
||||
(t.iofAmount || 0).toString(),
|
||||
t.reportingRequired ? 'Yes' : 'No',
|
||||
]);
|
||||
|
||||
const csv = [headers.join(','), ...rows.map((row) => row.join(','))].join('\n');
|
||||
return csv;
|
||||
}
|
||||
15
packages/audit/src/retention.d.ts
vendored
Normal file
15
packages/audit/src/retention.d.ts
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
import type { RetentionPolicy, AuditLog } from '@brazil-swift-ops/types';
|
||||
declare class RetentionPolicyStore {
|
||||
private policies;
|
||||
add(policy: RetentionPolicy): void;
|
||||
get(dataType: RetentionPolicy['dataType']): RetentionPolicy | undefined;
|
||||
getAll(): RetentionPolicy[];
|
||||
}
|
||||
export declare function getRetentionPolicyStore(): RetentionPolicyStore;
|
||||
export declare function applyRetentionPolicy(log: AuditLog, policy: RetentionPolicy): {
|
||||
shouldArchive: boolean;
|
||||
shouldDelete: boolean;
|
||||
};
|
||||
export declare function enforceRetentionPolicies(): void;
|
||||
export {};
|
||||
//# sourceMappingURL=retention.d.ts.map
|
||||
1
packages/audit/src/retention.d.ts.map
Normal file
1
packages/audit/src/retention.d.ts.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"retention.d.ts","sourceRoot":"","sources":["retention.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAIzE,cAAM,oBAAoB;IACxB,OAAO,CAAC,QAAQ,CAAyB;IAEzC,GAAG,CAAC,MAAM,EAAE,eAAe,GAAG,IAAI;IAIlC,GAAG,CAAC,QAAQ,EAAE,eAAe,CAAC,UAAU,CAAC,GAAG,eAAe,GAAG,SAAS;IAIvE,MAAM,IAAI,eAAe,EAAE;CAG5B;AAID,wBAAgB,uBAAuB,IAAI,oBAAoB,CAE9D;AAED,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,QAAQ,EACb,MAAM,EAAE,eAAe,GACtB;IAAE,aAAa,EAAE,OAAO,CAAC;IAAC,YAAY,EAAE,OAAO,CAAA;CAAE,CAcnD;AAED,wBAAgB,wBAAwB,IAAI,IAAI,CAqB/C"}
|
||||
49
packages/audit/src/retention.js
Normal file
49
packages/audit/src/retention.js
Normal file
@@ -0,0 +1,49 @@
|
||||
import { shouldArchive, shouldDelete } from '@brazil-swift-ops/utils';
|
||||
import { getAuditLogStore } from './logger';
|
||||
class RetentionPolicyStore {
|
||||
policies = [];
|
||||
add(policy) {
|
||||
this.policies.push(policy);
|
||||
}
|
||||
get(dataType) {
|
||||
return this.policies.find((p) => p.dataType === dataType);
|
||||
}
|
||||
getAll() {
|
||||
return [...this.policies];
|
||||
}
|
||||
}
|
||||
const retentionPolicyStore = new RetentionPolicyStore();
|
||||
export function getRetentionPolicyStore() {
|
||||
return retentionPolicyStore;
|
||||
}
|
||||
export function applyRetentionPolicy(log, policy) {
|
||||
if (policy.archivalAfterDays) {
|
||||
const archive = shouldArchive(log.timestamp, policy.archivalAfterDays);
|
||||
if (archive) {
|
||||
return { shouldArchive: true, shouldDelete: false };
|
||||
}
|
||||
}
|
||||
if (policy.autoDelete) {
|
||||
const deleteLog = shouldDelete(log.timestamp, policy.retentionPeriodDays);
|
||||
return { shouldArchive: false, shouldDelete: deleteLog };
|
||||
}
|
||||
return { shouldArchive: false, shouldDelete: false };
|
||||
}
|
||||
export function enforceRetentionPolicies() {
|
||||
const auditLogStore = getAuditLogStore();
|
||||
const policyStore = getRetentionPolicyStore();
|
||||
const allPolicies = policyStore.getAll();
|
||||
const allLogs = auditLogStore.getAll();
|
||||
allLogs.forEach((log) => {
|
||||
const policy = allPolicies.find((p) => p.dataType === 'audit_log' || p.dataType === 'all');
|
||||
if (policy) {
|
||||
const { shouldDelete: shouldDeleteLog } = applyRetentionPolicy(log, policy);
|
||||
if (shouldDeleteLog && policy.autoDelete) {
|
||||
// In production, would actually delete from persistent storage
|
||||
// For now, just mark for deletion
|
||||
console.log(`Log ${log.id} should be deleted per retention policy`);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
//# sourceMappingURL=retention.js.map
|
||||
1
packages/audit/src/retention.js.map
Normal file
1
packages/audit/src/retention.js.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"retention.js","sourceRoot":"","sources":["retention.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAE5C,MAAM,oBAAoB;IAChB,QAAQ,GAAsB,EAAE,CAAC;IAEzC,GAAG,CAAC,MAAuB;QACzB,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC7B,CAAC;IAED,GAAG,CAAC,QAAqC;QACvC,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC;IAC5D,CAAC;IAED,MAAM;QACJ,OAAO,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC5B,CAAC;CACF;AAED,MAAM,oBAAoB,GAAG,IAAI,oBAAoB,EAAE,CAAC;AAExD,MAAM,UAAU,uBAAuB;IACrC,OAAO,oBAAoB,CAAC;AAC9B,CAAC;AAED,MAAM,UAAU,oBAAoB,CAClC,GAAa,EACb,MAAuB;IAEvB,IAAI,MAAM,CAAC,iBAAiB,EAAE,CAAC;QAC7B,MAAM,OAAO,GAAG,aA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QACH,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
|
||||
13
packages/audit/src/versions.d.ts
vendored
Normal file
13
packages/audit/src/versions.d.ts
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
import type { RuleVersion } from '@brazil-swift-ops/types';
|
||||
declare class RuleVersionStore {
|
||||
private versions;
|
||||
add(version: RuleVersion): void;
|
||||
get(version: string): RuleVersion | undefined;
|
||||
getCurrent(): RuleVersion | undefined;
|
||||
getAll(): RuleVersion[];
|
||||
deprecate(version: string, deprecatedDate: Date): void;
|
||||
}
|
||||
export declare function getRuleVersionStore(): RuleVersionStore;
|
||||
export declare function createRuleVersion(version: string, effectiveDate: Date, approvalAuthority: string, description?: string): RuleVersion;
|
||||
export {};
|
||||
//# sourceMappingURL=versions.d.ts.map
|
||||
1
packages/audit/src/versions.d.ts.map
Normal file
1
packages/audit/src/versions.d.ts.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"versions.d.ts","sourceRoot":"","sources":["versions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE3D,cAAM,gBAAgB;IACpB,OAAO,CAAC,QAAQ,CAAqB;IAErC,GAAG,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI;IAI/B,GAAG,CAAC,OAAO,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS;IAI7C,UAAU,IAAI,WAAW,GAAG,SAAS;IAMrC,MAAM,IAAI,WAAW,EAAE;IAIvB,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,IAAI,GAAG,IAAI;CAOvD;AAID,wBAAgB,mBAAmB,IAAI,gBAAgB,CAEtD;AAED,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,MAAM,EACf,aAAa,EAAE,IAAI,EACnB,iBAAiB,EAAE,MAAM,EACzB,WAAW,CAAC,EAAE,MAAM,GACnB,WAAW,CAWb"}
|
||||
40
packages/audit/src/versions.js
Normal file
40
packages/audit/src/versions.js
Normal file
@@ -0,0 +1,40 @@
|
||||
class RuleVersionStore {
|
||||
versions = [];
|
||||
add(version) {
|
||||
this.versions.push(version);
|
||||
}
|
||||
get(version) {
|
||||
return this.versions.find((v) => v.version === version);
|
||||
}
|
||||
getCurrent() {
|
||||
return this.versions
|
||||
.filter((v) => !v.deprecated)
|
||||
.sort((a, b) => b.effectiveDate.getTime() - a.effectiveDate.getTime())[0];
|
||||
}
|
||||
getAll() {
|
||||
return [...this.versions];
|
||||
}
|
||||
deprecate(version, deprecatedDate) {
|
||||
const versionObj = this.versions.find((v) => v.version === version);
|
||||
if (versionObj) {
|
||||
versionObj.deprecated = true;
|
||||
versionObj.deprecatedDate = deprecatedDate;
|
||||
}
|
||||
}
|
||||
}
|
||||
const ruleVersionStore = new RuleVersionStore();
|
||||
export function getRuleVersionStore() {
|
||||
return ruleVersionStore;
|
||||
}
|
||||
export function createRuleVersion(version, effectiveDate, approvalAuthority, description) {
|
||||
const ruleVersion = {
|
||||
version,
|
||||
effectiveDate,
|
||||
approvalAuthority,
|
||||
deprecated: false,
|
||||
description,
|
||||
};
|
||||
ruleVersionStore.add(ruleVersion);
|
||||
return ruleVersion;
|
||||
}
|
||||
//# sourceMappingURL=versions.js.map
|
||||
1
packages/audit/src/versions.js.map
Normal file
1
packages/audit/src/versions.js.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"versions.js","sourceRoot":"","sources":["versions.ts"],"names":[],"mappings":"AAEA,MAAM,gBAAgB;IACZ,QAAQ,GAAkB,EAAE,CAAC;IAErC,GAAG,CAAC,OAAoB;QACtB,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC9B,CAAC;IAED,GAAG,CAAC,OAAe;QACjB,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,KAAK,OAAO,CAAC,CAAC;IAC1D,CAAC;IAED,UAAU;QACR,OAAO,IAAI,CAAC,QAAQ;aACjB,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC;aAC5B,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,aAAa,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9E,CAAC;IAED,MAAM;QACJ,OAAO,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC5B,CAAC;IAED,SAAS,CAAC,OAAe,EAAE,cAAoB;QAC7C,MAAM,UAAU,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,KAAK,OAAO,CAAC,CAAC;QACpE,IAAI,UAAU,EAAE,CAAC;YACf,UAAU,CAAC,UAAU,GAAG,IAAI,CAAC;YAC7B,UAAU,CAAC,cAAc,GAAG,cAAc,CAAC;QAC7C,CAAC;IACH,CAAC;CACF;AAED,MAAM,gBAAgB,GAAG,IAAI,gBAAgB,EAAE,CAAC;AAEhD,MAAM,UAAU,mBAAmB;IACjC,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAED,MAAM,UAAU,iBAAiB,CAC/B,OAAe,EACf,aAAmB,EACnB,iBAAyB,EACzB,WAAoB;IAEpB,MAAM,WAAW,GAAgB;QAC/B,OAAO;QACP,aAAa;QACb,iBAAiB;QACjB,UAAU,EAAE,KAAK;QACjB,WAAW;KACZ,CAAC;IAEF,gBAAgB,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IAClC,OAAO,WAAW,CAAC;AACrB,CAAC"}
|
||||
5
packages/iso20022/src/exporter.d.ts
vendored
Normal file
5
packages/iso20022/src/exporter.d.ts
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
import type { ISO20022Message } from '@brazil-swift-ops/types';
|
||||
export declare function exportToJSON(message: ISO20022Message): string;
|
||||
export declare function exportToXML(message: ISO20022Message): string;
|
||||
export declare function exportMessage(message: ISO20022Message, format?: 'json' | 'xml'): string;
|
||||
//# sourceMappingURL=exporter.d.ts.map
|
||||
1
packages/iso20022/src/exporter.d.ts.map
Normal file
1
packages/iso20022/src/exporter.d.ts.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"exporter.d.ts","sourceRoot":"","sources":["exporter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE/D,wBAAgB,YAAY,CAAC,OAAO,EAAE,eAAe,GAAG,MAAM,CAE7D;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,eAAe,GAAG,MAAM,CAa5D;AAED,wBAAgB,aAAa,CAC3B,OAAO,EAAE,eAAe,EACxB,MAAM,GAAE,MAAM,GAAG,KAAc,GAC9B,MAAM,CASR"}
|
||||
28
packages/iso20022/src/exporter.js
Normal file
28
packages/iso20022/src/exporter.js
Normal file
@@ -0,0 +1,28 @@
|
||||
export function exportToJSON(message) {
|
||||
return JSON.stringify(message, null, 2);
|
||||
}
|
||||
export function exportToXML(message) {
|
||||
// Simplified XML export - in production would use proper XML serialization
|
||||
const xml = `<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Document xmlns="urn:iso:std:iso:20022:tech:xsd:${message.messageType}">
|
||||
<${message.messageType}>
|
||||
<GrpHdr>
|
||||
<MsgId>${message.groupHeader.messageIdentification}</MsgId>
|
||||
<CreDtTm>${message.groupHeader.creationDateTime.toISOString()}</CreDtTm>
|
||||
<NbOfTxs>${message.groupHeader.numberOfTransactions}</NbOfTxs>
|
||||
</GrpHdr>
|
||||
</${message.messageType}>
|
||||
</Document>`;
|
||||
return xml;
|
||||
}
|
||||
export function exportMessage(message, format = 'json') {
|
||||
switch (format) {
|
||||
case 'json':
|
||||
return exportToJSON(message);
|
||||
case 'xml':
|
||||
return exportToXML(message);
|
||||
default:
|
||||
throw new Error(`Unsupported export format: ${format}`);
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=exporter.js.map
|
||||
1
packages/iso20022/src/exporter.js.map
Normal file
1
packages/iso20022/src/exporter.js.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"exporter.js","sourceRoot":"","sources":["exporter.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,YAAY,CAAC,OAAwB;IACnD,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;AAC1C,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,OAAwB;IAClD,2EAA2E;IAC3E,MAAM,GAAG,GAAG;kDACoC,OAAO,CAAC,WAAW;KAChE,OAAO,CAAC,WAAW;;eAET,OAAO,CAAC,WAAW,CAAC,qBAAqB;iBACvC,OAAO,CAAC,WAAW,CAAC,gBAAgB,CAAC,WAAW,EAAE;iBAClD,OAAO,CAAC,WAAW,CAAC,oBAAoB;;MAEnD,OAAO,CAAC,WAAW;YACb,CAAC;IACX,OAAO,GAAG,CAAC;AACb,CAAC;AAED,MAAM,UAAU,aAAa,CAC3B,OAAwB,EACxB,SAAyB,MAAM;IAE/B,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,MAAM;YACT,OAAO,YAAY,CAAC,OAAO,CAAC,CAAC;QAC/B,KAAK,KAAK;YACR,OAAO,WAAW,CAAC,OAAO,CAAC,CAAC;QAC9B;YACE,MAAM,IAAI,KAAK,CAAC,8BAA8B,MAAM,EAAE,CAAC,CAAC;IAC5D,CAAC;AACH,CAAC"}
|
||||
6
packages/iso20022/src/index.d.ts
vendored
Normal file
6
packages/iso20022/src/index.d.ts
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
export * from './pacs008';
|
||||
export * from './pacs009';
|
||||
export * from './pain001';
|
||||
export * from './mt-mapper';
|
||||
export * from './exporter';
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
1
packages/iso20022/src/index.d.ts.map
Normal file
1
packages/iso20022/src/index.d.ts.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC"}
|
||||
6
packages/iso20022/src/index.js
Normal file
6
packages/iso20022/src/index.js
Normal file
@@ -0,0 +1,6 @@
|
||||
export * from './pacs008';
|
||||
export * from './pacs009';
|
||||
export * from './pain001';
|
||||
export * from './mt-mapper';
|
||||
export * from './exporter';
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
packages/iso20022/src/index.js.map
Normal file
1
packages/iso20022/src/index.js.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC"}
|
||||
21
packages/iso20022/src/mt-mapper.d.ts
vendored
Normal file
21
packages/iso20022/src/mt-mapper.d.ts
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
import type { Transaction, ISO20022Message } from '@brazil-swift-ops/types';
|
||||
export interface MT103Message {
|
||||
field20: string;
|
||||
field23B: string;
|
||||
field32A: string;
|
||||
field50A?: string;
|
||||
field52A?: string;
|
||||
field53A?: string;
|
||||
field54A?: string;
|
||||
field56A?: string;
|
||||
field57A?: string;
|
||||
field59: string;
|
||||
field70: string;
|
||||
field71A: string;
|
||||
field72: string;
|
||||
}
|
||||
export declare function mapMT103ToTransaction(mt103: MT103Message): Transaction;
|
||||
export declare function mapTransactionToMT103(transaction: Transaction): MT103Message;
|
||||
export declare function convertMT103ToISO20022(mt103: MT103Message, targetType?: 'pacs.008' | 'pacs.009' | 'pain.001', version?: string): ISO20022Message;
|
||||
export declare function convertISO20022ToMT103(message: ISO20022Message): MT103Message;
|
||||
//# sourceMappingURL=mt-mapper.d.ts.map
|
||||
1
packages/iso20022/src/mt-mapper.d.ts.map
Normal file
1
packages/iso20022/src/mt-mapper.d.ts.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"mt-mapper.d.ts","sourceRoot":"","sources":["mt-mapper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAK5E,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,YAAY,GAAG,WAAW,CAuBtE;AAED,wBAAgB,qBAAqB,CAAC,WAAW,EAAE,WAAW,GAAG,YAAY,CAc5E;AAED,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,YAAY,EACnB,UAAU,GAAE,UAAU,GAAG,UAAU,GAAG,UAAuB,EAC7D,OAAO,CAAC,EAAE,MAAM,GACf,eAAe,CAWjB;AAED,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,eAAe,GAAG,YAAY,CAqB7E"}
|
||||
73
packages/iso20022/src/mt-mapper.js
Normal file
73
packages/iso20022/src/mt-mapper.js
Normal file
@@ -0,0 +1,73 @@
|
||||
import { createPacs008Message } from './pacs008';
|
||||
import { createPacs009Message } from './pacs009';
|
||||
import { createPain001Message } from './pain001';
|
||||
export function mapMT103ToTransaction(mt103) {
|
||||
const [valueDate, currency, amountStr] = mt103.field32A.split(/(\d{6})([A-Z]{3})([\d,]+)/).filter(Boolean);
|
||||
const amount = parseFloat(amountStr.replace(',', '.'));
|
||||
return {
|
||||
id: mt103.field20,
|
||||
direction: 'outbound',
|
||||
amount,
|
||||
currency: currency || 'USD',
|
||||
orderingCustomer: {
|
||||
name: mt103.field50A || '',
|
||||
country: 'BR',
|
||||
},
|
||||
beneficiary: {
|
||||
name: mt103.field59,
|
||||
country: 'BR',
|
||||
},
|
||||
purposeOfPayment: mt103.field70,
|
||||
swiftReference: mt103.field20,
|
||||
status: 'pending',
|
||||
createdAt: new Date(),
|
||||
updatedAt: new Date(),
|
||||
};
|
||||
}
|
||||
export function mapTransactionToMT103(transaction) {
|
||||
const valueDate = new Date().toISOString().slice(0, 10).replace(/-/g, '');
|
||||
const amountStr = transaction.amount.toFixed(2).replace('.', ',');
|
||||
return {
|
||||
field20: transaction.swiftReference || transaction.id,
|
||||
field23B: 'CRED',
|
||||
field32A: `${valueDate}${transaction.currency}${amountStr}`,
|
||||
field50A: transaction.orderingCustomer.name,
|
||||
field59: transaction.beneficiary.name,
|
||||
field70: transaction.purposeOfPayment || '',
|
||||
field71A: 'OUR',
|
||||
field72: `//${transaction.fxContractId || ''}`,
|
||||
};
|
||||
}
|
||||
export function convertMT103ToISO20022(mt103, targetType = 'pacs.008', version) {
|
||||
const transaction = mapMT103ToTransaction(mt103);
|
||||
switch (targetType) {
|
||||
case 'pacs.008':
|
||||
return createPacs008Message(transaction, version);
|
||||
case 'pacs.009':
|
||||
return createPacs009Message(transaction, version);
|
||||
case 'pain.001':
|
||||
return createPain001Message(transaction, version);
|
||||
}
|
||||
}
|
||||
export function convertISO20022ToMT103(message) {
|
||||
// This is a simplified conversion - in production would need full mapping
|
||||
const transaction = {
|
||||
id: message.groupHeader.messageIdentification,
|
||||
direction: 'outbound',
|
||||
amount: message.groupHeader.controlSum || 0,
|
||||
currency: 'USD',
|
||||
orderingCustomer: {
|
||||
name: message.groupHeader.initiatingParty.name || '',
|
||||
country: 'BR',
|
||||
},
|
||||
beneficiary: {
|
||||
name: '',
|
||||
country: 'BR',
|
||||
},
|
||||
status: 'pending',
|
||||
createdAt: message.creationDateTime,
|
||||
updatedAt: new Date(),
|
||||
};
|
||||
return mapTransactionToMT103(transaction);
|
||||
}
|
||||
//# sourceMappingURL=mt-mapper.js.map
|
||||
1
packages/iso20022/src/mt-mapper.js.map
Normal file
1
packages/iso20022/src/mt-mapper.js.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"mt-mapper.js","sourceRoot":"","sources":["mt-mapper.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAkBjD,MAAM,UAAU,qBAAqB,CAAC,KAAmB;IACvD,MAAM,CAAC,SAAS,EAAE,QAAQ,EAAE,SAAS,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,2BAA2B,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAC3G,MAAM,MAAM,GAAG,UAAU,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;IAEvD,OAAO;QACL,EAAE,EAAE,KAAK,CAAC,OAAO;QACjB,SAAS,EAAE,UAAU;QACrB,MAAM;QACN,QAAQ,EAAE,QAAQ,IAAI,KAAK;QAC3B,gBAAgB,EAAE;YAChB,IAAI,EAAE,KAAK,CAAC,QAAQ,IAAI,EAAE;YAC1B,OAAO,EAAE,IAAI;SACd;QACD,WAAW,EAAE;YACX,IAAI,EAAE,KAAK,CAAC,OAAO;YACn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oBAAoB,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;QACpD,KAAK,UAAU;YACb,OAAO,oBAAoB,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IACtD,CAAC;AACH,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,OAAwB;IAC7D,0EAA0E;IAC1E,MAAM,WAAW,GAAgB;QAC/B,EAAE,EAAE,OAAO,CAAC,WAAW,CAAC,qBAAqB;QAC7C,SAAS,EAAE,UAAU;QACrB,MAAM,EAAE,OAAO,CAAC,WAAW,CAAC,UAAU,IAAI,CAAC;QAC3C,QAAQ,EAAE,KAAK;QACf,gBAAgB,EAAE;YAChB,IAAI,EAAE,OAAO,CAAC,WAAW,CAAC,eAAe,CAAC,IAAI,IAAI,EAAE;YACpD,OAAO,EAAE,IAAI;SACd;QACD,WAAW,EAAE;YACX,IAAI,EAAE,EAAE;YACR,OAAO,EAAE,IAAI;SACd;QACD,MAAM,EAAE,SAAS;QACjB,SAAS,EAAE,OAAO,CAAC,gBAAgB;QACnC,SAAS,EAAE,IAAI,IAAI,EAAE;KACtB,CAAC;IAEF,OAAO,qBAAqB,CAAC,WAAW,CAAC,CAAC;AAC5C,CAAC"}
|
||||
9
packages/risk-models/src/capital.d.ts
vendored
Normal file
9
packages/risk-models/src/capital.d.ts
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
import type { Transaction, CapitalImpact, RiskWeight } from '@brazil-swift-ops/types';
|
||||
export interface CapitalConfig {
|
||||
capitalRatio: number;
|
||||
capitalBuffer: number;
|
||||
riskWeights: RiskWeight[];
|
||||
}
|
||||
export declare function getRiskWeight(transaction: Transaction, riskWeights: RiskWeight[]): number;
|
||||
export declare function calculateCapitalImpact(transaction: Transaction, config: CapitalConfig): CapitalImpact;
|
||||
//# sourceMappingURL=capital.d.ts.map
|
||||
1
packages/risk-models/src/capital.d.ts.map
Normal file
1
packages/risk-models/src/capital.d.ts.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"capital.d.ts","sourceRoot":"","sources":["capital.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAEtF,MAAM,WAAW,aAAa;IAC5B,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,UAAU,EAAE,CAAC;CAC3B;AAED,wBAAgB,aAAa,CAAC,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU,EAAE,GAAG,MAAM,CAGzF;AAED,wBAAgB,sBAAsB,CAAC,WAAW,EAAE,WAAW,EAAE,MAAM,EAAE,aAAa,GAAG,aAAa,CA2BrG"}
|
||||
33
packages/risk-models/src/capital.js
Normal file
33
packages/risk-models/src/capital.js
Normal file
@@ -0,0 +1,33 @@
|
||||
import Decimal from 'decimal.js';
|
||||
export function getRiskWeight(transaction, riskWeights) {
|
||||
const paymentWeight = riskWeights.find((w) => w.category === 'payment');
|
||||
return paymentWeight?.weight ?? 0.1;
|
||||
}
|
||||
export function calculateCapitalImpact(transaction, config) {
|
||||
const riskWeight = getRiskWeight(transaction, config.riskWeights);
|
||||
const transactionDecimal = new Decimal(transaction.amount);
|
||||
const weightDecimal = new Decimal(riskWeight);
|
||||
const rwaDecimal = transactionDecimal.mul(weightDecimal);
|
||||
const riskWeightedAssets = rwaDecimal.toNumber();
|
||||
const ratioDecimal = new Decimal(config.capitalRatio);
|
||||
const capitalConsumedDecimal = rwaDecimal.mul(ratioDecimal);
|
||||
const capitalConsumed = capitalConsumedDecimal.toNumber();
|
||||
const capitalBufferAfter = config.capitalBuffer - capitalConsumed;
|
||||
const complianceCheck = capitalBufferAfter >= 0;
|
||||
return {
|
||||
transactionId: transaction.id,
|
||||
transactionAmount: transaction.amount,
|
||||
currency: transaction.currency,
|
||||
riskWeight,
|
||||
riskWeightedAssets,
|
||||
capitalRatio: config.capitalRatio,
|
||||
capitalConsumed,
|
||||
capitalBufferBefore: config.capitalBuffer,
|
||||
capitalBufferAfter,
|
||||
complianceCheck,
|
||||
rationale: complianceCheck
|
||||
? `Capital consumed: ${capitalConsumed.toFixed(2)}. Capital buffer after transaction: ${capitalBufferAfter.toFixed(2)} (above minimum).`
|
||||
: `Capital consumed: ${capitalConsumed.toFixed(2)}. Capital buffer after transaction: ${capitalBufferAfter.toFixed(2)} (below minimum). Transaction may be blocked.`,
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=capital.js.map
|
||||
1
packages/risk-models/src/capital.js.map
Normal file
1
packages/risk-models/src/capital.js.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"capital.js","sourceRoot":"","sources":["capital.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,YAAY,CAAC;AASjC,MAAM,UAAU,aAAa,CAAC,WAAwB,EAAE,WAAyB;IAC/E,MAAM,aAAa,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC;IACxE,OAAO,aAAa,EAAE,MAAM,IAAI,GAAG,CAAC;AACtC,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,WAAwB,EAAE,MAAqB;IACpF,MAAM,UAAU,GAAG,aAAa,CAAC,WAAW,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC;IAClE,MAAM,kBAAkB,GAAG,IAAI,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IAC3D,MAAM,aAAa,GAAG,IAAI,OAAO,CAAC,UAAU,CAAC,CAAC;IAC9C,MAAM,UAAU,GAAG,kBAAkB,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;IACzD,MAAM,kBAAkB,GAAG,UAAU,CAAC,QAAQ,EAAE,CAAC;IACjD,MAAM,YAAY,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;IACtD,MAAM,sBAAsB,GAAG,UAAU,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IAC5D,MAAM,eAAe,GAAG,sBAAsB,CAAC,QAAQ,EAAE,CAAC;IAC1D,MAAM,kBAAkB,GAAG,MAAM,CAAC,aAAa,GAAG,eAAe,CAAC;IAClE,MAAM,eAAe,GAAG,kBAAkB,IAAI,CAAC,CAAC;IAEhD,OAAO;QACL,aAAa,EAAE,WAAW,CAAC,EAAE;QAC7B,iBAAiB,EAAE,WAAW,CAAC,MAAM;QACrC,QAAQ,EAAE,WAAW,CAAC,QAAQ;QAC9B,UAAU;QACV,kBAAkB;QAClB,YAAY,EAAE,MAAM,CAAC,YAAY;QACjC,eAAe;QACf,mBAAmB,EAAE,MAAM,CAAC,aAAa;QACzC,kBAAkB;QAClB,eAAe;QACf,SAAS,EAAE,eAAe;YACxB,CAAC,CAAC,qBAAqB,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC,uCAAuC,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAC,mBAAmB;YACxI,CAAC,CAAC,qBAAqB,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC,uCAAuC,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAC,+CAA+C;KACvK,CAAC;AACJ,CAAC"}
|
||||
6
packages/risk-models/src/escalation.d.ts
vendored
Normal file
6
packages/risk-models/src/escalation.d.ts
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
import type { EscalationState, EscalationLevel, RuleDecision } from '@brazil-swift-ops/types';
|
||||
export declare function determineEscalationLevel(decision: RuleDecision, hasLiquidityIssue: boolean, hasCapitalIssue: boolean, hasLCRIssue: boolean): EscalationLevel;
|
||||
export declare function createEscalationState(transactionId: string, level: EscalationLevel, reason: string): EscalationState;
|
||||
export declare function escalate(currentState: EscalationState, newLevel: EscalationLevel, reason: string): EscalationState;
|
||||
export declare function approveEscalation(state: EscalationState, approvedBy: string): EscalationState;
|
||||
//# sourceMappingURL=escalation.d.ts.map
|
||||
1
packages/risk-models/src/escalation.d.ts.map
Normal file
1
packages/risk-models/src/escalation.d.ts.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"escalation.d.ts","sourceRoot":"","sources":["escalation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,eAAe,EACf,YAAY,EACb,MAAM,yBAAyB,CAAC;AAEjC,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,YAAY,EACtB,iBAAiB,EAAE,OAAO,EAC1B,eAAe,EAAE,OAAO,EACxB,WAAW,EAAE,OAAO,GACnB,eAAe,CAcjB;AAED,wBAAgB,qBAAqB,CACnC,aAAa,EAAE,MAAM,EACrB,KAAK,EAAE,eAAe,EACtB,MAAM,EAAE,MAAM,GACb,eAAe,CAQjB;AAED,wBAAgB,QAAQ,CACtB,YAAY,EAAE,eAAe,EAC7B,QAAQ,EAAE,eAAe,EACzB,MAAM,EAAE,MAAM,GACb,eAAe,CAQjB;AAED,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,eAAe,EACtB,UAAU,EAAE,MAAM,GACjB,eAAe,CAOjB"}
|
||||
39
packages/risk-models/src/escalation.js
Normal file
39
packages/risk-models/src/escalation.js
Normal file
@@ -0,0 +1,39 @@
|
||||
export function determineEscalationLevel(decision, hasLiquidityIssue, hasCapitalIssue, hasLCRIssue) {
|
||||
if (decision === 'Allow') {
|
||||
return 'Allow';
|
||||
}
|
||||
if (hasLiquidityIssue || hasCapitalIssue || hasLCRIssue) {
|
||||
return 'TreasuryApproval';
|
||||
}
|
||||
if (decision === 'Escalate') {
|
||||
return 'ComplianceReview';
|
||||
}
|
||||
return 'Hold';
|
||||
}
|
||||
export function createEscalationState(transactionId, level, reason) {
|
||||
return {
|
||||
transactionId,
|
||||
currentLevel: level,
|
||||
reason,
|
||||
escalatedAt: new Date(),
|
||||
approvalRequired: level !== 'Allow',
|
||||
};
|
||||
}
|
||||
export function escalate(currentState, newLevel, reason) {
|
||||
return {
|
||||
...currentState,
|
||||
previousLevel: currentState.currentLevel,
|
||||
currentLevel: newLevel,
|
||||
reason,
|
||||
escalatedAt: new Date(),
|
||||
};
|
||||
}
|
||||
export function approveEscalation(state, approvedBy) {
|
||||
return {
|
||||
...state,
|
||||
approvalRequired: false,
|
||||
approvedBy,
|
||||
approvedAt: new Date(),
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=escalation.js.map
|
||||
1
packages/risk-models/src/escalation.js.map
Normal file
1
packages/risk-models/src/escalation.js.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"escalation.js","sourceRoot":"","sources":["escalation.ts"],"names":[],"mappings":"AAMA,MAAM,UAAU,wBAAwB,CACtC,QAAsB,EACtB,iBAA0B,EAC1B,eAAwB,EACxB,WAAoB;IAEpB,IAAI,QAAQ,KAAK,OAAO,EAAE,CAAC;QACzB,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,IAAI,iBAAiB,IAAI,eAAe,IAAI,WAAW,EAAE,CAAC;QACxD,OAAO,kBAAkB,CAAC;IAC5B,CAAC;IAED,IAAI,QAAQ,KAAK,UAAU,EAAE,CAAC;QAC5B,OAAO,kBAAkB,CAAC;IAC5B,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,UAAU,qBAAqB,CACnC,aAAqB,EACrB,KAAsB,EACtB,MAAc;IAEd,OAAO;QACL,aAAa;QACb,YAAY,EAAE,KAAK;QACnB,MAAM;QACN,WAAW,EAAE,IAAI,IAAI,EAAE;QACvB,gBAAgB,EAAE,KAAK,KAAK,OAAO;KACpC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,QAAQ,CACtB,YAA6B,EAC7B,QAAyB,EACzB,MAAc;IAEd,OAAO;QACL,GAAG,YAAY;QACf,aAAa,EAAE,YAAY,CAAC,YAAY;QACxC,YAAY,EAAE,QAAQ;QACtB,MAAM;QACN,WAAW,EAAE,IAAI,IAAI,EAAE;KACxB,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,iBAAiB,CAC/B,KAAsB,EACtB,UAAkB;IAElB,OAAO;QACL,GAAG,KAAK;QACR,gBAAgB,EAAE,KAAK;QACvB,UAAU;QACV,UAAU,EAAE,IAAI,IAAI,EAAE;KACvB,CAAC;AACJ,CAAC"}
|
||||
6
packages/risk-models/src/index.d.ts
vendored
Normal file
6
packages/risk-models/src/index.d.ts
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
export * from './reserves';
|
||||
export * from './capital';
|
||||
export * from './lcr';
|
||||
export * from './escalation';
|
||||
export * from './risk-weights';
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
1
packages/risk-models/src/index.d.ts.map
Normal file
1
packages/risk-models/src/index.d.ts.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,OAAO,CAAC;AACtB,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC"}
|
||||
6
packages/risk-models/src/index.js
Normal file
6
packages/risk-models/src/index.js
Normal file
@@ -0,0 +1,6 @@
|
||||
export * from './reserves';
|
||||
export * from './capital';
|
||||
export * from './lcr';
|
||||
export * from './escalation';
|
||||
export * from './risk-weights';
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
packages/risk-models/src/index.js.map
Normal file
1
packages/risk-models/src/index.js.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,OAAO,CAAC;AACtB,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC"}
|
||||
9
packages/risk-models/src/lcr.d.ts
vendored
Normal file
9
packages/risk-models/src/lcr.d.ts
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
import type { Transaction, LCRImpact } from '@brazil-swift-ops/types';
|
||||
export interface LCRConfig {
|
||||
hqla: number;
|
||||
netOutflows: number;
|
||||
minimumLCR: number;
|
||||
runoffFactor: number;
|
||||
}
|
||||
export declare function calculateLCRImpact(transaction: Transaction, config: LCRConfig): LCRImpact;
|
||||
//# sourceMappingURL=lcr.d.ts.map
|
||||
1
packages/risk-models/src/lcr.d.ts.map
Normal file
1
packages/risk-models/src/lcr.d.ts.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"lcr.d.ts","sourceRoot":"","sources":["lcr.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAGtE,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,GAAG,SAAS,CAgCzF"}
|
||||
35
packages/risk-models/src/lcr.js
Normal file
35
packages/risk-models/src/lcr.js
Normal file
@@ -0,0 +1,35 @@
|
||||
import Decimal from 'decimal.js';
|
||||
import { getDefaultConverter } from '@brazil-swift-ops/utils';
|
||||
export function calculateLCRImpact(transaction, config) {
|
||||
const converter = getDefaultConverter();
|
||||
const brlAmount = converter.convert(transaction.amount, transaction.currency, 'BRL');
|
||||
const transactionDecimal = new Decimal(brlAmount);
|
||||
const runoffDecimal = new Decimal(config.runoffFactor);
|
||||
const outflowStressDecimal = transactionDecimal.mul(runoffDecimal);
|
||||
const outflowStress = outflowStressDecimal.toNumber();
|
||||
const netOutflowsAfter = config.netOutflows + outflowStress;
|
||||
const hqlaDecimal = new Decimal(config.hqla);
|
||||
const outflowsBeforeDecimal = new Decimal(config.netOutflows);
|
||||
const outflowsAfterDecimal = new Decimal(netOutflowsAfter);
|
||||
const lcrBefore = outflowsBeforeDecimal.gt(0) ? hqlaDecimal.div(outflowsBeforeDecimal).toNumber() : Infinity;
|
||||
const lcrAfter = outflowsAfterDecimal.gt(0) ? hqlaDecimal.div(outflowsAfterDecimal).toNumber() : Infinity;
|
||||
const complianceCheck = lcrAfter >= config.minimumLCR;
|
||||
return {
|
||||
transactionId: transaction.id,
|
||||
transactionAmount: transaction.amount,
|
||||
currency: transaction.currency,
|
||||
runoffFactor: config.runoffFactor,
|
||||
outflowStress,
|
||||
hqlaBefore: config.hqla,
|
||||
netOutflowsBefore: config.netOutflows,
|
||||
netOutflowsAfter,
|
||||
lcrBefore,
|
||||
lcrAfter,
|
||||
minimumLCR: config.minimumLCR,
|
||||
complianceCheck,
|
||||
rationale: complianceCheck
|
||||
? `LCR after transaction: ${(lcrAfter * 100).toFixed(2)}% (above minimum ${(config.minimumLCR * 100).toFixed(2)}%).`
|
||||
: `LCR after transaction: ${(lcrAfter * 100).toFixed(2)}% (below minimum ${(config.minimumLCR * 100).toFixed(2)}%). Transaction may be blocked.`,
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=lcr.js.map
|
||||
1
packages/risk-models/src/lcr.js.map
Normal file
1
packages/risk-models/src/lcr.js.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"lcr.js","sourceRoot":"","sources":["lcr.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,YAAY,CAAC;AAEjC,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAS9D,MAAM,UAAU,kBAAkB,CAAC,WAAwB,EAAE,MAAiB;IAC5E,MAAM,SAAS,GAAG,mBAAmB,EAAE,CAAC;IACxC,MAAM,SAAS,GAAG,SAAS,CAAC,OAAO,CAAC,WAAW,CAAC,MAAM,EAAE,WAAW,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IACrF,MAAM,kBAAkB,GAAG,IAAI,OAAO,CAAC,SAAS,CAAC,CAAC;IAClD,MAAM,aAAa,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;IACvD,MAAM,oBAAoB,GAAG,kBA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AoB,CAAC,MAAM,CAAC,UAAU,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK;YACpH,CAAC,CAAC,0BAA0B,CAAC,QAAQ,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,oBAAoB,CAAC,MAAM,CAAC,UAAU,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,iCAAiC;KACnJ,CAAC;AACJ,CAAC"}
|
||||
8
packages/risk-models/src/reserves.d.ts
vendored
Normal file
8
packages/risk-models/src/reserves.d.ts
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
import type { Transaction, ReserveImpact } from '@brazil-swift-ops/types';
|
||||
export interface ReserveConfig {
|
||||
reserveRatio: number;
|
||||
availableLiquidity: number;
|
||||
requiredReserves: number;
|
||||
}
|
||||
export declare function calculateReserveImpact(transaction: Transaction, config: ReserveConfig): ReserveImpact;
|
||||
//# sourceMappingURL=reserves.d.ts.map
|
||||
1
packages/risk-models/src/reserves.d.ts.map
Normal file
1
packages/risk-models/src/reserves.d.ts.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"reserves.d.ts","sourceRoot":"","sources":["reserves.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAG1E,MAAM,WAAW,aAAa;IAC5B,YAAY,EAAE,MAAM,CAAC;IACrB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED,wBAAgB,sBAAsB,CAAC,WAAW,EAAE,WAAW,EAAE,MAAM,EAAE,aAAa,GAAG,aAAa,CAwBrG"}
|
||||
27
packages/risk-models/src/reserves.js
Normal file
27
packages/risk-models/src/reserves.js
Normal file
@@ -0,0 +1,27 @@
|
||||
import Decimal from 'decimal.js';
|
||||
import { getDefaultConverter } from '@brazil-swift-ops/utils';
|
||||
export function calculateReserveImpact(transaction, config) {
|
||||
const converter = getDefaultConverter();
|
||||
const brlAmount = converter.convert(transaction.amount, transaction.currency, 'BRL');
|
||||
const transactionDecimal = new Decimal(brlAmount);
|
||||
const ratioDecimal = new Decimal(config.reserveRatio);
|
||||
const reserveImpactDecimal = transactionDecimal.mul(ratioDecimal);
|
||||
const reserveImpact = reserveImpactDecimal.toNumber();
|
||||
const availableLiquidityAfter = config.availableLiquidity - brlAmount;
|
||||
const complianceCheck = availableLiquidityAfter >= config.requiredReserves;
|
||||
return {
|
||||
transactionId: transaction.id,
|
||||
transactionAmount: transaction.amount,
|
||||
currency: transaction.currency,
|
||||
reserveRatio: config.reserveRatio,
|
||||
reserveImpact,
|
||||
availableLiquidityBefore: config.availableLiquidity,
|
||||
availableLiquidityAfter,
|
||||
requiredReserves: config.requiredReserves,
|
||||
complianceCheck,
|
||||
rationale: complianceCheck
|
||||
? `Reserve impact: ${reserveImpact.toFixed(2)} BRL. Available liquidity after transaction: ${availableLiquidityAfter.toFixed(2)} BRL (above required ${config.requiredReserves.toFixed(2)} BRL).`
|
||||
: `Reserve impact: ${reserveImpact.toFixed(2)} BRL. Available liquidity after transaction: ${availableLiquidityAfter.toFixed(2)} BRL (below required ${config.requiredReserves.toFixed(2)} BRL). Transaction may be blocked.`,
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=reserves.js.map
|
||||
1
packages/risk-models/src/reserves.js.map
Normal file
1
packages/risk-models/src/reserves.js.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"reserves.js","sourceRoot":"","sources":["reserves.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,YAAY,CAAC;AAEjC,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAQ9D,MAAM,UAAU,sBAAsB,CAAC,WAAwB,EAAE,MAAqB;IACpF,MAAM,SAAS,GAAG,mBAAmB,EAAE,CAAC;IACxC,MAAM,SAAS,GAAG,SAAS,CAAC,OAAO,CAAC,WAAW,CAAC,MAAM,EAAE,WAA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skWeight, RiskWeightTable } from '@brazil-swift-ops/types';
|
||||
export declare const DEFAULT_RISK_WEIGHTS: RiskWeight[];
|
||||
export declare function createRiskWeightTable(version?: string, effectiveDate?: Date): RiskWeightTable;
|
||||
//# sourceMappingURL=risk-weights.d.ts.map
|
||||
1
packages/risk-models/src/risk-weights.d.ts.map
Normal file
1
packages/risk-models/src/risk-weights.d.ts.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"risk-weights.d.ts","sourceRoot":"","sources":["risk-weights.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE3E,eAAO,MAAM,oBAAoB,EAAE,UAAU,EAsB5C,CAAC;AAEF,wBAAgB,qBAAqB,CACnC,OAAO,GAAE,MAAgB,EACzB,aAAa,GAAE,IAAiB,GAC/B,eAAe,CAOjB"}
|
||||
32
packages/risk-models/src/risk-weights.js
Normal file
32
packages/risk-models/src/risk-weights.js
Normal file
@@ -0,0 +1,32 @@
|
||||
export const DEFAULT_RISK_WEIGHTS = [
|
||||
{
|
||||
category: 'payment',
|
||||
description: 'Payment transactions',
|
||||
weight: 0.1, // 10%
|
||||
minWeight: 0.0,
|
||||
maxWeight: 0.2,
|
||||
},
|
||||
{
|
||||
category: 'fx_settlement',
|
||||
description: 'FX settlement transactions',
|
||||
weight: 0.35, // 35%
|
||||
minWeight: 0.2,
|
||||
maxWeight: 0.5,
|
||||
},
|
||||
{
|
||||
category: 'nostro_exposure',
|
||||
description: 'Nostro account exposure',
|
||||
weight: 1.0, // 100%
|
||||
minWeight: 0.5,
|
||||
maxWeight: 1.0,
|
||||
},
|
||||
];
|
||||
export function createRiskWeightTable(version = '1.0.0', effectiveDate = new Date()) {
|
||||
return {
|
||||
id: `RWT-${version}`,
|
||||
version,
|
||||
effectiveDate,
|
||||
weights: DEFAULT_RISK_WEIGHTS,
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=risk-weights.js.map
|
||||
1
packages/risk-models/src/risk-weights.js.map
Normal file
1
packages/risk-models/src/risk-weights.js.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"risk-weights.js","sourceRoot":"","sources":["risk-weights.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,oBAAoB,GAAiB;IAChD;QACE,QAAQ,EAAE,SAAS;QACnB,WAAW,EAAE,sBAAsB;QACnC,MAAM,EAAE,GAAG,EAAE,MAAM;QACnB,SAAS,EAAE,GAAG;QACd,SAAS,EAAE,GAAG;KACf;IACD;QACE,QAAQ,EAAE,eAAe;QACzB,WAAW,EAAE,4BAA4B;QACzC,MAAM,EAAE,IAAI,EAAE,MAAM;QACpB,SAAS,EAAE,GAAG;QACd,SAAS,EAAE,GAAG;KACf;IACD;QACE,QAAQ,EAAE,iBAAiB;QAC3B,WAAW,EAAE,yBAAyB;QACtC,MAAM,EAAE,GAAG,EAAE,OAAO;QACpB,SAAS,EAAE,GAAG;QACd,SAAS,EAAE,GAAG;KACf;CACF,CAAC;AAEF,MAAM,UAAU,qBAAqB,CACnC,UAAkB,OAAO,EACzB,gBAAsB,IAAI,IAAI,EAAE;IAEhC,OAAO;QACL,EAAE,EAAE,OAAO,OAAO,EAAE;QACpB,OAAO;QACP,aAAa;QACb,OAAO,EAAE,oBAAoB;KAC9B,CAAC;AACJ,CAAC"}
|
||||
42
packages/rules-engine/src/aml.d.ts
vendored
Normal file
42
packages/rules-engine/src/aml.d.ts
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* AML (Anti-Money Laundering) and anti-structuring detection
|
||||
*/
|
||||
import type { Transaction, AMLCheckResult, SingleTransactionAMLResult, StructuringCheckResult, RuleResult } from '@brazil-swift-ops/types';
|
||||
/**
|
||||
* Transaction history for structuring detection (in production, this would be a database)
|
||||
*/
|
||||
interface TransactionHistory {
|
||||
transactionId: string;
|
||||
amount: number;
|
||||
currency: string;
|
||||
usdEquivalent: number;
|
||||
date: Date;
|
||||
orderingCustomerTaxId?: string;
|
||||
beneficiaryTaxId?: string;
|
||||
}
|
||||
declare class TransactionHistoryStore {
|
||||
private history;
|
||||
add(entry: TransactionHistory): void;
|
||||
getByDateRange(startDate: Date, endDate: Date): TransactionHistory[];
|
||||
getByCustomer(taxId: string, startDate: Date, endDate: Date): TransactionHistory[];
|
||||
getAll(): TransactionHistory[];
|
||||
}
|
||||
export declare function getHistoryStore(): TransactionHistoryStore;
|
||||
/**
|
||||
* Check single transaction AML threshold
|
||||
*/
|
||||
export declare function checkSingleTransactionAML(transaction: Transaction): SingleTransactionAMLResult;
|
||||
/**
|
||||
* Check for structuring patterns (multiple small transactions that sum above threshold)
|
||||
*/
|
||||
export declare function checkStructuring(transaction: Transaction, historicalTransactions?: TransactionHistory[]): StructuringCheckResult | undefined;
|
||||
/**
|
||||
* Perform complete AML check
|
||||
*/
|
||||
export declare function performAMLCheck(transaction: Transaction, historicalTransactions?: TransactionHistory[]): AMLCheckResult;
|
||||
/**
|
||||
* Create rule result for AML check
|
||||
*/
|
||||
export declare function createAMLRuleResult(check: AMLCheckResult): RuleResult;
|
||||
export {};
|
||||
//# sourceMappingURL=aml.d.ts.map
|
||||
1
packages/rules-engine/src/aml.d.ts.map
Normal file
1
packages/rules-engine/src/aml.d.ts.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"aml.d.ts","sourceRoot":"","sources":["aml.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EACV,WAAW,EACX,cAAc,EACd,0BAA0B,EAC1B,sBAAsB,EACtB,UAAU,EAGX,MAAM,yBAAyB,CAAC;AAKjC;;GAEG;AACH,UAAU,kBAAkB;IAC1B,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,IAAI,CAAC;IACX,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,cAAM,uBAAuB;IAC3B,OAAO,CAAC,OAAO,CAA4B;IAE3C,GAAG,CAAC,KAAK,EAAE,kBAAkB,GAAG,IAAI;IAIpC,cAAc,CAAC,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,GAAG,kBAAkB,EAAE;IAMpE,aAAa,CACX,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,IAAI,EACf,OAAO,EAAE,IAAI,GACZ,kBAAkB,EAAE;IAUvB,MAAM,IAAI,kBAAkB,EAAE;CAG/B;AAID,wBAAgB,eAAe,IAAI,uBAAuB,CAEzD;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CACvC,WAAW,EAAE,WAAW,GACvB,0BAA0B,CA6B5B;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,WAAW,EAAE,WAAW,EACxB,sBAAsB,CAAC,EAAE,kBAAkB,EAAE,GAC5C,sBAAsB,GAAG,SAAS,CAiEpC;AAED;;GAEG;AACH,wBAAgB,eAAe,CAC7B,WAAW,EAAE,WAAW,EACxB,sBAAsB,CAAC,EAAE,kBAAkB,EAAE,GAC5C,cAAc,CAyBhB;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,cAAc,GAAG,UAAU,CAsBrE"}
|
||||
152
packages/rules-engine/src/aml.js
Normal file
152
packages/rules-engine/src/aml.js
Normal file
@@ -0,0 +1,152 @@
|
||||
/**
|
||||
* AML (Anti-Money Laundering) and anti-structuring detection
|
||||
*/
|
||||
import { getDefaultConverter } from '@brazil-swift-ops/utils';
|
||||
import { calculateRollingWindow, filterDatesInWindow } from '@brazil-swift-ops/utils';
|
||||
import { getConfig } from './config';
|
||||
class TransactionHistoryStore {
|
||||
history = [];
|
||||
add(entry) {
|
||||
this.history.push(entry);
|
||||
}
|
||||
getByDateRange(startDate, endDate) {
|
||||
return this.history.filter((entry) => entry.date >= startDate && entry.date <= endDate);
|
||||
}
|
||||
getByCustomer(taxId, startDate, endDate) {
|
||||
return this.history.filter((entry) => (entry.orderingCustomerTaxId === taxId ||
|
||||
entry.beneficiaryTaxId === taxId) &&
|
||||
entry.date >= startDate &&
|
||||
entry.date <= endDate);
|
||||
}
|
||||
getAll() {
|
||||
return [...this.history];
|
||||
}
|
||||
}
|
||||
const historyStore = new TransactionHistoryStore();
|
||||
export function getHistoryStore() {
|
||||
return historyStore;
|
||||
}
|
||||
/**
|
||||
* Check single transaction AML threshold
|
||||
*/
|
||||
export function checkSingleTransactionAML(transaction) {
|
||||
const config = getConfig();
|
||||
const converter = getDefaultConverter();
|
||||
const usdEquivalent = converter.getUSDEquivalent(transaction.amount, transaction.currency);
|
||||
const threshold = config.aml.singleTransactionThreshold;
|
||||
const requiresEnhancedReview = usdEquivalent >= threshold;
|
||||
let riskLevel;
|
||||
if (usdEquivalent >= threshold) {
|
||||
riskLevel = 'High';
|
||||
}
|
||||
else if (usdEquivalent >= threshold * 0.5) {
|
||||
riskLevel = 'Medium';
|
||||
}
|
||||
else {
|
||||
riskLevel = 'Low';
|
||||
}
|
||||
return {
|
||||
passed: true, // AML check doesn't fail, it flags for review
|
||||
transactionAmount: transaction.amount,
|
||||
usdEquivalent,
|
||||
threshold,
|
||||
requiresEnhancedReview,
|
||||
riskLevel,
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Check for structuring patterns (multiple small transactions that sum above threshold)
|
||||
*/
|
||||
export function checkStructuring(transaction, historicalTransactions) {
|
||||
const config = getConfig();
|
||||
const converter = getDefaultConverter();
|
||||
// Calculate rolling window
|
||||
const window = calculateRollingWindow(transaction.createdAt || new Date(), config.aml.structuringWindowDays);
|
||||
// Get historical transactions if not provided
|
||||
if (!historicalTransactions) {
|
||||
const customerTaxId = transaction.orderingCustomerTaxId || transaction.beneficiary?.taxId;
|
||||
if (customerTaxId) {
|
||||
historicalTransactions = historyStore.getByCustomer(customerTaxId, window.startDate, window.endDate);
|
||||
}
|
||||
else {
|
||||
historicalTransactions = historyStore.getByDateRange(window.startDate, window.endDate);
|
||||
}
|
||||
}
|
||||
// Filter to transactions in window
|
||||
const windowTransactions = historicalTransactions.filter((t) => filterDatesInWindow([t.date], window).length > 0);
|
||||
// Calculate totals
|
||||
const totalAmount = windowTransactions.reduce((sum, t) => sum + t.amount, transaction.amount);
|
||||
const totalUsdEquivalent = windowTransactions.reduce((sum, t) => sum + t.usdEquivalent, converter.getUSDEquivalent(transaction.amount, transaction.currency));
|
||||
const individualAmounts = [
|
||||
...windowTransactions.map((t) => t.usdEquivalent),
|
||||
converter.getUSDEquivalent(transaction.amount, transaction.currency),
|
||||
];
|
||||
// Check if structuring detected
|
||||
const threshold = config.aml.structuringThreshold;
|
||||
const detected = totalUsdEquivalent >= threshold &&
|
||||
individualAmounts.every((amt) => amt < threshold);
|
||||
return {
|
||||
detected,
|
||||
windowDays: window.days,
|
||||
transactionCount: windowTransactions.length + 1,
|
||||
totalAmount,
|
||||
totalUsdEquivalent,
|
||||
individualAmounts,
|
||||
rationale: detected
|
||||
? `Structuring detected: ${windowTransactions.length + 1} transactions totaling ${totalUsdEquivalent.toFixed(2)} USD over ${window.days} days, each below ${threshold} USD threshold.`
|
||||
: `No structuring pattern detected. Total: ${totalUsdEquivalent.toFixed(2)} USD over ${window.days} days.`,
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Perform complete AML check
|
||||
*/
|
||||
export function performAMLCheck(transaction, historicalTransactions) {
|
||||
const singleCheck = checkSingleTransactionAML(transaction);
|
||||
const structuringCheck = checkStructuring(transaction, historicalTransactions);
|
||||
// Determine overall risk level
|
||||
let overallRiskLevel;
|
||||
if (singleCheck.riskLevel === 'High' || structuringCheck?.detected) {
|
||||
overallRiskLevel = 'High';
|
||||
}
|
||||
else if (singleCheck.riskLevel === 'Medium') {
|
||||
overallRiskLevel = 'Medium';
|
||||
}
|
||||
else {
|
||||
overallRiskLevel = 'Low';
|
||||
}
|
||||
const passed = overallRiskLevel !== 'High';
|
||||
return {
|
||||
passed,
|
||||
singleTransactionCheck: singleCheck,
|
||||
structuringCheck,
|
||||
overallRiskLevel,
|
||||
rationale: passed
|
||||
? `AML check passed. Risk level: ${overallRiskLevel}.`
|
||||
: `AML check flagged for review. Risk level: ${overallRiskLevel}. ${structuringCheck?.detected ? 'Structuring pattern detected.' : ''}`,
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Create rule result for AML check
|
||||
*/
|
||||
export function createAMLRuleResult(check) {
|
||||
const severity = check.overallRiskLevel === 'High'
|
||||
? 'Critical'
|
||||
: check.overallRiskLevel === 'Medium'
|
||||
? 'Warning'
|
||||
: 'Info';
|
||||
const decision = check.passed ? 'Allow' : 'Escalate';
|
||||
return {
|
||||
ruleId: 'aml-check',
|
||||
ruleName: 'AML & Anti-Structuring Check',
|
||||
passed: check.passed,
|
||||
severity,
|
||||
decision,
|
||||
rationale: check.rationale,
|
||||
details: {
|
||||
overallRiskLevel: check.overallRiskLevel,
|
||||
singleTransactionCheck: check.singleTransactionCheck,
|
||||
structuringCheck: check.structuringCheck,
|
||||
},
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=aml.js.map
|
||||
1
packages/rules-engine/src/aml.js.map
Normal file
1
packages/rules-engine/src/aml.js.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"aml.js","sourceRoot":"","sources":["aml.ts"],"names":[],"mappings":"AAAA;;GAEG;AAWH,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AACtF,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAerC,MAAM,uBAAuB;IACnB,OAAO,GAAyB,EAAE,CAAC;IAE3C,GAAG,CAAC,KAAyB;QAC3B,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC3B,CAAC;IAED,cAAc,CAAC,SAAe,EAAE,OAAa;QAC3C,OAAO,IAAI,CAAC,OAAO,CA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AAQ;QACR,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,OAAO,EAAE;YACP,gBAAgB,EAAE,KAAK,CAAC,gBAAgB;YACxC,sBAAsB,EAAE,KAAK,CAAC,sBAAsB;YACpD,gBAAgB,EAAE,KAAK,CAAC,gBAAgB;SACzC;KACF,CAAC;AACJ,CAAC"}
|
||||
13
packages/rules-engine/src/fx-contract.d.ts
vendored
Normal file
13
packages/rules-engine/src/fx-contract.d.ts
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
import type { Transaction, FXContract, FXContractCheckResult, RuleResult } from '@brazil-swift-ops/types';
|
||||
declare class FXContractStore {
|
||||
private contracts;
|
||||
add(contract: FXContract): void;
|
||||
get(contractId: string): FXContract | undefined;
|
||||
getAll(): FXContract[];
|
||||
updateRemainingAmount(contractId: string, usedAmount: number): void;
|
||||
}
|
||||
export declare function getContractStore(): FXContractStore;
|
||||
export declare function validateFXContract(transaction: Transaction, contract?: FXContract): FXContractCheckResult;
|
||||
export declare function createFXContractRuleResult(check: FXContractCheckResult): RuleResult;
|
||||
export {};
|
||||
//# sourceMappingURL=fx-contract.d.ts.map
|
||||
1
packages/rules-engine/src/fx-contract.d.ts.map
Normal file
1
packages/rules-engine/src/fx-contract.d.ts.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"fx-contract.d.ts","sourceRoot":"","sources":["fx-contract.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,UAAU,EACV,qBAAqB,EACrB,UAAU,EAGX,MAAM,yBAAyB,CAAC;AAGjC,cAAM,eAAe;IACnB,OAAO,CAAC,SAAS,CAAsC;IAEvD,GAAG,CAAC,QAAQ,EAAE,UAAU,GAAG,IAAI;IAI/B,GAAG,CAAC,UAAU,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS;IAI/C,MAAM,IAAI,UAAU,EAAE;IAItB,qBAAqB,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI;CAWpE;AAID,wBAAgB,gBAAgB,IAAI,eAAe,CAElD;AAED,wBAAgB,kBAAkB,CAChC,WAAW,EAAE,WAAW,EACxB,QAAQ,CAAC,EAAE,UAAU,GACpB,qBAAqB,CAmFvB;AAED,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,qBAAqB,GAC3B,UAAU,CAsBZ"}
|
||||
127
packages/rules-engine/src/fx-contract.js
Normal file
127
packages/rules-engine/src/fx-contract.js
Normal file
@@ -0,0 +1,127 @@
|
||||
import { isEffectiveDate } from '@brazil-swift-ops/utils';
|
||||
class FXContractStore {
|
||||
contracts = new Map();
|
||||
add(contract) {
|
||||
this.contracts.set(contract.contractId, contract);
|
||||
}
|
||||
get(contractId) {
|
||||
return this.contracts.get(contractId);
|
||||
}
|
||||
getAll() {
|
||||
return Array.from(this.contracts.values());
|
||||
}
|
||||
updateRemainingAmount(contractId, usedAmount) {
|
||||
const contract = this.contracts.get(contractId);
|
||||
if (contract) {
|
||||
contract.usedAmount += usedAmount;
|
||||
contract.remainingAmount = contract.amount - contract.usedAmount;
|
||||
contract.updatedAt = new Date();
|
||||
if (contract.remainingAmount <= 0) {
|
||||
contract.status = 'exhausted';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
const contractStore = new FXContractStore();
|
||||
export function getContractStore() {
|
||||
return contractStore;
|
||||
}
|
||||
export function validateFXContract(transaction, contract) {
|
||||
if (!transaction.fxContractId) {
|
||||
return {
|
||||
passed: false,
|
||||
contractExists: false,
|
||||
contractType: undefined,
|
||||
contractAmount: 0,
|
||||
contractRemainingAmount: 0,
|
||||
transactionAmount: transaction.amount,
|
||||
amountWithinLimit: false,
|
||||
rationale: 'FX contract ID is required for cross-border transactions.',
|
||||
};
|
||||
}
|
||||
if (!contract) {
|
||||
contract = contractStore.get(transaction.fxContractId);
|
||||
}
|
||||
if (!contract) {
|
||||
return {
|
||||
passed: false,
|
||||
fxContractId: transaction.fxContractId,
|
||||
contractExists: false,
|
||||
contractType: undefined,
|
||||
contractAmount: 0,
|
||||
contractRemainingAmount: 0,
|
||||
transactionAmount: transaction.amount,
|
||||
amountWithinLimit: false,
|
||||
rationale: `FX contract ${transaction.fxContractId} not found.`,
|
||||
};
|
||||
}
|
||||
const now = new Date();
|
||||
const contractActive = contract.status === 'active' &&
|
||||
isEffectiveDate(now, contract.effectiveDate, contract.expiryDate);
|
||||
if (!contractActive) {
|
||||
return {
|
||||
passed: false,
|
||||
fxContractId: contract.contractId,
|
||||
contractExists: true,
|
||||
contractActive: false,
|
||||
contractType: contract.type,
|
||||
contractAmount: contract.amount,
|
||||
contractRemainingAmount: contract.remainingAmount,
|
||||
transactionAmount: transaction.amount,
|
||||
amountWithinLimit: false,
|
||||
rationale: `FX contract ${contract.contractId} is not active (status: ${contract.status}).`,
|
||||
};
|
||||
}
|
||||
if (contract.type !== transaction.direction) {
|
||||
return {
|
||||
passed: false,
|
||||
fxContractId: contract.contractId,
|
||||
contractExists: true,
|
||||
contractActive: false,
|
||||
contractType: contract.type,
|
||||
contractAmount: contract.amount,
|
||||
contractRemainingAmount: contract.remainingAmount,
|
||||
transactionAmount: transaction.amount,
|
||||
amountWithinLimit: false,
|
||||
rationale: `FX contract type (${contract.type}) does not match transaction direction (${transaction.direction}).`,
|
||||
};
|
||||
}
|
||||
const amountWithinLimit = transaction.amount <= contract.remainingAmount;
|
||||
return {
|
||||
passed: amountWithinLimit && contractActive,
|
||||
fxContractId: contract.contractId,
|
||||
contractExists: true,
|
||||
contractActive,
|
||||
contractType: contract.type,
|
||||
contractAmount: contract.amount,
|
||||
contractRemainingAmount: contract.remainingAmount,
|
||||
transactionAmount: transaction.amount,
|
||||
amountWithinLimit,
|
||||
rationale: amountWithinLimit
|
||||
? `Transaction amount (${transaction.amount} ${transaction.currency}) is within FX contract limit (${contract.remainingAmount} ${contract.currency} remaining).`
|
||||
: `Transaction amount (${transaction.amount} ${transaction.currency}) exceeds FX contract remaining amount (${contract.remainingAmount} ${contract.currency}).`,
|
||||
};
|
||||
}
|
||||
export function createFXContractRuleResult(check) {
|
||||
const severity = check.passed ? 'Info' : 'Critical';
|
||||
const decision = check.passed ? 'Allow' : 'Hold';
|
||||
return {
|
||||
ruleId: 'fx-contract-check',
|
||||
ruleName: 'FX Contract Validation',
|
||||
passed: check.passed,
|
||||
severity,
|
||||
decision,
|
||||
rationale: check.rationale,
|
||||
details: {
|
||||
fxContractId: check.fxContractId,
|
||||
contractExists: check.contractExists,
|
||||
contractActive: check.contractActive,
|
||||
contractType: check.contractType,
|
||||
contractAmount: check.contractAmount,
|
||||
contractRemainingAmount: check.contractRemainingAmount,
|
||||
transactionAmount: check.transactionAmount,
|
||||
amountWithinLimit: check.amountWithinLimit,
|
||||
},
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=fx-contract.js.map
|
||||
1
packages/rules-engine/src/fx-contract.js.map
Normal file
1
packages/rules-engine/src/fx-contract.js.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"fx-contract.js","sourceRoot":"","sources":["fx-contract.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE1D,MAAM,eAAe;IACX,SAAS,GAA4B,IAAI,GAAG,EAAE,CAAC;IAEvD,GAAG,CAAC,QAAoB;QACtB,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;IACpD,CAAC;IAED,GAAG,CAAC,UAAkB;QACpB,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IACxC,CAAC;IAED,MAAM;QACJ,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC;IAC7C,CAAC;IAED,qBAAqB,CAAC,UAAkB,EAAE,UAAkB;QAC1D,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QAChD,IAAI,QAAQ,E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AAK,CAAC,iBAAiB;YAC1C,iBAAiB,EAAE,KAAK,CAAC,iBAAiB;SAC3C;KACF,CAAC;AACJ,CAAC"}
|
||||
13
packages/rules-engine/src/index.d.ts
vendored
Normal file
13
packages/rules-engine/src/index.d.ts
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* @brazil-swift-ops/rules-engine
|
||||
*
|
||||
* Brazil regulatory rules engine for cross-border payments
|
||||
*/
|
||||
export * from './config';
|
||||
export * from './threshold';
|
||||
export * from './documentation';
|
||||
export * from './fx-contract';
|
||||
export * from './iof';
|
||||
export * from './aml';
|
||||
export * from './orchestrator';
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
1
packages/rules-engine/src/index.d.ts.map
Normal file
1
packages/rules-engine/src/index.d.ts.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,OAAO,CAAC;AACtB,cAAc,OAAO,CAAC;AACtB,cAAc,gBAAgB,CAAC"}
|
||||
13
packages/rules-engine/src/index.js
Normal file
13
packages/rules-engine/src/index.js
Normal file
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* @brazil-swift-ops/rules-engine
|
||||
*
|
||||
* Brazil regulatory rules engine for cross-border payments
|
||||
*/
|
||||
export * from './config';
|
||||
export * from './threshold';
|
||||
export * from './documentation';
|
||||
export * from './fx-contract';
|
||||
export * from './iof';
|
||||
export * from './aml';
|
||||
export * from './orchestrator';
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
packages/rules-engine/src/index.js.map
Normal file
1
packages/rules-engine/src/index.js.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,OAAO,CAAC;AACtB,cAAc,OAAO,CAAC;AACtB,cAAc,gBAAgB,CAAC"}
|
||||
4
packages/rules-engine/src/iof.d.ts
vendored
Normal file
4
packages/rules-engine/src/iof.d.ts
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
import type { Transaction, IOFCalculationResult, RuleResult } from '@brazil-swift-ops/types';
|
||||
export declare function calculateIOF(transaction: Transaction): IOFCalculationResult;
|
||||
export declare function createIOFRuleResult(calculation: IOFCalculationResult): RuleResult;
|
||||
//# sourceMappingURL=iof.d.ts.map
|
||||
1
packages/rules-engine/src/iof.d.ts.map
Normal file
1
packages/rules-engine/src/iof.d.ts.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"iof.d.ts","sourceRoot":"","sources":["iof.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,WAAW,EACX,oBAAoB,EACpB,UAAU,EACX,MAAM,yBAAyB,CAAC;AAIjC,wBAAgB,YAAY,CAAC,WAAW,EAAE,WAAW,GAAG,oBAAoB,CAuC3E;AAED,wBAAgB,mBAAmB,CACjC,WAAW,EAAE,oBAAoB,GAChC,UAAU,CAoBZ"}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user