mirror of
https://github.com/expo/entity.git
synced 2026-11-15 17:32:07 -10:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0e8e05f963 |
No files matched your search
@@ -98,34 +98,63 @@ export default abstract class EntityPrivacyPolicy<
|
||||
TEntity extends ReadonlyEntity<TFields, TID, TViewerContext, TSelectedFields>,
|
||||
TSelectedFields extends keyof TFields = keyof TFields
|
||||
> {
|
||||
protected readonly createRules: readonly PrivacyPolicyRule<
|
||||
protected abstract getCreateRules?(): readonly PrivacyPolicyRule<
|
||||
TFields,
|
||||
TID,
|
||||
TViewerContext,
|
||||
TEntity,
|
||||
TSelectedFields
|
||||
>[] = [];
|
||||
protected readonly readRules: readonly PrivacyPolicyRule<
|
||||
>[];
|
||||
protected abstract getReadRules?(): readonly PrivacyPolicyRule<
|
||||
TFields,
|
||||
TID,
|
||||
TViewerContext,
|
||||
TEntity,
|
||||
TSelectedFields
|
||||
>[] = [];
|
||||
protected readonly updateRules: readonly PrivacyPolicyRule<
|
||||
>[];
|
||||
protected abstract getUpdateRules?(): readonly PrivacyPolicyRule<
|
||||
TFields,
|
||||
TID,
|
||||
TViewerContext,
|
||||
TEntity,
|
||||
TSelectedFields
|
||||
>[] = [];
|
||||
protected readonly deleteRules: readonly PrivacyPolicyRule<
|
||||
>[];
|
||||
protected abstract getDeleteRules?(): readonly PrivacyPolicyRule<
|
||||
TFields,
|
||||
TID,
|
||||
TViewerContext,
|
||||
TEntity,
|
||||
TSelectedFields
|
||||
>[] = [];
|
||||
>[];
|
||||
|
||||
private createRules: readonly PrivacyPolicyRule<
|
||||
TFields,
|
||||
TID,
|
||||
TViewerContext,
|
||||
TEntity,
|
||||
TSelectedFields
|
||||
>[] = this.getCreateRules ? this.getCreateRules() : [];
|
||||
private readRules: readonly PrivacyPolicyRule<
|
||||
TFields,
|
||||
TID,
|
||||
TViewerContext,
|
||||
TEntity,
|
||||
TSelectedFields
|
||||
>[] = this.getReadRules ? this.getReadRules() : [];
|
||||
private updateRules: readonly PrivacyPolicyRule<
|
||||
TFields,
|
||||
TID,
|
||||
TViewerContext,
|
||||
TEntity,
|
||||
TSelectedFields
|
||||
>[] = this.getUpdateRules ? this.getUpdateRules() : [];
|
||||
private deleteRules: readonly PrivacyPolicyRule<
|
||||
TFields,
|
||||
TID,
|
||||
TViewerContext,
|
||||
TEntity,
|
||||
TSelectedFields
|
||||
>[] = this.getDeleteRules ? this.getDeleteRules() : [];
|
||||
|
||||
/**
|
||||
* Get the privacy policy evaluation mode and deny handler for this policy.
|
||||
|
||||
@@ -6,6 +6,7 @@ import EntityPrivacyPolicy from '../../EntityPrivacyPolicy';
|
||||
import ViewerContext from '../../ViewerContext';
|
||||
import { successfulResults, failedResults } from '../../entityUtils';
|
||||
import AlwaysAllowPrivacyPolicyRule from '../../rules/AlwaysAllowPrivacyPolicyRule';
|
||||
import PrivacyPolicyRule from '../../rules/PrivacyPolicyRule';
|
||||
import { createUnitTestEntityCompanionProvider } from '../../utils/testing/createUnitTestEntityCompanionProvider';
|
||||
|
||||
describe('Two entities backed by the same table', () => {
|
||||
@@ -107,18 +108,45 @@ const testEntityConfiguration = new EntityConfiguration<TestFields>({
|
||||
});
|
||||
|
||||
class TestEntityPrivacyPolicy extends EntityPrivacyPolicy<any, string, ViewerContext, any, any> {
|
||||
protected override readonly readRules = [
|
||||
new AlwaysAllowPrivacyPolicyRule<any, string, ViewerContext, any, any>(),
|
||||
];
|
||||
protected override readonly createRules = [
|
||||
new AlwaysAllowPrivacyPolicyRule<any, string, ViewerContext, any, any>(),
|
||||
];
|
||||
protected override readonly updateRules = [
|
||||
new AlwaysAllowPrivacyPolicyRule<any, string, ViewerContext, any, any>(),
|
||||
];
|
||||
protected override readonly deleteRules = [
|
||||
new AlwaysAllowPrivacyPolicyRule<any, string, ViewerContext, any, any>(),
|
||||
];
|
||||
protected override getReadRules(): readonly PrivacyPolicyRule<
|
||||
any,
|
||||
string,
|
||||
ViewerContext,
|
||||
any,
|
||||
any
|
||||
>[] {
|
||||
return [new AlwaysAllowPrivacyPolicyRule<any, string, ViewerContext, any, any>()];
|
||||
}
|
||||
|
||||
protected override getCreateRules(): readonly PrivacyPolicyRule<
|
||||
any,
|
||||
string,
|
||||
ViewerContext,
|
||||
any,
|
||||
any
|
||||
>[] {
|
||||
return [new AlwaysAllowPrivacyPolicyRule<any, string, ViewerContext, any, any>()];
|
||||
}
|
||||
|
||||
protected override getUpdateRules(): readonly PrivacyPolicyRule<
|
||||
any,
|
||||
string,
|
||||
ViewerContext,
|
||||
any,
|
||||
any
|
||||
>[] {
|
||||
return [new AlwaysAllowPrivacyPolicyRule<any, string, ViewerContext, any, any>()];
|
||||
}
|
||||
|
||||
protected override getDeleteRules(): readonly PrivacyPolicyRule<
|
||||
any,
|
||||
string,
|
||||
ViewerContext,
|
||||
any,
|
||||
any
|
||||
>[] {
|
||||
return [new AlwaysAllowPrivacyPolicyRule<any, string, ViewerContext, any, any>()];
|
||||
}
|
||||
}
|
||||
|
||||
class OneTestEntity extends Entity<TestFields, string, ViewerContext, OneTestFields> {
|
||||
|
||||
Reference in new issue
Block a user