MCPcopy Create free account
hub / github.com/FlowiseAI/Flowise / bindNodesApi

Function bindNodesApi

packages/agentflow/src/infrastructure/api/nodes.ts:8–58  ·  view source on GitHub ↗
(client: AxiosInstance)

Source from the content-addressed store, hash-verified

6 * Create nodes API functions bound to a client instance
7 */
8export function bindNodesApi(client: AxiosInstance) {
9 return {
10 /**
11 * Get all available nodes.
12 * Component definitions from the server (`inputs` is a schema array).
13 * Pass results through initNode() to get canvas-ready NodeData.
14 */
15 getAllNodes: async (): Promise<NodeDataSchema[]> => {
16 const response = await client.get('/nodes', { params: { client: 'agentflowsdk' } })
17 return response.data
18 },
19
20 /**
21 * Get a specific node by name.
22 * Single component definition (`inputs` is a schema array).
23 */
24 getNodeByName: async (name: string): Promise<NodeDataSchema> => {
25 const response = await client.get(`/nodes/${name}`, { params: { client: 'agentflowsdk' } })
26 return response.data
27 },
28
29 /**
30 * Call a loadMethod on a specific node (e.g. listRegions on awsChatBedrock).
31 * Maps to POST /node-load-method/{nodeName} with { loadMethod, ...body }.
32 */
33 loadNodeMethod: async (nodeName: string, loadMethod: string, body?: Record<string, unknown>): Promise<unknown> => {
34 const response = await client.post(`/node-load-method/${nodeName}`, { loadMethod, ...body })
35 return response.data
36 },
37
38 /**
39 * Get node configuration (override configs) for a node.
40 * Posts the node data to /node-config and returns an array of config entries.
41 * NodeData field names (inputParams for schema, inputs for values) already
42 * match what the server expects.
43 */
44 getNodeConfig: async (data: NodeData): Promise<NodeConfigEntry[]> => {
45 const response = await client.post('/node-config', data)
46 return response.data
47 },
48
49 /**
50 * Get node icon URL
51 */
52 getNodeIconUrl: (instanceUrl: string, nodeName: string): string => {
53 // Strip trailing slashes so we never get double slashes in the URL.
54 const base = instanceUrl.replace(/\/+$/, '')
55 return `${base}/api/v1/node-icon/${nodeName}`
56 }
57 }
58}
59
60export type NodesApi = ReturnType<typeof bindNodesApi>

Callers 2

ApiProviderFunction · 0.90
nodes.test.tsFile · 0.90

Calls 1

getMethod · 0.45

Tested by

no test coverage detected