import { Logger } from 'winston'; import { IPermitConfig } from '../config'; import { IUser } from '../enforcement/interfaces'; import { Dict } from '../utils/dict'; export interface ITenant { key: string; name: string; description?: string; } interface IOperation { run: () => Promise; } export declare type IReadOperation = IOperation; export declare type IWriteOperation = IOperation; export declare class ReadOperation implements IReadOperation { private callback; constructor(callback: () => Promise); run(): Promise; } export declare class WriteOperation implements IWriteOperation { private callback; constructor(callback: () => Promise); run(): Promise; } /** * This interface contains *read actions* that goes outside * of your local network and queries permit.io cloud api. * You should be aware that these actions incur some cross-cloud latency. */ export interface IReadApis { getUser(userKey: string): ReadOperation; getRole(roleKey: string): ReadOperation; getTenant(tenantKey: string): ReadOperation; getAssignedRoles(userKey: string, tenantKey?: string): ReadOperation; } /** * This interface contains *write actions* (or mutations) that manipulate remote * state by calling the permit.io api. These api calls goes *outside* your local network. * You should be aware that these actions incur some cross-cloud latency. */ export interface IWriteApis { syncUser(user: IUser): WriteOperation; deleteUser(userKey: string): WriteOperation; createTenant(tenant: ITenant): WriteOperation; updateTenant(tenant: ITenant): WriteOperation; deleteTenant(tenantKey: string): WriteOperation; assignRole(userKey: string, roleKey: string, tenantKey: string): WriteOperation; unassignRole(userKey: string, roleKey: string, tenantKey: string): WriteOperation; } export interface IPermitApi extends IReadApis, IWriteApis { } export interface IAPIClient { api: IPermitApi; } export declare class MutationsClient implements IReadApis, IWriteApis, IAPIClient { private config; private logger; private client; constructor(config: IPermitConfig, logger: Logger); getUser(userKey: string): ReadOperation; getRole(roleKey: string): ReadOperation; getTenant(tenantKey: string): ReadOperation; getAssignedRoles(userKey: string, tenantKey?: string): ReadOperation; syncUser(user: IUser): WriteOperation; deleteUser(userKey: string): WriteOperation; createTenant(tenant: ITenant): WriteOperation; updateTenant(tenant: ITenant): WriteOperation; deleteTenant(tenantKey: string): WriteOperation; assignRole(userKey: string, roleKey: string, tenantKey: string): WriteOperation; unassignRole(userKey: string, roleKey: string, tenantKey: string): WriteOperation; read(...operations: IReadOperation[]): Promise; write(...operations: IWriteOperation[]): Promise; get api(): IPermitApi; getMethods(): IAPIClient; } export {};