Add entity address/contact tables and CRUD for entity resources

This commit is contained in:
seb
2026-08-06 05:43:50 +02:00
parent 0b7e40ac9c
commit 3b77a1c946
32 changed files with 3078 additions and 1363 deletions

View File

@@ -0,0 +1,22 @@
import { GET_BY_COMPANY_AND_ID } from '../../sql/entity.js';
import request from '../request.js';
/** Ensure entity belongs to company. Throws Entity not found. */
export default function resolveEntityAccess(pool) {
return async (companyId, entityId, tx) => {
if (!Number.isFinite(entityId)) {
throw new Error('Entity not found');
}
const result = await request(pool, tx)
.input('id', entityId)
.input('companyId', companyId)
.query(GET_BY_COMPANY_AND_ID);
const row = result.recordset[0];
if (!row) {
throw new Error('Entity not found');
}
return row;
};
}