This commit broadens the search functionality within privacy.sexy by including documentation text in the search scope. Users can now find scripts and categories not only by their names but also by content in their documentation. This improvement aims to make the discovery of relevant scripts and information more intuitive and comprehensive. Key changes: - Documentation text is now searchable, enhancing the ability to discover scripts and categories based on content details. Other supporting changes: - Remove interface prefixes (`I`) from related interfaces to adhere to naming conventions, enhancing code readability. - Refactor filtering to separate actual filtering logic from filter state management, improving the structure for easier maintenance. - Improve test coverage to ensure relability of existing and new search capabilities. - Test coverage expanded to ensure the reliability of the new search capabilities.
72 lines
1.7 KiB
TypeScript
72 lines
1.7 KiB
TypeScript
import { BaseEntity } from '@/infrastructure/Entity/BaseEntity';
|
|
import { IScript } from '@/domain/IScript';
|
|
import { RecommendationLevel } from '@/domain/RecommendationLevel';
|
|
import { IScriptCode } from '@/domain/IScriptCode';
|
|
import { SelectedScriptStub } from './SelectedScriptStub';
|
|
|
|
export class ScriptStub extends BaseEntity<string> implements IScript {
|
|
public name = `name${this.id}`;
|
|
|
|
public code: IScriptCode = {
|
|
execute: `REM execute-code (${this.id})`,
|
|
revert: `REM revert-code (${this.id})`,
|
|
};
|
|
|
|
public docs: readonly string[] = new Array<string>();
|
|
|
|
public level? = RecommendationLevel.Standard;
|
|
|
|
private isReversible: boolean | undefined = undefined;
|
|
|
|
constructor(public readonly id: string) {
|
|
super(id);
|
|
}
|
|
|
|
public canRevert(): boolean {
|
|
if (this.isReversible === undefined) {
|
|
return Boolean(this.code.revert);
|
|
}
|
|
return this.isReversible;
|
|
}
|
|
|
|
public withLevel(value: RecommendationLevel | undefined): this {
|
|
this.level = value;
|
|
return this;
|
|
}
|
|
|
|
public withCode(value: string): this {
|
|
this.code = {
|
|
execute: value,
|
|
revert: this.code.revert,
|
|
};
|
|
return this;
|
|
}
|
|
|
|
public withName(name: string): this {
|
|
this.name = name;
|
|
return this;
|
|
}
|
|
|
|
public withReversibility(isReversible: boolean): this {
|
|
this.isReversible = isReversible;
|
|
return this;
|
|
}
|
|
|
|
public withRevertCode(revertCode?: string): this {
|
|
this.code = {
|
|
execute: this.code.execute,
|
|
revert: revertCode,
|
|
};
|
|
return this;
|
|
}
|
|
|
|
public withDocs(docs: readonly string[]): this {
|
|
this.docs = docs;
|
|
return this;
|
|
}
|
|
|
|
public toSelectedScript(): SelectedScriptStub {
|
|
return new SelectedScriptStub(this);
|
|
}
|
|
}
|