/** * We are using Builder pattern to create sdk-model objects https://en.wikipedia.org/wiki/Builder_pattern * Each sdk-model should have its own builder, and you should use it. * * This class serves to: * - unify all builders & builder factories across our codebase * - hold all common methods and properties of builders (e.g. item & build) * * @beta */ export declare class Builder implements IBuilder { protected item: Partial; protected validator?: ((item: Partial) => void) | undefined; constructor(item: Partial, validator?: ((item: Partial) => void) | undefined); build(): T; modify(modifications: BuilderModifications): this; validate(): this; } /** * Common builder interface * @beta */ export interface IBuilder { /** * Build & return current item */ build(): T; /** * Modify current item with set of modifications */ modify(modifications: BuilderModifications): this; /** * Validate current item, throws error when item is not valid */ validate(): this; } /** * Extracts item type from generic builder type * * @beta */ export type ExtractBuilderType = TBuilder extends IBuilder ? TItem : never; /** * Type that represents generic builder constructor * * @beta */ export type BuilderConstructor, TItem> = new (item: Partial) => TBuilder; /** * Function that will be called to perform modifications on item before it is fully constructed * * @beta */ export type BuilderModifications, TItem = ExtractBuilderType> = (builder: TBuilder) => TBuilder; /** * Represents a callback to update the value, or the value itself. * @alpha */ export type ValueOrUpdateCallback = TValue | ((value: TValue) => TValue); /** * Calls an update callback when it's a function, otherwise returns the value itself. * This is just an utility function to DRY the builder implementation a bit. * * @alpha * @param valueOrUpdateCallback - value to set, or update callback * @param valueToUpdate - original value to update */ export declare const resolveValueOrUpdateCallback: (valueOrUpdateCallback: ValueOrUpdateCallback, valueToUpdate: TValue) => TValue; /** * Generic builder factory to create sdk-model objects using builder pattern * * @beta */ export declare function builderFactory, TBuilderConstructor extends BuilderConstructor>(Builder: TBuilderConstructor, defaultItem: Partial, modifications: BuilderModifications): TItem; //# sourceMappingURL=builder.d.ts.map