UNPKG

recallrai

Version:

Official Node.js SDK for RecallrAI - Revolutionary contextual memory system that enables AI assistants to form meaningful connections between conversations, just like human memory.

68 lines (67 loc) 1.9 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.UserList = exports.UserModel = void 0; const schemas_1 = require("./schemas"); /** * Represents a user in the RecallrAI system. */ class UserModel { /** * Creates a new UserModel instance * * @param data - User data */ constructor(data) { const validated = schemas_1.userSchema.parse(data); this.userId = validated.userId; this.metadata = validated.metadata; this.createdAt = validated.createdAt; this.lastActiveAt = validated.lastActiveAt; } /** * Create a UserModel instance from an API response * * @param data - API response data * @returns A UserModel instance */ static fromApiResponse(data) { const userData = data.user; return new UserModel({ userId: userData.user_id, metadata: userData.metadata, createdAt: new Date(userData.created_at), lastActiveAt: new Date(userData.last_active_at), }); } } exports.UserModel = UserModel; /** * Represents a paginated list of users. */ class UserList { /** * Creates a new UserList instance * * @param data - User list data */ constructor(data) { const validated = schemas_1.userListSchema.parse(data); this.users = validated.users; this.total = validated.total; this.hasMore = validated.hasMore; } /** * Create a UserList instance from an API response * * @param data - API response data * @returns A UserList instance */ static fromApiResponse(data) { return new UserList({ users: data.users.map((user) => UserModel.fromApiResponse({ user })), total: data.total, hasMore: data.has_more, }); } } exports.UserList = UserList;