-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
30 changed files
with
860 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,102 @@ | ||
import { GdprStorage } from "./GdprStorage"; | ||
export interface GdprRawInto<RawRepr> { | ||
raw(): RawRepr | object; | ||
/** | ||
* Raw/simple representation of this guard | ||
*/ | ||
raw(): RawRepr; | ||
} | ||
/** | ||
* Raw representation of a guard | ||
*/ | ||
export interface GdprGuardRaw { | ||
name: string; | ||
enabled: boolean; | ||
required: boolean; | ||
description: string; | ||
storage: GdprStorage; | ||
} | ||
/** | ||
* Generic type representing a guard | ||
*/ | ||
export interface GdprGuard extends GdprRawInto<GdprGuardRaw> { | ||
/** | ||
* Unique name of this guard | ||
*/ | ||
readonly name: string; | ||
/** | ||
* Whether the guard is currently enabled | ||
*/ | ||
enabled: boolean; | ||
/** | ||
* A description of what this guard does | ||
*/ | ||
readonly description: string; | ||
/** | ||
* Where this guard is stored | ||
*/ | ||
readonly storage: GdprStorage; | ||
/** | ||
* Whether this guard is required | ||
*/ | ||
required: boolean; | ||
/** | ||
* Determine whether or not a guard is enabled | ||
* @param name The name of the guard to look for | ||
* @memberof GdprGuard | ||
*/ | ||
isEnabled(name: string): boolean; | ||
/** | ||
* Enable this guard | ||
* @returns this guard | ||
* @memberof GdprGuard | ||
*/ | ||
enable(): GdprGuard; | ||
/** | ||
* Disable this guard | ||
* @returns this guard | ||
* @memberof GdprGuard | ||
*/ | ||
disable(): GdprGuard; | ||
/** | ||
* Toggle the enabled state of this guard | ||
* @returns this guard | ||
* @memberof GdprGuard | ||
*/ | ||
toggle(): GdprGuard; | ||
/** | ||
* Make this guard required | ||
* @returns this guard | ||
* @memberof GdprGuard | ||
*/ | ||
makeRequired(): GdprGuard; | ||
/** | ||
* Enable guards of the given type (this guard and sub-guards) | ||
* @param type The storage type to enable all guards for | ||
* @returns this guard | ||
* @memberof GdprGuard | ||
*/ | ||
enableForStorage(type: GdprStorage): GdprGuard; | ||
/** | ||
* Disable guards of the given type (this guard and sub-guards) | ||
* @param type The storage type to enable all guards for | ||
* @returns this guard | ||
* @memberof GdprGuard | ||
*/ | ||
disableForStorage(type: GdprStorage): GdprGuard; | ||
/** | ||
* Toggle guards of the given type (this guard and sub-guards) | ||
* @param type The storage type to enable all guards for | ||
* @returns this guard | ||
* @memberof GdprGuard | ||
*/ | ||
toggleForStorage(type: GdprStorage): GdprGuard; | ||
raw(): object | GdprGuardRaw; | ||
} | ||
/** | ||
* Factory for creating a guard | ||
* @param name The unique name/identifier for this guard | ||
* @param description The description of the guard | ||
* @param storage Where the data will be stored | ||
* @param required Whether or not it is a required guard | ||
* @param enabled Whether or not it is currently enabled | ||
*/ | ||
export declare function makeGuard(name: string, description: string, storage?: GdprStorage, required?: boolean, enabled?: boolean | null): GdprGuard; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,19 @@ | ||
import { GdprGuard } from "./GdprGuard"; | ||
/** | ||
* An interface representing a collecion of guards | ||
*/ | ||
export interface GdprGuardCollection extends GdprGuard { | ||
/** | ||
* Determine whether or not the collection has a given guard | ||
* @param name The name of the guard to look for | ||
* @returns TRUE if it is in its hierarchy, FALSE otherwise | ||
* @memberof GdprGuardCollection | ||
*/ | ||
hasGuard(name: string): boolean; | ||
/** | ||
* Retrieve a guard from the collection | ||
* @param name being the name of the guard to retrieve | ||
* @memberof GdprGuardCollection | ||
*/ | ||
getGuard(name: string): GdprGuard | null; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,145 @@ | ||
import { GdprGuard, GdprGuardRaw, GdprRawInto } from "./GdprGuard"; | ||
import { GdprStorage } from "./GdprStorage"; | ||
import { GdprGuardCollection } from "./GdprGuardCollection"; | ||
/** | ||
* Raw representation of a guard group | ||
*/ | ||
export interface GdprGuardGroupRaw extends GdprGuardRaw { | ||
guards: GdprGuardRaw[]; | ||
} | ||
/** | ||
* A group of guards | ||
*/ | ||
export declare class GdprGuardGroup implements GdprGuardCollection, GdprRawInto<GdprGuardGroupRaw> { | ||
name: string; | ||
description: string; | ||
enabled: boolean; | ||
required: boolean; | ||
readonly storage: GdprStorage; | ||
/** | ||
* Binding from guard name to guard | ||
* @protected | ||
*/ | ||
protected bindings: Map<string, GdprGuard>; | ||
/** | ||
* Creates an instance of GdprGuardGroup. | ||
* @ignore | ||
* @param name | ||
* @param [description] | ||
* @param [enabled] | ||
* @param [required] | ||
* @memberof GdprGuardGroup | ||
*/ | ||
constructor(name: string, description?: string, enabled?: boolean, required?: boolean); | ||
/** | ||
* Factory for creating a groupe | ||
* @static | ||
* @param name The name of the group | ||
* @param [description] The description of the group | ||
* @param [enabled=false] Whether or not the group is enabled by default | ||
* @param [required=false] Whether or not the entire group is required | ||
* @returns {GdprGuardGroup} | ||
* @memberof GdprGuardGroup | ||
*/ | ||
static for(name: string, description?: string, enabled?: boolean, required?: boolean): GdprGuardGroup; | ||
/** | ||
* Add a guard to this group | ||
* @param {GdprGuard} guard | ||
* @returns {GdprGuardGroup} | ||
* @memberof GdprGuardGroup | ||
*/ | ||
addGuard(guard: GdprGuard): GdprGuardGroup; | ||
/** | ||
* @inheritDoc | ||
* @memberof GdprGuardGroup | ||
*/ | ||
hasGuard(name: string): boolean; | ||
/** | ||
* @inheritDoc | ||
* @memberof GdprGuardGroup | ||
*/ | ||
getGuard(name: string): GdprGuard | null; | ||
/** | ||
* @inheritDoc | ||
* @memberof GdprGuardGroup | ||
*/ | ||
isEnabled(name: string): boolean; | ||
/** | ||
* @inheritDoc | ||
* @override | ||
* @memberof GdprGuardGroup | ||
* @returns {GdprGuardGroup} | ||
*/ | ||
enable(): GdprGuardGroup; | ||
/** | ||
* @inheritDoc | ||
* @override | ||
* @memberof GdprGuardGroup | ||
* @returns {GdprGuardGroup} | ||
*/ | ||
disable(): GdprGuardGroup; | ||
/** | ||
* @inheritDoc | ||
* @override | ||
* @memberof GdprGuardGroup | ||
* @returns {GdprGuardGroup} | ||
*/ | ||
toggle(): GdprGuardGroup; | ||
/** | ||
* @inheritDoc | ||
* @override | ||
* @memberof GdprGuardGroup | ||
* @returns {GdprGuardGroup} | ||
*/ | ||
makeRequired(): GdprGuardGroup; | ||
/** | ||
* @inheritDoc | ||
* @override | ||
* @memberof GdprGuardGroup | ||
*/ | ||
enableForStorage(type: GdprStorage): GdprGuardGroup; | ||
/** | ||
* @inheritDoc | ||
* @override | ||
* @memberof GdprGuardGroup | ||
*/ | ||
disableForStorage(type: GdprStorage): GdprGuardGroup; | ||
/** | ||
* @inheritDoc | ||
* @override | ||
* @memberof GdprGuardGroup | ||
*/ | ||
toggleForStorage(type: GdprStorage): GdprGuardGroup; | ||
/** | ||
* @inheritDoc | ||
* @override | ||
* @memberof GdprGuardGroup | ||
*/ | ||
raw(): GdprGuardGroupRaw; | ||
/** | ||
* Execute a callback on each guard of this group | ||
* @ignore | ||
* @protected | ||
* @param cb | ||
* @memberof GdprGuardGroup | ||
*/ | ||
protected doForEachGuard(cb: (guard: GdprGuard) => any): GdprGuardGroup; | ||
/** | ||
* Shortcircuit on predicate | ||
* @ignore | ||
* @protected | ||
* @param {(group: GdprGuardCollection) => boolean} pred | ||
* @returns {boolean} | ||
* @memberof GdprManager | ||
*/ | ||
protected reduceSubGroupsPred(pred: (guard: GdprGuardGroup) => boolean): boolean; | ||
/** | ||
* Shortcircuit on finding a matching guard | ||
* @ignore | ||
* @protected | ||
* @param extractor | ||
* @memberof GdprManager | ||
*/ | ||
protected reduceSubGroups(extractor: (guard: GdprGuardCollection & GdprGuard) => GdprGuard | null): GdprGuard | null; | ||
getGuards(): GdprGuard[]; | ||
} |
Oops, something went wrong.