CrumpetDev / crumpet

GNU Affero General Public License v3.0
18 stars 1 forks source link

A client can subscribe to active flow state and active step changes #68

Open tomtitherington opened 4 months ago

tomtitherington commented 4 months ago

Background & Context*

Once a client has a valid Websocket connection to the server, they should be able to subscribe to change notifications from the FlowInstance and StepInstance models related to the current Person associated with the session.

Goal*

A client should be able to subscribe to active flow and active step changes for the specified person.

Implementation Details*

Calls to this endpoint should be idempotent. Calling this endpoint multiple times with the same parameters should always result in the same outcome. Subscribing once produces the same outcome as subscribing n times.

// Example request when subscribing to Flow state changes
{
    "action": "subscribe_state_change",
    "request_id" : Date.now(),
    "data": {
        "person_key": "string",
        "entity" : "flow",
    }
}

// Example request when subscribing to Step state changes
{
    "action": "subscribe_state_change",
    "request_id" : Date.now(),
    "data": {
        "person_key": "string",
        "entity" : "step",
    }
}

// Example response for Flow/Step state change subscriptions
{
  "request_id": 1519211809934,
  "errors": [],
  "status": 200,
}

// Example events (flow and step changes)
{
    "event": "state_change",
    "request_id": 1519211809934,
    "data": {
        "entity": "flow",
        "id": "string",
        "identifier": "string",
        "state": "string (active, inactive, completed, exited)",
        "previous_state": "string"
    }
}

{
    "event": "state_change",
    "request_id": 1519211809934,
    "data": {
        "entity": "step",
        "id": "string",
        "identifier": "string",
        "state": "string (active, inactive, completed)",
        "previous_state": "string"
    }
}

Acceptance Criteria*

Test cases that

Dependencies

Blockers:

*required field.