Skip to content

redactStateData

function redactStateData(params): Record<string, AslState>;

Defined in: src/redact.ts:165

Run a caller’s redaction hook over the raw ASL bound for #sfn-state-data.

Every state is offered whole first (path is just its id), then every field at every depth, so a hook can drop one key, one state, or scrub a value in place.

RedactStateDataParams

Redaction parameters

Record<string, AslState>

The state data to inline, or stateData itself when no hook was given

const safe = redactStateData({
redact: ({ path, value }) => (path.endsWith('.Parameters') ? undefined : value),
stateData: collectStateData({ definition: asl }),
});
safe.ProcessOrder.Parameters; // => '[redacted]'

The hook is called with the value it would inline and returns what to inline instead; returning that same value keeps it and descends into it. So a hook that rebuilds an object it meant to keep stops the walk there - return the argument itself to carry on.

stateId is the entry a value is inlined under, which is not always the state it describes. A Parallel or Map container’s own ASL contains its children whole, so every nested state’s ASL is offered twice: once under its own scoped id, and once more inside its container’s entry, under the container’s id and a path running through Branches or ItemProcessor. A hook that must catch every copy has to key on path or on the value, not on stateId alone.

path is for matching, not identity: it is built by concatenation, so a key that itself contains a dot or a bracket - "Payload.$", which ASL uses constantly - produces a path indistinguishable from one more level of nesting.