@elsikora/nestjs-crud-automator
Version:
A library for automating the creation of CRUD operations in NestJS.
58 lines (57 loc) • 3.51 kB
TypeScript
import { IApiBaseEntity } from '../../../interface/api-base-entity.interface';
import { IApiFunctionContext, IApiFunctionStepContext } from '../../../interface/class/api/function';
import { EntityManager, Repository } from 'typeorm';
export declare class ApiFunctionServiceContextFactory {
/**
* Creates a service-bound ApiFunction context for custom functions and internal steps.
* @template E - Entity type associated with the decorated function or step.
* @param {object} options - Context creation options.
* @param {new (...arguments_: Array<unknown>) => E} options.entity - Entity constructor associated with the service context.
* @param {EntityManager} [options.eventManager] - Active transaction manager, when available.
* @param {{ repository?: Repository<E> }} options.target - Service instance that owns the decorated method.
* @param {Repository<E>} [options.target.repository] - Service repository used to resolve non-transactional repositories.
* @returns {IApiFunctionContext<E>} Service-bound function context.
*/
static create<E extends IApiBaseEntity>(options: {
entity: new (...arguments_: Array<unknown>) => E;
eventManager?: EntityManager;
target: {
repository?: Repository<E>;
};
}): IApiFunctionContext<E>;
/**
* Creates a narrow service-bound ApiFunctionStep context.
* @template E - Entity type associated with the decorated step.
* @param {object} options - Context creation options.
* @param {new (...arguments_: Array<unknown>) => E} options.entity - Entity constructor associated with the step context.
* @param {EntityManager} [options.eventManager] - Active transaction manager, when available.
* @param {{ repository?: Repository<E> }} options.target - Service instance that owns the decorated step.
* @param {Repository<E>} [options.target.repository] - Service repository used to resolve non-transactional repositories.
* @returns {IApiFunctionStepContext<E>} Service-bound step context.
*/
static createStep<E extends IApiBaseEntity>(options: {
entity: new (...arguments_: Array<unknown>) => E;
eventManager?: EntityManager;
target: {
repository?: Repository<E>;
};
}): IApiFunctionStepContext<E>;
/**
* Resolves repositories from the service repository manager when no transaction manager is active.
* @template T - Repository entity type.
* @param {{ repository?: Repository<IApiBaseEntity> }} target - Service instance with an optional repository.
* @param {Repository<IApiBaseEntity>} [target.repository] - Service repository used to resolve repositories.
* @param {new () => T} entity - Entity constructor to resolve.
* @returns {Repository<T>} Repository from the service manager.
*/
private static getManagerRepository;
/**
* Resolves a repository from the service repository manager if a service repository exists.
* @template T - Repository entity type.
* @param {{ repository?: Repository<IApiBaseEntity> }} target - Service instance with an optional repository.
* @param {Repository<IApiBaseEntity>} [target.repository] - Service repository used to resolve repositories.
* @param {new () => T} entity - Entity constructor to resolve.
* @returns {Repository<T> | undefined} Repository from the service manager, when available.
*/
private static resolveManagerRepository;
}