UNPKG

meta-cloud-api

Version:
137 lines (134 loc) 5.21 kB
import { B as BaseAPI } from './base-CdGDdVEl.js'; import { WabaConfigType } from './types/config.js'; import { R as RequesterClass, e as ResponseSuccess } from './request-vYMaEfk5.js'; import { h as FlowClass, k as FlowsListResponse, g as FlowCategoryEnum, C as CreateFlowResponse, c as Flow, j as FlowPreviewResponse, f as FlowAssetsResponse, U as UpdateFlowResponse, V as ValidateFlowJsonResponse, i as FlowMigrationResponse } from './common-lV0NsO7t.js'; /** * API for managing WhatsApp Flows. * * This API allows you to: * - List flows * - Create flows * - Get flow details and previews * - Update flow metadata and JSON * - Delete flows * - Publish and deprecate flows * - Migrate flows between WABAs * - Validate flow JSON */ declare class FlowApi extends BaseAPI implements FlowClass { constructor(config: WabaConfigType, client: RequesterClass); /** * List Flows * * @param wabaId - The WABA ID * @returns Promise with the list of flows */ listFlows(wabaId: string): Promise<FlowsListResponse>; /** * Create Flow * * @param wabaId - The WABA ID * @param data - The flow data including name, categories, endpoint_uri, and optional clone_flow_id * @returns Promise with the created flow ID and validation errors if any */ createFlow(wabaId: string, data: { name: string; categories?: FlowCategoryEnum[]; endpoint_uri?: string; clone_flow_id?: string; flow_json?: string; publish?: boolean; }): Promise<CreateFlowResponse>; /** * Get Flow details * * @param flowId - The flow ID * @param fields - Optional fields to return (e.g., 'name,status,preview.invalidate(false)') * @param dateFormat - Optional date format * @returns Promise with the flow details or preview response */ getFlow(flowId: string, fields?: string, dateFormat?: string): Promise<Flow | FlowPreviewResponse>; /** * Get Flow Preview URL * * @param flowId - The flow ID * @param invalidate - Optional. If true, invalidates existing preview and generates a new one. Defaults to false. * @returns Promise with the flow preview details */ getFlowPreview(flowId: string, invalidate?: boolean): Promise<FlowPreviewResponse>; /** * Update Flow Metadata * * @param flowId - The flow ID * @param data - The flow metadata to update (name, categories, endpoint_uri, application_id) * @returns Promise with the success status */ updateFlowMetadata(flowId: string, data: { name?: string; categories?: FlowCategoryEnum[]; endpoint_uri?: string; application_id?: string; }): Promise<ResponseSuccess>; /** * Delete Flow (only works if the Flow is in DRAFT status) * * @param flowId - The flow ID * @returns Promise with the success status */ deleteFlow(flowId: string): Promise<ResponseSuccess>; /** * List Assets (e.g., get Flow JSON download URL) * * @param flowId - The flow ID * @returns Promise with the list of assets */ listAssets(flowId: string): Promise<FlowAssetsResponse>; /** * Update Flow JSON by uploading a file, buffer, JSON object, or Blob. * * @param flowId - The flow ID * @param data - Object containing the file data and optional name. * @param data.file - The Flow JSON content as a Buffer, JSON object, or Blob. * @param data.name - Optional name for the asset, defaults to 'flow.json'. * @returns Promise with the success status and validation errors, if any. */ updateFlowJson(flowId: string, data: { file: Blob | Buffer | object; name?: string; }): Promise<UpdateFlowResponse>; /** * Validate Flow JSON by attempting an update without publishing. * This is a convenience method; the API doesn't have a dedicated validation endpoint. * * @param flowId - The ID of the Flow (must exist, can be in DRAFT status). * @param flowJsonData - The Flow JSON content as a file path (string), Buffer, JSON object, or Blob. * @returns Promise indicating if the JSON is valid and includes validation errors if any. */ validateFlowJson(flowId: string, flowJsonData: Blob | Buffer | object): Promise<ValidateFlowJsonResponse>; /** * Publish Flow * * @param flowId - The flow ID * @returns Promise with the success status */ publishFlow(flowId: string): Promise<ResponseSuccess>; /** * Deprecate Flow * * @param flowId - The flow ID * @returns Promise with the success status */ deprecateFlow(flowId: string): Promise<ResponseSuccess>; /** * Migrate Flows between WABAs * * @param destinationWabaId - The destination WABA ID * @param data - The migration data including source_waba_id and optional source_flow_names * @returns Promise with migration results (successes and failures) */ migrateFlows(destinationWabaId: string, data: { source_waba_id: string; source_flow_names?: string[]; }): Promise<FlowMigrationResponse>; } export { FlowApi as F };