ruch
Version:
Revolutionary React TypeScript CLI with hexagonal architecture & AI-powered development assistance. Create maintainable, scalable applications with domain-driven design and integrated AI tooling.
138 lines (121 loc) • 3.02 kB
text/typescript
// Notification Domain Mock Data
// This file contains mock data and utilities for notification domain testing
/**
* TODO: Replace this interface with your actual Notification entity
* Import from: '../entities/Notification'
*/
interface Notification {
id: string;
name: string;
createdAt: string;
updatedAt: string;
// Add your domain-specific fields here
}
/**
* Mock notification data store
*/
class MockNotificationData {
private data: Notification[] = [
{
id: '1',
name: 'Sample Notification 1',
createdAt: '2025-01-01T00:00:00Z',
updatedAt: '2025-01-01T00:00:00Z',
},
{
id: '2',
name: 'Sample Notification 2',
createdAt: '2025-01-02T00:00:00Z',
updatedAt: '2025-01-02T00:00:00Z',
},
{
id: '3',
name: 'Sample Notification 3',
createdAt: '2025-01-03T00:00:00Z',
updatedAt: '2025-01-03T00:00:00Z',
},
];
/**
* Get all notification items
*/
getAll(): Notification[] {
return [...this.data];
}
/**
* Get notification item by ID
*/
getById(id: string): Notification | undefined {
return this.data.find(item => item.id === id);
}
/**
* Create new notification item
*/
create(item: Partial<Notification>): Notification {
const newItem: Notification = {
id: Date.now().toString(),
name: item.name || 'New Notification',
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
...item,
};
this.data.push(newItem);
return newItem;
}
/**
* Update notification item
*/
update(id: string, updates: Partial<Notification>): Notification | undefined {
const index = this.data.findIndex(item => item.id === id);
if (index === -1) {
return undefined;
}
this.data[index] = {
...this.data[index],
...updates,
updatedAt: new Date().toISOString(),
};
return this.data[index];
}
/**
* Delete notification item
*/
delete(id: string): boolean {
const index = this.data.findIndex(item => item.id === id);
if (index === -1) {
return false;
}
this.data.splice(index, 1);
return true;
}
/**
* Reset data to initial state (useful for tests)
*/
reset(): void {
this.data = [
{
id: '1',
name: 'Sample Notification 1',
createdAt: '2025-01-01T00:00:00Z',
updatedAt: '2025-01-01T00:00:00Z',
},
{
id: '2',
name: 'Sample Notification 2',
createdAt: '2025-01-02T00:00:00Z',
updatedAt: '2025-01-02T00:00:00Z',
},
{
id: '3',
name: 'Sample Notification 3',
createdAt: '2025-01-03T00:00:00Z',
updatedAt: '2025-01-03T00:00:00Z',
},
];
}
/**
* Add custom methods for your domain-specific operations
* Example: getByStatus, getByUser, etc.
*/
}
// Export singleton instance
export const mockNotificationData = new MockNotificationData();