UNPKG

@just-in/core

Version:

A TypeScript-first framework for building adaptive digital health interventions.

73 lines 3.22 kB
import { JUser } from "./user.type"; import { NewUserRecord } from "./user.type"; /** * @type {Map<string, JUser>} _users - In-memory cache for user data. * This Map enables quick lookups, insertions, and deletions by `id`. * @private */ export declare const _users: Map<string, JUser>; /** * Ensures that the DataManager has been initialized before any user * management operation can proceed. * * @throws Error if DataManager is not initialized. * @private */ export declare const _checkInitialization: () => void; /** * Adds one user to the Users collection in a single operation. * @param {object} user - The user object to add. * @returns {Promise<JUser | null>} Resolves with the added user or null if the operation fails. * @throws {Error} If no user is provided or if the user fails validation. */ export declare const addUser: (user: NewUserRecord) => Promise<(JUser | null)>; /** * Adds multiple users to the Users collection in a single operation. * @param {NewUserRecord[]} users - An array of user objects to add. * @returns {Promise<(JUser | null)[]>} Resolves with the added users or null if the operation fails. * @throws {Error} If no users are provided or if any user fails validation. */ export declare const addUsers: (users: NewUserRecord[]) => Promise<(JUser | null)[]>; /** * UserManager provides methods for managing users. * * Includes user creation, deletion, retrieval, and updates. * @namespace UserManager */ export declare const UserManager: { init: () => Promise<void>; addUser: (user: NewUserRecord) => Promise<(JUser | null)>; addUsers: (users: NewUserRecord[]) => Promise<(JUser | null)[]>; getAllUsers: () => JUser[]; getUserByUniqueIdentifier: (uniqueIdentifier: string) => JUser | null; updateUserByUniqueIdentifier: (userUniqueIdentifier: string, attributesToUpdate: Record<string, any>) => Promise<JUser | null>; deleteUserByUniqueIdentifier: (uniqueIdentifier: string) => Promise<void>; deleteAllUsers: () => Promise<void>; shutdown: () => void; }; /** * TestingUserManager provides additional utilities for testing. * * @namespace TestingUserManager * @private */ export declare const TestingUserManager: { updateUserById: (userId: string, attributesToUpdate: object) => Promise<JUser>; deleteUserById: (userId: string) => Promise<void>; transformUserDocument: (doc: any) => JUser; _checkInitialization: () => void; refreshCache: () => Promise<void>; isIdentifierUnique: (userUniqueIdentifier: string) => Promise<boolean>; setupChangeListeners: () => void; _users: Map<string, JUser>; init: () => Promise<void>; addUser: (user: NewUserRecord) => Promise<(JUser | null)>; addUsers: (users: NewUserRecord[]) => Promise<(JUser | null)[]>; getAllUsers: () => JUser[]; getUserByUniqueIdentifier: (uniqueIdentifier: string) => JUser | null; updateUserByUniqueIdentifier: (userUniqueIdentifier: string, attributesToUpdate: Record<string, any>) => Promise<JUser | null>; deleteUserByUniqueIdentifier: (uniqueIdentifier: string) => Promise<void>; deleteAllUsers: () => Promise<void>; shutdown: () => void; }; //# sourceMappingURL=user-manager.d.ts.map