-
Notifications
You must be signed in to change notification settings - Fork 0
/
allow-owner.decorator.ts
30 lines (25 loc) · 893 Bytes
/
allow-owner.decorator.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import { SetMetadata } from '@nestjs/common';
import { CollectionDtoUnion } from './persistence/dto/collection-dto-union.type';
export const ALLOW_OWNER_METADATA_KEY = 'allow-owner';
export type AllowOwnerArgs =
| AllowOwnerCollectionArgs
| AllowOwnerEdgeArgs
| AllowOwnerVertexArgs;
export interface AllowOwnerBaseArgs {
graphIdFromBodyPath?: string;
graphIdFromParamKey?: string;
permission?: string;
sudoMaskKey?: string;
}
export interface AllowOwnerCollectionArgs extends AllowOwnerBaseArgs {
graphObjectType: 'collection';
graphObjectCollection?: keyof CollectionDtoUnion;
}
export interface AllowOwnerEdgeArgs extends AllowOwnerBaseArgs {
graphObjectType: 'edge';
}
export interface AllowOwnerVertexArgs extends AllowOwnerBaseArgs {
graphObjectType: 'vertex';
}
export const AllowOwner = (arg: AllowOwnerArgs) =>
SetMetadata(ALLOW_OWNER_METADATA_KEY, arg);