Custom nodes
A custom node is the simplest node type: it receives one message, optionally mutates the payload, and returns it. No external HTTP, no fan-out, no state outside the message itself. Use custom nodes for transformations, filters, decisions, and any local logic that does not belong in a connector.
For background see Concepts: Topologies.
Class to extend #
| SDK | Base class |
|---|---|
| Node.js | ACommonNode (in @orchesty/nodejs-sdk/dist/lib/Commons/ACommonNode) |
| PHP | CommonNodeAbstract (in Hanaboso\PipesPhpSdk\CustomNode) |
Mapper example #
A mapper that converts a Hubspot contact into the canonical shape the rest of your topology expects:
// worker/src/Mapper/HubspotContactToCanonical.ts
import ACommonNode from '@orchesty/nodejs-sdk/dist/lib/Commons/ACommonNode';
import ProcessDto from '@orchesty/nodejs-sdk/dist/lib/Utils/ProcessDto';
export default class HubspotContactToCanonical extends ACommonNode {
public getName(): string {
return 'hubspot-contact-to-canonical';
}
public async processAction(dto: ProcessDto): Promise<ProcessDto> {
const contact = dto.getJsonData() as {
id: string;
properties: { firstname?: string; lastname?: string; email?: string };
};
dto.setJsonData({
externalId: contact.id,
firstName: contact.properties.firstname ?? '',
lastName: contact.properties.lastname ?? '',
email: contact.properties.email ?? '',
});
return dto;
}
}
Filter / branching example #
A filter that drops a message when the contact is missing an email:
import { ResultCode } from '@orchesty/nodejs-sdk/dist/lib/Utils/ResultCode';
public async processAction(dto: ProcessDto): Promise<ProcessDto> {
const data = dto.getJsonData() as { email?: string };
if (!data.email) {
dto.setStopProcess(ResultCode.STOP_AND_FAILED, 'Missing email');
}
return dto;
}
setStopProcess() ends this branch of the process. Use STOP_AND_OK to stop without error, STOP_AND_FAILED to route to the next failure handler, and the routing options described in Topologies for branching to a named successor.
Register the node #
import HubspotContactToCanonical from './Mapper/HubspotContactToCanonical';
container.setNode(new HubspotContactToCanonical());
Custom nodes that don't authenticate against an external service are registered without an Application reference.