UNPKG

haystack-nclient

Version:

Project Haystack Network Client

78 lines (77 loc) 2.44 kB
import { HDict, HGrid, HMarker, HRef, HaysonDict, HList } from 'haystack-core'; import { ClientServiceConfig } from '../ClientServiceConfig'; import { ReadOptions } from '../RecordService'; /** * A group record */ export interface Group extends HDict { id?: HRef; userGroup: HMarker; } /** * Optional parameters available to readByFilter query */ export type GroupsReadOptions = Omit<ReadOptions, 'unique'>; /** * An implementation of the FIN Groups service. */ export declare class GroupsService<GroupType extends Group = Group> { #private; /** * Constructs a new groups service object. * * @param serviceConfig Service configuration. */ constructor(serviceConfig: ClientServiceConfig); /** * Query all groups. * * @param options Optional options for read operation. * @returns The result of the read operation. */ readAll(options?: GroupsReadOptions): Promise<GroupType[]>; /** * Read a group via its id. * * @param id The id of the group to read. * @returns The group record. * @throws An error if the group can't be found. */ readById(id: string | HRef): Promise<GroupType>; /** * Query some groups 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?: GroupsReadOptions): Promise<HGrid<GroupType>>; /** * Create multiple group records. * * @param groups The groups to create. * @returns A grid of groups. */ create(groups: GroupType[] | HaysonDict[] | HGrid<GroupType> | HList<GroupType>): Promise<HGrid<GroupType>>; /** * Create a single group record. * * @param group The group record to create. * @returns The created group record. */ createGroup(group: GroupType | HaysonDict): Promise<GroupType>; /** * Update a group record. * * @param group The group record to update. * @returns A updated record. Please note, this record doesn't * have any group information just the `id` and `mod`. */ update(group: GroupType | HaysonDict): Promise<GroupType>; /** * Delete a group record via its id. * * @param id The id of the record to delete. */ deleteById(id: string | HRef): Promise<void>; }