Classes · @purista/core

ClientBuilder

ClientBuilder to generate clients, based on service definitions.

Signature

ClientBuilder.ts typescript
class ClientBuilder

Constructors

1 entry

constructor

Constructor

Source
constructor.ts typescript
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

Source
config.ts typescript
config: { buildAs: "esm"; definitionPath: string; eventBridgeClient: { clientName: string }; httpClient: { clientName: string }; outputPath: string; package: { description: string; name: string; private: boolean }; ... }

rootPath

Property

Source
rootPath.ts typescript
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

Source
build.ts typescript
build(): Promise<void>

Runs the tsc against the generated ts source files. Generates plain ESM output.

cleanDistFolder

Method

Source
cleanDistFolder.ts typescript
cleanDistFolder(): Promise<void>

Deletes the content of the output folder. Should be called before generating the client

createIndex

Method

Source
createIndex.ts typescript
createIndex(): Promise<void>

Creates a index.ts file which exports the client(s) and types. Is used in generated package.json

createPackageJson

Method

Source
createPackageJson.ts typescript
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

Source
destroy.ts typescript
destroy(): void

Destroys the builder and cleans the event listeners

emit

Method

Source
emit.ts typescript
emit<K>(eventName: K, parameter?: ClientBuilderEvents[K]): void

generateEventBridgeClient

Method

Source
generateEventBridgeClient.ts typescript
generateEventBridgeClient(serviceDefinition: FullServiceDefinition): Promise<void>

Generates the zero-dependency EventBridge client source files.

generateHEventBridgeClient

Method

Source
generateHEventBridgeClient.ts typescript
generateHEventBridgeClient(serviceDefinition: FullServiceDefinition): Promise<void>

generateHttpClient

Method

Source
generateHttpClient.ts typescript
generateHttpClient(serviceDefinition: FullServiceDefinition): Promise<void>

Generate zero‑dependency HTTP client source files from the given definition.

getDefinitionPath

Method

Source
getDefinitionPath.ts typescript
getDefinitionPath(): string

Resolves the definitions folder path from config with rootPath

getDefinitionsFromServiceBuilders

Method

Source
getDefinitionsFromServiceBuilders.ts typescript
getDefinitionsFromServiceBuilders(serviceBuilders: ServiceBuilder<ServiceBuilderTypes>[]): Promise<FullServiceDefinition>

Gets the definitions from the provided service builders

getOutputPath

Method

Source
getOutputPath.ts typescript
getOutputPath(): string

Resolves the output folder path from config with rootPath

loadConfig

Method

Source
loadConfig.ts typescript
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

Source
loadDefinitionFiles.ts typescript
loadDefinitionFiles(path?: string): Promise<FullServiceDefinition>

Load service definitions from JSON files.

off

Method

Source
off.ts typescript
off<K>(eventName: K, fn: EventReceiver<ClientBuilderEvents[K]>): void

on

Method

Source
on.ts typescript
on<K>(eventName: K, fn: EventReceiver<ClientBuilderEvents[K]>): void

removeAllListeners

Method

Source
removeAllListeners.ts typescript
removeAllListeners(): void

writeConfig

Method

Source
writeConfig.ts typescript
writeConfig(path?: string): Promise<void>

Writes the config to a config file. Defaults to purista.client.json in rootPath directory