haystack-nclient
Version:
Project Haystack Network Client
78 lines (77 loc) • 2.37 kB
TypeScript
import { HaysonDict, HDict, HGrid, HMarker, HRef } from 'haystack-core';
import { ClientServiceConfig } from '../ClientServiceConfig';
import { ReadOptions } from '../RecordService';
/**
* A role record
*/
export interface Role extends HDict {
id?: HRef;
userRole: HMarker;
}
/**
* Optional parameters available to readByFilter query
*/
export type RolesReadOptions = Omit<ReadOptions, 'unique'>;
/**
* An implementation of the FIN Roles service.
*/
export declare class RolesService<RoleType extends Role = Role> {
#private;
/**
* Constructs a new roles service object.
*
* @param serviceConfig Service configuration.
*/
constructor(serviceConfig: ClientServiceConfig);
/**
* Query all roles.
*
* @param options Optional options for read operation.
* @returns The result of the read operation.
*/
readAll(options?: RolesReadOptions): Promise<RoleType[]>;
/**
* Read a role via its id.
*
* @param id The id of the role to read.
* @returns The role record.
* @throws An error if the role can't be found.
*/
readById(id: string | HRef): Promise<RoleType>;
/**
* Query some roles via a haystack filter.
*
* @param filter The haystack filter to query by.
* @param options Optional options for read operation.
* @returns The result of the read operation.
*/
readByFilter(filter: string, options?: RolesReadOptions): Promise<HGrid<RoleType>>;
/**
* Create multiple role records.
*
* @param role The roles to create.
* @returns A grid of roles.
*/
create(roles: RoleType[] | HaysonDict[] | HGrid<RoleType>): Promise<HGrid<RoleType>>;
/**
* Create a single role record.
*
* @param role The role record to create.
* @returns The created role record.
*/
createRole(role: RoleType | HaysonDict): Promise<RoleType>;
/**
* Update a role record.
*
* @param role The role record to update.
* @returns A updated record. Please note, this record doesn't
* have any role information just the `id` and `mod`.
*/
update(role: RoleType | HaysonDict): Promise<RoleType>;
/**
* Delete a role record via its id.
*
* @param id The id of the record to delete.
*/
deleteById(id: string | HRef): Promise<void>;
}