import type { BlipClient } from '../client.ts' import { BlipError } from '../sender/bliperror.ts' import { uri } from '../utils/uri.ts' import { type ConsumeOptions, Namespace, type SendCommandOptions } from './namespace.ts' export class BuilderNamespace extends Namespace { constructor(blipClient: BlipClient, defaultOptions?: SendCommandOptions) { super(blipClient, 'builder', defaultOptions) } public async getFlowId(botIdentifier?: string, opts?: ConsumeOptions): Promise { try { return await this.sendCommand( { method: 'get', uri: uri`/flow-id?${{ shortName: botIdentifier }}`, }, opts, ) } catch (err) { if (err instanceof BlipError && err.code === 67) { return undefined } throw err } } public async getFlowStates( botIdentifier?: string, opts?: ConsumeOptions, ): Promise> { try { return await this.sendCommand( { method: 'get', uri: uri`/flow/states?${{ shortName: botIdentifier }}`, }, { collection: true, ...opts, }, ) } catch (err) { if (err instanceof BlipError && err.code === 67) { return [] } throw err } } }