- Standardized import statements and removed unnecessary line breaks for better readability in various components. - Enhanced error handling and logging in the useElectronPrinter hook. - Updated sample data formatting in AgGridShowcase for improved clarity. - Refactored JSX elements for consistent indentation and structure in LandingSample, AuthPage, and EventsPage components. - Consolidated and simplified conditional rendering logic in several components. These changes aim to enhance code maintainability and readability throughout the project.
59 lines
1.7 KiB
TypeScript
59 lines
1.7 KiB
TypeScript
import type { BaseEntity } from './types';
|
|
import { BaseRemoteDataServices } from './base-remote.data-services';
|
|
|
|
/**
|
|
* General-purpose remote data services.
|
|
*
|
|
* A concrete, non-abstract version of BaseRemoteDataServices that
|
|
* can be instantiated directly for standard CRUD modules that don't
|
|
* need additional custom methods.
|
|
*
|
|
* For modules requiring domain-specific operations beyond standard
|
|
* CRUD + lifecycle, extend BaseRemoteDataServices instead and add
|
|
* custom methods using `this.execute()` or `this.customRequest()`.
|
|
*
|
|
* @typeParam E - The domain entity type
|
|
* @typeParam TDTO - The API DTO shape (defaults to E for backward compatibility)
|
|
*
|
|
* @example
|
|
* ```ts
|
|
* // Direct instantiation for standard modules (no transformer)
|
|
* const bookingServices = new CommonRemoteDataServices<BookingEntity>(
|
|
* apiClient,
|
|
* { apiUrl: '/bookings', moduleKey: 'BOOKING' },
|
|
* );
|
|
*
|
|
* const { data } = await bookingServices.getMany();
|
|
* ```
|
|
*
|
|
* @example
|
|
* ```ts
|
|
* // With transformer for DTO ↔ Entity mapping
|
|
* const bookingServices = new CommonRemoteDataServices<BookingEntity, BookingDTO>(
|
|
* apiClient,
|
|
* {
|
|
* apiUrl: '/bookings',
|
|
* moduleKey: 'BOOKING',
|
|
* transformer: new BookingTransformer(),
|
|
* },
|
|
* );
|
|
* ```
|
|
*
|
|
* @example
|
|
* ```ts
|
|
* // For modules needing custom operations, extend the base:
|
|
* class InvoiceDataServices extends BaseRemoteDataServices<InvoiceEntity> {
|
|
* async calculateTax(invoiceId: string) {
|
|
* return this.customRequest<TaxResult>({
|
|
* url: `/invoices/${invoiceId}/calculate-tax`,
|
|
* method: 'POST',
|
|
* });
|
|
* }
|
|
* }
|
|
* ```
|
|
*/
|
|
export class CommonRemoteDataServices<E extends BaseEntity = BaseEntity, TDTO = E> extends BaseRemoteDataServices<
|
|
E,
|
|
TDTO
|
|
> {}
|