update Implement standardized documentation for all database modules, including purpose, rules, and requirements for each CRUD operation; refactor existing comments to follow new documentation standard
```
This commit is contained in:
2025-05-17 10:02:05 +00:00
parent b8309596be
commit 59cdf7257b
135 changed files with 1207 additions and 37 deletions

View File

@@ -1,6 +1,11 @@
// api method for create notification record
// PURPOSE:
// Create new notification record
//
// RULES:
// TBA
// 1. Uses COL_NOTIFICATIONS collection
// 2. Requires NotificationFormProps type data
// 3. Returns Promise<RecordModel> with created record
// 4. Errors handled by caller
import { pb } from '@/lib/pb';
import { COL_NOTIFICATIONS } from '@/constants';
import type { NotificationFormProps } from '@/components/dashboard/notification/type.d';

View File

@@ -1,6 +1,11 @@
// api method for delete notification record
// PURPOSE:
// Delete notification record by ID
//
// RULES:
// TBA
// 1. Uses COL_NOTIFICATIONS collection
// 2. Requires valid notification ID string
// 3. Returns Promise<boolean> indicating success
// 4. Errors handled by caller
import { pb } from '@/lib/pb';
import { COL_NOTIFICATIONS } from '@/constants';

View File

@@ -1,3 +1,11 @@
// PURPOSE:
// Count active notification records
//
// RULES:
// 1. Uses COL_CUSTOMERS collection
// 2. Filters records with status="active"
// 3. Returns Promise<number> with count
// 4. Errors handled by caller
import { COL_CUSTOMERS } from '@/constants';
import { pb } from '@/lib/pb';

View File

@@ -1,6 +1,12 @@
// api method for get all notification records
// PURPOSE:
// Get all notification records
//
// RULES:
// TBA
// 1. Uses COL_NOTIFICATIONS collection
// 2. Returns Promise<RecordModel[]> with all records
// 3. Accepts optional options parameter
// 4. Uses getFullList API
// 5. Errors handled by caller
import { pb } from '@/lib/pb';
import { COL_NOTIFICATIONS } from '@/constants';
import type { RecordModel } from 'pocketbase';

View File

@@ -1,3 +1,12 @@
// PURPOSE:
// Get total count of notification records
//
// RULES:
// 1. Uses COL_NOTIFICATIONS collection
// 2. Returns Promise<number> with total count
// 3. Uses getList API
// 4. Errors handled by caller
//
import { pb } from '@/lib/pb';
import { COL_CUSTOMERS } from '@/constants';

View File

@@ -1,3 +1,11 @@
// PURPOSE:
// Count blocked notification records
//
// RULES:
// 1. Uses COL_CUSTOMERS collection
// 2. Filters records with status="blocked"
// 3. Returns Promise<number> with count
// 4. Errors handled by caller
import { COL_CUSTOMERS } from '@/constants';
import { pb } from '@/lib/pb';

View File

@@ -1,6 +1,12 @@
// api method for get notification by id
// PURPOSE:
// - Provides functionality to retrieve a single notification by ID
// - Returns complete notification details for specified ID
//
// RULES:
// TBA
// - Must validate input ID format
// - Should handle cases where notification is not found
// - Must respect data privacy and only return authorized fields
// - Should optimize query performance for single record retrieval
import { pb } from '@/lib/pb';
import { COL_NOTIFICATIONS } from '@/constants';
import type { RecordModel } from 'pocketbase';

View File

@@ -1,6 +1,12 @@
// PURPOSE:
// Get notifications for specific user ID
//
// RULES:
// api method for get notifications by user id
// 1. Uses COL_NOTIFICATIONS collection
// 2. Requires valid user ID string
// 3. Returns Promise<Notification[]> with user's notifications
// 4. Expands author and to_user_id relations
// 5. Sorts by created date (newest first)
import { COL_NOTIFICATIONS } from '@/constants';
import { pb } from '@/lib/pb';

View File

@@ -1,3 +1,11 @@
// PURPOSE:
// Count pending customer notifications
//
// RULES:
// 1. Uses COL_CUSTOMERS collection
// 2. Filters records with status="pending"
// 3. Returns Promise<number> with count
// 4. Errors handled by caller
import { COL_CUSTOMERS } from '@/constants';
import { pb } from '@/lib/pb';

View File

@@ -1,6 +1,13 @@
// PURPOSE:
// Get all unread notifications for specified user ID
//
// RULES:
// api method for get notifications by user id
// 1. Uses COL_NOTIFICATIONS collection
// 2. Filters by to_user_id and read=false status
// 3. Expands author and to_user_id relations
// 4. Sorts by created date (newest first)
// 5. Returns Promise<Notification[]>
// 6. Disables caching for real-time results
import { COL_NOTIFICATIONS } from '@/constants';
import { pb } from '@/lib/pb';

View File

@@ -1,3 +1,10 @@
// PURPOSE:
// Example/Test component for notifications
//
// RULES:
// 1. Returns fixed string for testing
// 2. Not used in production
// 3. Follows project coding standards
export function helloCustomer(): string {
return 'Hello from Customers module!';
}

View File

@@ -1,6 +1,12 @@
// api method for update notification record
// PURPOSE:
// Update notification record
//
// RULES:
// TBA
// 1. Uses COL_NOTIFICATIONS collection
// 2. Requires valid notification ID string
// 3. Accepts Partial<NotificationFormProps> update data
// 4. Returns Promise<RecordModel> with updated record
// 5. Errors handled by caller
import { pb } from '@/lib/pb';
import { COL_NOTIFICATIONS } from '@/constants';
import type { RecordModel } from 'pocketbase';

View File

@@ -1,6 +1,12 @@
// api method for update notification record
// PURPOSE:
// Mark single notification as read
//
// RULES:
// TBA
// 1. Uses COL_NOTIFICATIONS collection
// 2. Requires valid notification ID string
// 3. Updates read status to true
// 4. Returns Promise<RecordModel> with updated record
// 5. Errors handled by caller
import { COL_NOTIFICATIONS } from '@/constants';
import type { RecordModel } from 'pocketbase';