Skip to main content

Rail Deck is being prepared for an invitation-only Alpha. Check current availability

Developer documentation

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 · required
RailDeckIdentifier

Account that owns the locomotive.

locomotiveId · required
RailDeckIdentifier

Locomotive whose functions should be listed.

options · optional
RailDeckRequestControlOptions

Optional 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 · required
RailDeckIdentifier

Owning account.

locomotiveId · required
RailDeckIdentifier

Destination.

input · required
CopyRailDeckLocomotiveFunctionsInput

Reviewed 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 · required
RailDeckIdentifier

Account that owns the locomotive.

locomotiveId · required
RailDeckIdentifier

Locomotive receiving the function definition.

input · required
CreateRailDeckLocomotiveFunctionInput

Function 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 · required
RailDeckIdentifier

Account that owns the locomotive.

locomotiveId · required
RailDeckIdentifier

Locomotive containing the function definition.

functionId · required
RailDeckIdentifier

Function definition to load.

options · optional
RailDeckRequestControlOptions

Optional 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 · required
RailDeckIdentifier

Account that owns the locomotive.

locomotiveId · required
RailDeckIdentifier

Locomotive containing the function definition.

functionId · required
RailDeckIdentifier

Function definition to update.

input · required
UpdateRailDeckLocomotiveFunctionInput

Partial 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 · required
RailDeckIdentifier

Account that owns the locomotive.

locomotiveId · required
RailDeckIdentifier

Locomotive containing the function definition.

functionId · required
RailDeckIdentifier

Function 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 · required
RailDeckIdentifier

Owning account.

locomotiveId · required
RailDeckIdentifier

Target 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.

Handle errors and uncertain outcomes

Choose another feature

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

Information reviewed .