Files
smom-dbis-138/packages/integration-foundation/dist/entities/RegulatedEntity.js

22 lines
694 B
JavaScript
Raw Normal View History

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createInMemoryEntityRegistry = createInMemoryEntityRegistry;
exports.assertTenantIsolation = assertTenantIsolation;
function createInMemoryEntityRegistry(entities) {
const index = new Map();
for (const e of entities) {
index.set(`${e.tenantId}:${e.entityId}`, e);
}
return {
entities,
getEntity(entityId, tenantId) {
return index.get(`${tenantId}:${entityId}`);
},
};
}
function assertTenantIsolation(actorTenantId, resourceTenantId) {
if (actorTenantId !== resourceTenantId) {
throw new Error('Tenant isolation violation');
}
}