import { ConfigService } from "@nestjs/config"; import { ModuleRef } from "@nestjs/core"; import { BaseConfigInterface } from "../../../config/interfaces"; import { EntityDescriptor } from "../../../common/interfaces/entity.schema.interface"; import { AbstractJsonApiSerialiser } from "../abstracts/abstract.jsonapi.serialiser"; import { JsonApiSerialiserFactory } from "../factories/jsonapi.serialiser.factory"; import { JsonApiDataInterface } from "../interfaces/jsonapi.data.interface"; import { JsonApiServiceInterface } from "../interfaces/jsonapi.service.interface"; /** * Base class for auto-generated serialisers from EntityDescriptor. * Derives attributes, meta, and relationships from the descriptor configuration. * * Subclasses should call `setDescriptor()` in their constructor. */ export declare class DescriptorBasedSerialiser extends AbstractJsonApiSerialiser implements JsonApiServiceInterface { protected readonly moduleRef: ModuleRef; protected descriptor: EntityDescriptor; /** * Resolved lazily by `resolveInjectedServices()` — NEVER populate this in the * constructor. See the comment there for why. */ private resolvedServices?; constructor(serialiserFactory: JsonApiSerialiserFactory, moduleRef: ModuleRef, configService: ConfigService); /** * Set the descriptor and inject required services. * Must be called by subclasses in their constructor. */ protected setDescriptor(descriptor: EntityDescriptor): void; /** * Resolve `injectServices` on FIRST USE, never at construction time. * * WHY THIS IS LAZY — this is load-bearing, do not inline it back into * setDescriptor(). setDescriptor() runs from a subclass CONSTRUCTOR, i.e. * while Nest is still instantiating the provider graph. `ModuleRef.get()` * does not participate in that graph: it returns whatever currently sits in * the target provider's InstanceWrapper. Nest pre-fills every wrapper with a * PLACEHOLDER before anything is constructed (instance-wrapper.js): * * instancePerContext.instance = Object.create(this.metatype.prototype); * * and then, when it really instantiates the provider, it REPLACES that * object rather than filling it in (injector.js, instantiateClass): * * instanceHost.instance = wrapper.forwardRef * ? Object.assign(instanceHost.instance, new metatype(...instances)) * : new metatype(...instances); * * So a serialiser constructed BEFORE its injected service captured the * placeholder — an object with the right prototype and ZERO own properties. * Every constructor-injected field on it (configService, logger, …) read as * undefined, while every other consumer of the same service worked fine, * because they held the replacement object. Whether it broke came down to * provider instantiation order, so it surfaced as an unrelated dependency * bump silently reordering the graph. * * Resolving here instead means the lookup happens on the first serialisation * — long after the whole graph is constructed — so it always returns the * real instance. */ protected resolveInjectedServices(): Record; get type(): string; create(): JsonApiDataInterface; } //# sourceMappingURL=descriptor.based.serialiser.d.ts.map