@prefecthq/prefect-ui-library
Version:
This library is the Vue and Typescript component library for [Prefect 2](https://github.com/PrefectHQ/prefect) and [Prefect Cloud 2](https://www.prefect.io/cloud/). _The components and utilities in this project are not meant to be used independently_.
10 lines (9 loc) • 728 B
TypeScript
import { WorkspacePermission } from '../services/can';
export type ObjectTypesWithPermissions = WorkspacePermission extends `${string}:${infer TObject}` ? TObject : never;
type ActionsForObjectsHelper<O extends string, T extends string> = T extends `${infer Action}:${infer TObject}` ? TObject extends O ? Action : never : never;
type PermissionsForObjectType<TObjectType extends ObjectTypesWithPermissions> = ActionsForObjectsHelper<TObjectType, WorkspacePermission>;
export type ObjectLevelCan<TObjectType extends ObjectTypesWithPermissions> = {
[key in PermissionsForObjectType<TObjectType>]: boolean;
};
export declare function createObjectLevelCan<T extends ObjectTypesWithPermissions>(): ObjectLevelCan<T>;
export {};