refactor: tenant proxy providers

This commit is contained in:
Ahmed Bouhuolia
2025-02-15 23:52:12 +02:00
parent 36851d3209
commit 5c0bb52b59
302 changed files with 2396 additions and 1677 deletions

View File

@@ -10,6 +10,7 @@ import {
IVendorNewDTO,
} from '../types/Vendors.types';
import { CreateEditVendorDTOService } from './CreateEditVendorDTO';
import { TenantModelProxy } from '@/modules/System/models/TenantBaseModel';
@Injectable()
export class CreateVendorService {
@@ -25,7 +26,7 @@ export class CreateVendorService {
private readonly transformDTO: CreateEditVendorDTOService,
@Inject(Vendor.name)
private readonly vendorModel: typeof Vendor,
private readonly vendorModel: TenantModelProxy<typeof Vendor>,
) {}
/**
@@ -46,9 +47,11 @@ export class CreateVendorService {
} as IVendorEventCreatingPayload);
// Creates a new contact as vendor.
const vendor = await this.vendorModel.query(trx).insertAndFetch({
...vendorObject,
});
const vendor = await this.vendorModel()
.query(trx)
.insertAndFetch({
...vendorObject,
});
// Triggers `onVendorCreated` event.
await this.eventPublisher.emitAsync(events.vendors.onCreated, {
vendorId: vendor.id,