Skip to main content

Method: Search Event Sequences - JS/TS

async searchWithPattern(request: Pattern): Promise<PatternResult>
ParameterDescription
requestEvent sequence search parameters (type Pattern)

A method of the Event Agent.

Search event sequences that match a pattern, that all events are emitted with the right order and each matches given conditions.

Returns type PatternResult, which contains matched event sequences.

Parameter Type

Pattern

Importable from @fstnetwork/loc-logic-sdk

Event sequence search parameters.

PropertyTypeDescription
sequencesSequence[]A set of event query conditions
filter?Filter[]Filter conditions (see Search Events)
maxSpan?stringSearch timestamp span (syntax reference)
warning

sequences must contain at least 2 set of conditions in order to search event sequences. An error will be thrown if only one set is provided.

Sub Parameter Type

Sequence

PropertyTypeDescription
conditions?Condition[] | nullQuery condition for each event
sharedFields?string[] | nullEvent shared field values
type?string | nullEvent type or group

Condition

PropertyTypeDescription
fieldstringEvent field name
opOpOperator
valuestringValue to be matched

Op

Operators for event query condition in the sequence:

type Op = "eq" | "ne" | "gt" | "lt" | "gte" | "lte";
OperatorDescription
"eq"Equal to
"ne"Not equal to
"gt"Greater than
"lt"Less than
"gte"Greater than or equal to
"lte"Less than or equal to

Return Type

PatternResult

Importable from @fstnetwork/loc-logic-sdk

Search result of matched event sequences.

MemberTypeDescription
sequencesSequencesResult[]Queried sequences
countnumberNumber of events to be queried
totalnumberActual queried number of events
tooknumberQuery time (milllisecond)

Sun Return Type

SequencesResult

Events in a queried sequence.

MemberTypeDescription
eventsEvent[]Queried events in a sequence
joinKeysstring[]

Examples

const query = await EventAgent.searchWithPattern({
sequences: [
// first set of confitions
{
conditions: [
{
field: "label_name",
op: "eq",
value: "some label name",
},
],
sharedFields: [],
type: "any",
},
// second set of conditions
{
conditions: [
{
field: "source_digital_identity",
op: "eq",
value: "some source DID",
},
{
field: "target_digital_identity",
op: "ne",
value: "some target DID",
},
],
sharedFields: [],
type: "any",
},
// more conditions...
],
filter: null,
maxSpan: null,
});

const sequences = query?.sequences;

// iterate through sequences and events
sequences.forEach((sequence) => {
sequence.events?.forEach((event) => {
const label_name = event.label.name;
const meta = event.meta;
const logicPid = event.logicIdentityContext.permanentIdentity;
// ...
});
});