Saltearse al contenido
sern

SDT

SDT (State, Dependencies, Type) interface represents the core data structure passed through the plugin pipeline to command modules.

SDT

Template

Type parameter for the state object’s structure

Template

Type parameter for dependencies interface

Example

1
// Example of a plugin using SDT
2
const loggingPlugin = CommandControlPlugin((ctx, sdt: SDT) => {
3
console.log(`User ${ctx.user.id} executed command`);
4
return controller.next({ 'logging/timestamp': Date.now() });
5
});

Example

1
// Example of state accumulation through multiple plugins
2
const plugin1 = CommandControlPlugin((ctx, sdt: SDT) => {
3
return controller.next({ 'plugin1/data': 'value1' });
4
});
5
6
const plugin2 = CommandControlPlugin((ctx, sdt: SDT) => {
7
// Access previous state
8
const prevData = sdt.state['plugin1/data'];
9
return controller.next({ 'plugin2/data': 'value2' });
10
});

Remarks

  • State is immutable and accumulated through the plugin chain
  • Keys in state should be namespaced to avoid collisions
  • Dependencies are injected and available throughout the pipeline
  • Type information helps plugins make type-safe decisions

See

Properties

deps

deps: Dependencies

Instance of application dependencies

Source

src/types/core-modules.ts:87


module

module: object

A copy of the current module that the plugin is running in.

description

description: string

locals

locals: Dictionary

meta

meta: Dictionary

name

name: string

Source

src/types/core-modules.ts:109


params?

optional params: string

Optional parameters passed to the command

Source

src/types/core-modules.ts:104


state

state: Record<string, unknown>

Accumulated state data passed between plugins

Source

src/types/core-modules.ts:79


type

type: CommandType

Command type identifier

Source

src/types/core-modules.ts:95