UNPKG

kubricate

Version:

A TypeScript framework for building reusable, type-safe Kubernetes infrastructure — without the YAML mess.

60 lines 2.58 kB
import type { Call, Objects } from 'hotscript'; import type { AnyClass } from '../types.js'; export interface ResourceEntry { type?: AnyClass; config: Record<string, unknown>; /** * The kind of resource. This is used to determine how to handle the resource. * - `class`: A class that will be instantiated with the config. * - `object`: An object that will be used as is. * - `instance`: An instance of a class that will be used as is. */ entryType: 'class' | 'object' | 'instance'; } export declare class ResourceComposer<Entries extends Record<string, unknown> = {}> { _entries: Record<string, ResourceEntry>; _override: Record<string, unknown>; inject(resourceId: string, path: string, value: unknown): void; build(): Record<string, unknown>; /** * Add a resource to the composer, extracting the type and data from the arguments. * * @deprecated This method is deprecated and will be removed in the future. Use `addClass` instead. */ add<Id extends string, T extends AnyClass>(params: { id: Id; type: T; config: ConstructorParameters<T>[0]; }): ResourceComposer<Entries & Record<Id, ConstructorParameters<T>[0]>>; /** * Add a resource to the composer, extracting the type and data from the arguments. */ addClass<const Id extends string, T extends AnyClass>(params: { id: Id; type: T; config: ConstructorParameters<T>[0]; }): ResourceComposer<Entries & Record<Id, ConstructorParameters<T>[0]>>; /** * Add an object to the composer directly. Using this method will support overriding the resource. */ addObject<const Id extends string, T extends object = object>(params: { id: Id; config: T; }): ResourceComposer<Entries & Record<Id, T>>; /** * Add an instance to the composer directly. Using this method will not support overriding the resource. * * @deprecated This method is deprecated and will be removed in the future. Use `addObject` instead for supporting overrides. */ addInstance<Id extends string, T extends object = object>(params: { id: Id; config: T; }): ResourceComposer<Entries & Record<Id, T>>; override(overrideResources: Call<Objects.PartialDeep, Entries>): this; /** * @interal Find all resource IDs of a specific kind. * This method is useful for filtering resources based on their kind. */ findResourceIdsByKind(kind: string): string[]; } //# sourceMappingURL=ResourceComposer.d.ts.map