fix(catalog-backend): actually use modified entity output (default namespace was broken)

This commit is contained in:
Fredrik Adelöw
2020-10-12 11:16:12 +02:00
parent caeb82b3d0
commit 390a6d7982
+8 -5
View File
@@ -40,10 +40,13 @@ class AllEntityPolicies implements EntityPolicy {
async enforce(entity: Entity): Promise<Entity> {
let result = entity;
for (const policy of this.policies) {
const output = await policy.enforce(entity);
if (output) {
result = output;
const output = await policy.enforce(result);
if (!output) {
throw new Error(
`Policy ${policy.constructor.name} did not return a result`,
);
}
result = output;
}
return result;
}
@@ -54,10 +57,10 @@ class AllEntityPolicies implements EntityPolicy {
class AnyEntityPolicy implements EntityPolicy {
constructor(private readonly policies: EntityPolicy[]) {}
async enforce(entity: Entity): Promise<Entity | undefined> {
async enforce(entity: Entity): Promise<Entity> {
for (const policy of this.policies) {
const output = await policy.enforce(entity);
if (output !== null) {
if (output) {
return output;
}
}