Classes · @purista/core
ClientBuilder
ClientBuilder to generate clients, based on service definitions.
Signature
class ClientBuilder Constructors
1 entry
constructor
Constructor
new constructor(config?: Partial<{ buildAs: "esm"; definitionPath: string; eventBridgeClient: { clientName: string }; httpClient: { clientName: string }; outputPath: string; package: { description: string; name: string; private: boolean }; ... }>) Properties
2 entries
config
Property
config: { buildAs: "esm"; definitionPath: string; eventBridgeClient: { clientName: string }; httpClient: { clientName: string }; outputPath: string; package: { description: string; name: string; private: boolean }; ... } rootPath
Property
rootPath: string The root path from where relative definition/config/output paths are resolved. Defaults to the current working directory (`process.cwd()`).
Methods
18 entries
build
Method
build(): Promise<void> Runs the tsc against the generated ts source files. Generates plain ESM output.
cleanDistFolder
Method
cleanDistFolder(): Promise<void> Deletes the content of the output folder. Should be called before generating the client
createIndex
Method
createIndex(): Promise<void> Creates a index.ts file which exports the client(s) and types. Is used in generated package.json
createPackageJson
Method
createPackageJson(): Promise<void> Creates a package.json file in the output folder. Exports the files which are build by tsc based on generated client files
destroy
Method
destroy(): void Destroys the builder and cleans the event listeners
emit
Method
emit<K>(eventName: K, parameter?: ClientBuilderEvents[K]): void generateEventBridgeClient
Method
generateEventBridgeClient(serviceDefinition: FullServiceDefinition): Promise<void> Generates the zero-dependency EventBridge client source files.
generateHEventBridgeClient
Method
generateHEventBridgeClient(serviceDefinition: FullServiceDefinition): Promise<void> generateHttpClient
Method
generateHttpClient(serviceDefinition: FullServiceDefinition): Promise<void> Generate zero‑dependency HTTP client source files from the given definition.
getDefinitionPath
Method
getDefinitionPath(): string Resolves the definitions folder path from config with rootPath
getDefinitionsFromServiceBuilders
Method
getDefinitionsFromServiceBuilders(serviceBuilders: ServiceBuilder<ServiceBuilderTypes>[]): Promise<FullServiceDefinition> Gets the definitions from the provided service builders
getOutputPath
Method
getOutputPath(): string Resolves the output folder path from config with rootPath
loadConfig
Method
loadConfig(path?: string): Promise<void> Loads the config from a JSON file. If no path is provided, it loads `purista.client.json` from `rootPath`.
loadDefinitionFiles
Method
loadDefinitionFiles(path?: string): Promise<FullServiceDefinition> Load service definitions from JSON files.
off
Method
off<K>(eventName: K, fn: EventReceiver<ClientBuilderEvents[K]>): void on
Method
on<K>(eventName: K, fn: EventReceiver<ClientBuilderEvents[K]>): void removeAllListeners
Method
removeAllListeners(): void writeConfig
Method
writeConfig(path?: string): Promise<void> Writes the config to a config file. Defaults to purista.client.json in rootPath directory