From f5c7669d7d4502580cdabab6ca8a1d0bf55908bb Mon Sep 17 00:00:00 2001 From: TheoryOfNekomata Date: Wed, 13 Mar 2024 18:41:59 +0800 Subject: [PATCH] Add revoke factory methods Allow resources to revoke permissions through the revokeXXXXX() methods. --- src/core.ts | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/core.ts b/src/core.ts index eaa1988..1d98eaa 100644 --- a/src/core.ts +++ b/src/core.ts @@ -44,6 +44,12 @@ interface ResourceFactory { allowPatch(): this; allowEmplace(): this; allowDelete(): this; + revokeFetchCollection(): this; + revokeFetchItem(): this; + revokeCreate(): this; + revokePatch(): this; + revokeEmplace(): this; + revokeDelete(): this; } export interface ResourceData { @@ -155,6 +161,30 @@ export const resource = (schema: T): Resource => { canDelete = true; return this; }, + revokeFetchCollection() { + canFetchCollection = false; + return this; + }, + revokeFetchItem() { + canFetchItem = false; + return this; + }, + revokeCreate() { + canCreate = false; + return this; + }, + revokePatch() { + canPatch = false; + return this; + }, + revokeEmplace() { + canEmplace = false; + return this; + }, + revokeDelete() { + canDelete = false; + return this; + }, get canCreate() { return canCreate; },