haystack-nclient
Version:
Project Haystack Network Client
75 lines (74 loc) • 2.33 kB
TypeScript
import { ClientServiceConfig } from './ClientServiceConfig';
import { HDict, HMarker, HRef, HGrid, HaysonDict, HList } from 'haystack-core';
import { ReadOptions } from './RecordService';
/**
* A user record.
*/
export interface User extends HDict {
id?: HRef;
user: HMarker;
}
export type UserReadOptions = Omit<ReadOptions, 'unique'>;
/**
* An implementation of the FIN user service.
*/
export declare class UserService<UserType extends User = User> {
#private;
/**
* Constructs a new user service object.
*
* @param serviceConfig Service configuration.
*/
constructor(serviceConfig: ClientServiceConfig);
/**
* Read a user via its id.
*
* @param id The id of the user to read.
* @returns The user record.
* @throws An error if the user can't be found.
*/
readById(id: string | HRef): Promise<UserType>;
/**
* Query some users 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?: UserReadOptions): Promise<HGrid<UserType>>;
/**
* Query all users.
*
* @param options Optional options for read operation.
* @returns The result of the read operation.
*/
readAll(options?: UserReadOptions): Promise<HGrid<UserType>>;
/**
* Create multiple user records.
*
* @param users The users to create.
* @returns A grid of users.
*/
create(users: UserType[] | HaysonDict[] | HGrid<UserType> | HList<UserType>): Promise<HGrid<UserType>>;
/**
* Create a single user record.
*
* @param user The user record to create.
* @returns The created user record.
*/
createUser(user: UserType | HaysonDict): Promise<UserType>;
/**
* Update a user record.
*
* @param user The user record to update.
* @returns A updated record. Please note, this record doesn't
* have any user information just the `id` and `mod`.
*/
update(user: UserType | HaysonDict): Promise<UserType>;
/**
* Delete a user record via its id.
*
* @param id The id of the record to delete.
*/
deleteById(id: string | HRef): Promise<void>;
}