Backend modules from tastefully 8bd93d15: core-libs, core-session, api-gateway, mobile-api, services-auth, services-system, services-counter, services-member, services-log, services-email. solvway-admin-portal from babyboo f64d096ea, solvway-customer-portal from tastefully 8bd93d15. Copied as tracked files only. Literal secrets replaced with environment placeholders: - services-email: SMTP_PASSWORD, MAILGUN_API_KEY, SENDGRID_API_KEY, MAILJET_API_KEY, MAILJET_SECRET_KEY (optional, empty default) - services-system: JUMIO_TOKEN, JUMIO_SECRET (optional) - services-auth: USER_AUTH_API_SECRET (required); commented JWT secret removed - core-libs: JWT_TOKEN default removed (required), XXL_JOB_TOKEN default removed, ipgeolocation key read from IPGEOLOCATION_API_KEY - services-system EkycAppConfig: commented Jumio credentials removed Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
28 lines
1.1 KiB
TypeScript
28 lines
1.1 KiB
TypeScript
// audit-log-readable-actions: mobile-api records an audited endpoint that declares no action as a readable
|
|
// UPPER_SNAKE code (AppAccessAspect.defaultAuditAction). Events stored before that carry the raw
|
|
// "XController.method" name; this derives the same code for display, so old and new events read alike.
|
|
// Stored audit rows are never rewritten.
|
|
|
|
const LEGACY_ACTION = /^([A-Za-z0-9]+)\.([A-Za-z0-9]+)$/;
|
|
|
|
function upperSnake(camel: string): string {
|
|
return camel
|
|
.replace(/([a-z0-9])([A-Z])/g, "$1_$2")
|
|
.replace(/([A-Z]+)([A-Z][a-z])/g, "$1_$2")
|
|
.toUpperCase();
|
|
}
|
|
|
|
export function displayAuditAction(action: string | null | undefined): string {
|
|
if (!action) return "";
|
|
const legacy = LEGACY_ACTION.exec(action);
|
|
if (!legacy) return action;
|
|
let type = legacy[1];
|
|
if (type.endsWith("Controller") && type.length > "Controller".length) {
|
|
type = type.slice(0, -"Controller".length);
|
|
}
|
|
if (type.startsWith("Admin") && type.length > "Admin".length) {
|
|
type = type.slice("Admin".length);
|
|
}
|
|
return `${upperSnake(type)}_${upperSnake(legacy[2])}`;
|
|
}
|