Locomotive functions
Define, arrange and copy locomotive functions.
Source 0.1.0 Private source package
How the calls fit together
Read the function definitions and choose a deliberate configuration change; configuration does not operate a function.
JavaScript examples
Supply your configured client. Each call awaits a decoded result; errors pass to your caller. These identifiers and values are fictional. Use selected development records and review every change before running it. Opening this page sends no API requests.
See the complete TypeScript workflow · Explore the Node starter
locomotiveFunctions.list
Lists function definitions for one locomotive.
const result = await client.locomotiveFunctions.list(
"account-1",
"loco-1",
{}
);TypeScript parameters and return type
accountId· requiredRailDeckIdentifierAccount that owns the locomotive.
locomotiveId· requiredRailDeckIdentifierLocomotive whose functions should be listed.
options· optionalRailDeckRequestControlOptionsOptional caller cancellation and request timeout.
Returns Promise<RailDeckLocomotiveFunctionListResponse>.
Example evidence: Retained SDK transport fixture.
locomotiveFunctions.copy
Copies selected same-account functions with reviewed revisions and explicit replacements.
const result = await client.locomotiveFunctions.copy(
"23",
"4",
{
"sourceLocomotiveId": "5",
"functions": [
{
"id": "7",
"expectedRevision": 3,
"replace": {
"id": "9",
"expectedRevision": 2
}
}
]
}
);TypeScript parameters and return type
accountId· requiredRailDeckIdentifierOwning account.
locomotiveId· requiredRailDeckIdentifierDestination.
input· requiredCopyRailDeckLocomotiveFunctionsInputReviewed source selections and explicit replacements.
Returns Promise<RailDeckLocomotiveFunctionListResponse>.
Example evidence: Retained SDK transport fixture.
locomotiveFunctions.create
Creates a function definition for one locomotive.
const result = await client.locomotiveFunctions.create(
"23",
"4",
{
"functionNumber": 2,
"label": "Whistle",
"meaning": "whistle-short",
"momentary": true
}
);TypeScript parameters and return type
accountId· requiredRailDeckIdentifierAccount that owns the locomotive.
locomotiveId· requiredRailDeckIdentifierLocomotive receiving the function definition.
input· requiredCreateRailDeckLocomotiveFunctionInputFunction number, label, momentary mode, visibility, and display metadata.
Returns Promise<RailDeckLocomotiveFunction>.
Example evidence: Retained SDK transport fixture.
locomotiveFunctions.get
Loads one locomotive function definition.
const result = await client.locomotiveFunctions.get(
"account 1",
"loco 1",
"function 1",
{}
);TypeScript parameters and return type
accountId· requiredRailDeckIdentifierAccount that owns the locomotive.
locomotiveId· requiredRailDeckIdentifierLocomotive containing the function definition.
functionId· requiredRailDeckIdentifierFunction definition to load.
options· optionalRailDeckRequestControlOptionsOptional caller cancellation and request timeout.
Returns Promise<RailDeckLocomotiveFunction>.
Example evidence: Retained SDK transport fixture.
locomotiveFunctions.update
Updates one locomotive function definition.
const result = await client.locomotiveFunctions.update(
"account-1",
"loco-1",
"fn-2",
{
"expectedRevision": 1,
"visible": false
}
);TypeScript parameters and return type
accountId· requiredRailDeckIdentifierAccount that owns the locomotive.
locomotiveId· requiredRailDeckIdentifierLocomotive containing the function definition.
functionId· requiredRailDeckIdentifierFunction definition to update.
input· requiredUpdateRailDeckLocomotiveFunctionInputPartial function definition update.
Returns Promise<RailDeckLocomotiveFunction>.
Example evidence: Retained SDK transport fixture.
locomotiveFunctions.delete
Deletes one locomotive function definition.
const result = await client.locomotiveFunctions.delete(
"account-1",
"loco-1",
"fn-2",
{
"expectedRevision": 2
}
);TypeScript parameters and return type
accountId· requiredRailDeckIdentifierAccount that owns the locomotive.
locomotiveId· requiredRailDeckIdentifierLocomotive containing the function definition.
functionId· requiredRailDeckIdentifierFunction definition to delete.
input· required{ expectedRevision: number }Required revision from the reviewed definition.
Returns Promise<RailDeckSuccessResponse>.
Example evidence: Retained SDK transport fixture.
locomotiveFunctions.arrange
Atomically saves exact membership and reviewed revisions in display order.
const result = await client.locomotiveFunctions.arrange(
"23",
"4",
{
"functions": [
{
"id": "7",
"expectedRevision": 3
},
{
"id": "2",
"expectedRevision": 1
}
]
}
);TypeScript parameters and return type
accountId· requiredRailDeckIdentifierOwning account.
locomotiveId· requiredRailDeckIdentifierTarget locomotive.
input· required{ functions: { id: RailDeckIdentifier; expectedRevision: number }[] }Exact collection in desired order with reviewed revisions.
Returns Promise<RailDeckLocomotiveFunctionListResponse>.
Example evidence: Retained SDK transport fixture.
Download all TypeScript method examples
JavaScript calls and TypeScript downloads are checked through the real SDK using local response fixtures. This verifies the calls and decoding for those fixtures.
The complete TypeScript workflow
Follow how the calls fit together, including the review and recovery steps. Supply your configured client and explicitly selected development records. Importing the download performs no requests; mutations are never retried automatically.
import type { RailDeckDirectIntegrationClient as Client } from '@raildeck/frontend-sdk/direct-integration';
/**
* Read definitions for a deliberate function-order editing session.
* @param client - Configured client; the caller owns current authority.
* @param accountId - Authorised account for this workflow.
* @param locomotiveId - Explicitly selected locomotive.
* @param signal - Caller-owned cancellation signal.
* @returns Current definitions and revisions to retain during review.
*/
export async function readFunctionOrder(
client: Client,
accountId: string,
locomotiveId: string,
signal: AbortSignal,
) {
return client.locomotiveFunctions.list(accountId, locomotiveId, { signal, timeoutMs: 15_000 });
}
/**
* Save the explicitly reviewed order with each original revision.
* @param client - Configured client; the caller owns current authority.
* @param accountId - Authorised account for this workflow.
* @param locomotiveId - Explicitly selected locomotive.
* @param functions - Ordered function identities and their reviewed revisions.
* @returns Saved definitions; arranging them does not activate a locomotive function.
*/
export async function saveReviewedFunctionOrder(
client: Client,
accountId: string,
locomotiveId: string,
functions: Parameters<Client['locomotiveFunctions']['arrange']>[2]['functions'],
) {
return client.locomotiveFunctions.arrange(accountId, locomotiveId, { functions });
}
Download TypeScript example