Skip to main content

Processing Actions

Processing actions is done using action.run(data) of the ductape.processor interface.

It executes an action processor within the Ductape system, handling an action request based on the provided environment, product tag, and other parameters.

await ductape.processor.action.run(data: IActionProcessorInput)

This processes a defined action in the specified environment and application context, passing along request input, metadata, and optionally session tracking.

Parameters

IActionProcessorInput

FieldTypeRequiredDescription
envstringYesEnvironment slug (e.g. "dev", "prd").
product_tagstringYesProduct tag associated with this action.
appstringYesAccess tag of the application triggering the action.
eventstringYesEvent tag identifying the action to be processed.
cachestringNoCache tag (if using request caching).
inputIActionRequestYesRequest input including query, body, headers, and params.
sessionISessionNoOptional session tracking object.
retriesnumberNoNumber of retry attempts if execution fails.

IActionRequest Schema

interface IActionRequest {
query?: Record<string, unknown>;
params?: Record<string, unknown>;
body?: Record<string, unknown>;
headers?: Record<string, unknown>;
}
FieldTypeRequiredDescription
queryRecord<string, unknown>NoURL query parameters.
paramsRecord<string, unknown>NoRoute parameters.
bodyRecord<string, unknown>NoRequest body data.
headersRecord<string, unknown>NoHTTP request headers.

Note: If any of the above fields are undefined or empty, pass them as {}.

ISession Schema

The session field enables optional session tracking for any action run.

interface ISession {
tag: string; // session tag
token: string; // session token (e.g. signed JWT)
}
FieldTypeRequiredDescription
tagstringYesSession tag identifying the session.
tokenstringYesEncoded token used to validate and track the session.

Returns

A Promise<unknown> — resolves with the action's output. The shape of the response depends on the implementation of the triggered action.

Example

const data: IActionProcessorInput = {
env: 'dev',
product_tag: 'my-product',
app: 'auth-service',
event: 'user.signup',
input: {
query: { userId: '123' },
body: { email: 'user@example.com' },
headers: { Authorization: '$Auth{token_access}{token}' },
params: {}
},
session: {
tag: 'session-tag',
token: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'
},
retries: 3
};

const result = await ductape.processor.action.run(data);

See Also