From 7acda53d57492a658100fe0d326d05bf751c3251 Mon Sep 17 00:00:00 2001 From: Philipp Kunz Date: Thu, 30 May 2024 18:53:52 +0200 Subject: [PATCH] BREAKING CHANGE(api): changed API to be more concise --- package.json | 1 + pnpm-lock.yaml | 3 +++ ts/00_commitinfo_data.ts | 2 +- ts/smartguard.classes.guard.ts | 6 +++++- ts/smartguard.classes.guardset.ts | 8 ++++---- 5 files changed, 14 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 74fd15d..8e9a265 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,7 @@ "@types/node": "^20.12.13" }, "dependencies": { + "@api.global/typedrequest": "^3.0.25", "@push.rocks/smartpromise": "^4.0.2", "@push.rocks/smartrequest": "^2.0.15" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index cb8b060..4ac39b7 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8,6 +8,9 @@ importers: .: dependencies: + '@api.global/typedrequest': + specifier: ^3.0.25 + version: 3.0.25 '@push.rocks/smartpromise': specifier: ^4.0.2 version: 4.0.3 diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index 26f7894..a9ea55d 100644 --- a/ts/00_commitinfo_data.ts +++ b/ts/00_commitinfo_data.ts @@ -3,6 +3,6 @@ */ export const commitinfo = { name: '@push.rocks/smartguard', - version: '2.0.4', + version: '3.0.0', description: 'A TypeScript library for creating and managing validation guards, aiding in data validation and security checks.' } diff --git a/ts/smartguard.classes.guard.ts b/ts/smartguard.classes.guard.ts index 6cad160..9be8b0d 100644 --- a/ts/smartguard.classes.guard.ts +++ b/ts/smartguard.classes.guard.ts @@ -12,8 +12,12 @@ export class Guard { * executes the guard against a data argument; * @param dataArg */ - public async executeGuardWithData(dataArg: T) { + public async exec(dataArg: T) { const result = await this.guardFunction(dataArg); return result; } + + public async execForTR() { + + } } diff --git a/ts/smartguard.classes.guardset.ts b/ts/smartguard.classes.guardset.ts index 5ce2f08..baf610b 100644 --- a/ts/smartguard.classes.guardset.ts +++ b/ts/smartguard.classes.guardset.ts @@ -19,11 +19,11 @@ export class GuardSet extends Guard { * executes all guards in all guardSets against a data argument * @param dataArg */ - public async executeAllGuardsWithData(dataArg: T) { + public async execAllWithData(dataArg: T) { const resultPromises: Array> = []; for (const guard of this.guards) { - const guardResultPromise = guard.executeGuardWithData(dataArg); + const guardResultPromise = guard.exec(dataArg); resultPromises.push(guardResultPromise); } @@ -36,7 +36,7 @@ export class GuardSet extends Guard { * @param dataArg */ public async allGuardsPass(dataArg: T): Promise { - const results = await this.executeAllGuardsWithData(dataArg); + const results = await this.execAllWithData(dataArg); return results.every(result => result); } @@ -45,7 +45,7 @@ export class GuardSet extends Guard { * @param dataArg */ public async anyGuardsPass(dataArg: T): Promise { - const results = await this.executeAllGuardsWithData(dataArg); + const results = await this.execAllWithData(dataArg); return results.some(result => result); } }