Files
brazil-swift-ops/packages/audit/src/versions.ts
defiQUG 8c771da399 Initial implementation: Brazil SWIFT Operations Platform
- Complete monorepo structure with pnpm workspaces and Turborepo
- All packages implemented: types, utils, rules-engine, iso20022, treasury, risk-models, audit
- React web application with TypeScript and Tailwind CSS
- Full Brazil regulatory compliance (BCB requirements)
- ISO 20022 message support (pacs.008, pacs.009, pain.001)
- Treasury and subledger management
- Risk, capital, and liquidity stress allocation
- Audit logging and BCB reporting
- E&O +10% uplift implementation
2026-01-23 14:51:10 -08:00

56 lines
1.3 KiB
TypeScript

import type { RuleVersion } from '@brazil-swift-ops/types';
class RuleVersionStore {
private versions: RuleVersion[] = [];
add(version: RuleVersion): void {
this.versions.push(version);
}
get(version: string): RuleVersion | undefined {
return this.versions.find((v) => v.version === version);
}
getCurrent(): RuleVersion | undefined {
return this.versions
.filter((v) => !v.deprecated)
.sort((a, b) => b.effectiveDate.getTime() - a.effectiveDate.getTime())[0];
}
getAll(): RuleVersion[] {
return [...this.versions];
}
deprecate(version: string, deprecatedDate: Date): void {
const versionObj = this.versions.find((v) => v.version === version);
if (versionObj) {
versionObj.deprecated = true;
versionObj.deprecatedDate = deprecatedDate;
}
}
}
const ruleVersionStore = new RuleVersionStore();
export function getRuleVersionStore(): RuleVersionStore {
return ruleVersionStore;
}
export function createRuleVersion(
version: string,
effectiveDate: Date,
approvalAuthority: string,
description?: string
): RuleVersion {
const ruleVersion: RuleVersion = {
version,
effectiveDate,
approvalAuthority,
deprecated: false,
description,
};
ruleVersionStore.add(ruleVersion);
return ruleVersion;
}