53 lines
1.5 KiB
TypeScript
53 lines
1.5 KiB
TypeScript
|
|
import * as plugins from '../../plugins.js';
|
||
|
|
import { DcRouterDb } from '../classes.dcrouter-db.js';
|
||
|
|
import type { ISecurityBlockRule, TSecurityBlockRuleMatchMode, TSecurityBlockRuleType } from '../../../ts_interfaces/data/security-policy.js';
|
||
|
|
|
||
|
|
const getDb = () => DcRouterDb.getInstance().getDb();
|
||
|
|
|
||
|
|
@plugins.smartdata.Collection(() => getDb())
|
||
|
|
export class SecurityBlockRuleDoc extends plugins.smartdata.SmartDataDbDoc<SecurityBlockRuleDoc, SecurityBlockRuleDoc> implements ISecurityBlockRule {
|
||
|
|
@plugins.smartdata.unI()
|
||
|
|
@plugins.smartdata.svDb()
|
||
|
|
public id!: string;
|
||
|
|
|
||
|
|
@plugins.smartdata.svDb()
|
||
|
|
public type!: TSecurityBlockRuleType;
|
||
|
|
|
||
|
|
@plugins.smartdata.svDb()
|
||
|
|
public value!: string;
|
||
|
|
|
||
|
|
@plugins.smartdata.svDb()
|
||
|
|
public matchMode?: TSecurityBlockRuleMatchMode;
|
||
|
|
|
||
|
|
@plugins.smartdata.svDb()
|
||
|
|
public enabled: boolean = true;
|
||
|
|
|
||
|
|
@plugins.smartdata.svDb()
|
||
|
|
public reason?: string;
|
||
|
|
|
||
|
|
@plugins.smartdata.svDb()
|
||
|
|
public createdAt: number = Date.now();
|
||
|
|
|
||
|
|
@plugins.smartdata.svDb()
|
||
|
|
public updatedAt: number = Date.now();
|
||
|
|
|
||
|
|
@plugins.smartdata.svDb()
|
||
|
|
public createdBy: string = 'system';
|
||
|
|
|
||
|
|
constructor() {
|
||
|
|
super();
|
||
|
|
}
|
||
|
|
|
||
|
|
public static async findById(id: string): Promise<SecurityBlockRuleDoc | null> {
|
||
|
|
return await SecurityBlockRuleDoc.getInstance({ id });
|
||
|
|
}
|
||
|
|
|
||
|
|
public static async findAll(): Promise<SecurityBlockRuleDoc[]> {
|
||
|
|
return await SecurityBlockRuleDoc.getInstances({});
|
||
|
|
}
|
||
|
|
|
||
|
|
public static async findEnabled(): Promise<SecurityBlockRuleDoc[]> {
|
||
|
|
return await SecurityBlockRuleDoc.getInstances({ enabled: true });
|
||
|
|
}
|
||
|
|
}
|