import { JwtConfig, LedgerMeta, LedgerRecord, LedgerSigningParams } from "../../../../types/src"; import { BaseRecordResponse } from '../types/base-record-response'; import { BaseRecordBuilder } from './base-record-builder'; /** * A handler for creating new records on the remote API. */ export type CreateRecordHandler = (record: LedgerRecord, authParams: JwtConfig) => Promise; /** * Implements a builder pattern that allows a more * convenient way to work with ledger records. This * class has functions that simplify construction, * hashing, signing, testing and sending records to * remote ledger instances. * * This builder is intended for creating new records, * sending a record to ledger will attempt to create it * on the API with the content that was prepared in the * builder. * * NOTE: current record instance is mutated by this * class, we are not cloning instances intentionally, * and it isn't advised to reuse builder instances when * working with multiple records or mutating objects * passed to this builder in external code. It is * recommended to clone objects in such cases to avoid * unexpected behaviors. */ export declare class CreateRecordBuilder, M extends LedgerMeta = LedgerMeta> extends BaseRecordBuilder { /** * A handler for creating new records on the remote API. */ protected createRecord: CreateRecordHandler; /** * Creates new instance of record builder. * * @param createRecord function which creates new record on ledger api */ constructor(createRecord: CreateRecordHandler); /** * Sends the current record version to the remote ledger. * * @returns api response with the created record * @throws if any method in builder chain fails */ send(): Promise; /** * Sets custom.status 'created' to all the signatures that don't have status. * * @param params signatures * @returns this builder instance for chaining */ sign(params: LedgerSigningParams[]): this; }