瀏覽代碼

Add revoke factory methods

Allow resources to revoke permissions through the revokeXXXXX() methods.
master
TheoryOfNekomata 8 月之前
父節點
當前提交
f5c7669d7d
共有 1 個檔案被更改,包括 30 行新增0 行删除
  1. +30
    -0
      src/core.ts

+ 30
- 0
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<T extends BaseSchema> {
@@ -155,6 +161,30 @@ export const resource = <T extends BaseSchema>(schema: T): Resource<T> => {
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;
},


Loading…
取消
儲存