@baseplate-dev/sync
Version:
Library for syncing Baseplate descriptions
83 lines • 4.02 kB
TypeScript
import type { z } from 'zod';
import type { ExtractorConfig, TemplateConfig } from './extractor-config.schema.js';
export interface TemplateExtractorGeneratorEntry {
config: ExtractorConfig;
generatorDirectory: string;
packageName: string;
packagePath: string;
}
export interface TemplateExtractorProviderEntry<TConfig = Record<string, unknown>> {
config: TConfig;
packagePathSpecifier: string;
providerName: string;
packageName: string;
packagePath: string;
}
export interface TemplateExtractorTemplateEntry<TConfig = Record<string, unknown>> {
config: TConfig;
name: string;
}
/**
* Config lookup service for finding and caching extractor.json and providers.json files
*/
export declare class TemplateExtractorConfigLookup {
private readonly packageMap;
private extractorConfigCache;
private providersConfigCache;
private indexedPackages;
private initialized;
constructor(packageMap: Map<string, string>);
private checkInitialized;
/**
* Initialize the lookup service by indexing all packages in the package map
*/
initialize(): Promise<void>;
/**
* Get the extractor config for a generator
*/
getExtractorConfig(generatorName: string): TemplateExtractorGeneratorEntry | undefined;
getExtractorConfigOrThrow(generatorName: string): TemplateExtractorGeneratorEntry;
getTemplateConfig(generatorName: string, templateName: string): TemplateConfig | undefined;
getTemplateConfigOrThrow(generatorName: string, templateName: string): TemplateConfig;
getTemplatesForGenerator<T extends z.ZodTypeAny>(generatorName: string, templateMetadataSchema: T, templateType: z.infer<T>['type']): TemplateExtractorTemplateEntry<z.infer<T>>[];
getGeneratorConfigsForExtractorType<TTemplateMetadata extends z.ZodTypeAny, TGeneratorConfig extends z.ZodTypeAny = z.ZodNever>(templateType: z.infer<TTemplateMetadata>['type'], templateMetadataSchema: TTemplateMetadata, generatorConfigSchema?: TGeneratorConfig): {
generatorName: string;
generatorDirectory: string;
packageName: string;
packagePath: string;
templates: Record<string, z.infer<TTemplateMetadata>>;
config: z.infer<TGeneratorConfig>;
}[];
/**
* Get provider configs by type
*/
getProviderConfigsByType<T extends z.ZodTypeAny>(type: z.infer<T>['type'], providerConfigSchema: T): TemplateExtractorProviderEntry<z.infer<T>>[];
/**
* Write a new extractor config to the cache, reusing existing package info if available
*/
setExtractorConfig(generatorName: string, config: ExtractorConfig): void;
/**
* Update the template config for a generator
* @param generatorName - The name of the generator
* @param templateName - The name of the template to update
* @param config - The template config to update
*/
updateExtractorTemplateConfig(generatorName: string, templateName: string, config: TemplateConfig): void;
/**
* Get plugin configuration for a specific generator
* @param generatorName - The name of the generator
* @param pluginName - The name of the plugin
* @param schema - Zod schema to validate and parse the plugin configuration
* @returns The parsed plugin configuration or undefined if not found
*/
getPluginConfigForGenerator<T extends z.ZodTypeAny>(generatorName: string, pluginName: string, schema: T): z.infer<T> | undefined;
/**
* Get extractor configuration for a specific generator
* @param generatorName - The name of the generator
* @param extractorType - The type of extractor
* @param schema - Zod schema to validate and parse the extractor configuration
* @returns The parsed extractor configuration or undefined if not found
*/
getExtractorConfigForGenerator<T extends z.ZodTypeAny>(generatorName: string, extractorType: string, schema: T): z.infer<T> | undefined;
}
//# sourceMappingURL=template-extractor-config-lookup.d.ts.map