Skip to content

Commit

Permalink
Merge branch 'release/v2.3.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Voltra committed Feb 12, 2023
2 parents c4d7505 + 323ed52 commit 413b053
Show file tree
Hide file tree
Showing 30 changed files with 860 additions and 88 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ For instance you can use it like this:
```javascript
const manager = GdprManagerBuilder
.make()
.withBannerShown(!!localStorage.getItem("gdpr_banner"))
.startRequiredGroup(GdprStorage.Cookie, "Functionalities", "Information purely used for the user's experience")
// This is a group that by default uses cookies for storage, every option and the group itself is required
.withEnabledGuard("PHP_SESSID", "Server session identifier")
Expand Down
78 changes: 76 additions & 2 deletions dist/GdprGuard.d.ts
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;
14 changes: 14 additions & 0 deletions dist/GdprGuardCollection.d.ts
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;
}
113 changes: 113 additions & 0 deletions dist/GdprGuardGroup.d.ts
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[];
}
Loading

0 comments on commit 413b053

Please sign in to comment.