@makolabs/ripple
Version:
Simple Svelte 5 powered component library ✨
80 lines (79 loc) • 2.62 kB
TypeScript
/**
* Mock User Management Functions
*
* Mock implementation of user management functions for testing and development.
* These are regular async functions (NOT remote functions) that match the UserManagementAdapter interface.
* They store data in memory and work in both SvelteKit and non-SvelteKit contexts (like Storybook).
*
* Note: These are NOT actual remote functions because remote functions require a SvelteKit server context
* which doesn't exist in Storybook/tests. They're regular async functions that match the adapter interface.
*
* To set initial data, use the resetState function:
* ```ts
* import { resetState } from '@makolabs/ripple/funcs/mock-user-management';
* await resetState({ initialUsers: [...], simulateDelay: false });
* ```
*/
import type { User, GetUsersOptions, GetUsersResult } from '../index.js';
/**
* Reset mock adapter state
*/
export declare function resetState(options?: {
initialUsers?: User[];
simulateDelay?: boolean;
delayMs?: number;
}): Promise<void>;
/**
* Get users with pagination and sorting
* Matches UserManagementAdapter.getUsers signature
*/
export declare function getUsers(options: GetUsersOptions): Promise<GetUsersResult>;
/**
* Create a new user
* Matches UserManagementAdapter.createUser signature
*/
export declare function createUser(userData: Partial<User>): Promise<User>;
/**
* Update an existing user
* Matches UserManagementAdapter.updateUser signature
*/
export declare function updateUser(options: {
userId: string;
userData: Partial<User>;
}): Promise<User>;
/**
* Delete a single user
* Matches UserManagementAdapter.deleteUser signature
*/
export declare function deleteUser(userId: string): Promise<void>;
/**
* Delete multiple users
* Matches UserManagementAdapter.deleteUsers signature
*/
export declare function deleteUsers(userIds: string[]): Promise<void>;
/**
* Get permissions for a specific user
* Matches UserManagementAdapter.getUserPermissions signature
*/
export declare function getUserPermissions(userId: string): Promise<string[]>;
/**
* Update permissions for a specific user
* Matches UserManagementAdapter.updateUserPermissions signature
*/
export declare function updateUserPermissions(options: {
userId: string;
permissions: string[];
}): Promise<void>;
/**
* Generate API key (mock implementation)
* Matches UserManagementAdapter.generateApiKey signature
*/
export declare function generateApiKey(options: {
userId: string;
permissions: string[];
revokeOld?: boolean;
}): Promise<{
success: boolean;
apiKey: string;
message: string;
}>;