1.21.0 • Published 6 years ago

trigger-puller v1.21.0

Weekly downloads
1
License
ISC
Repository
-
Last release
6 years ago

Trigger Puller Architecture

Trigger puller architecture Password: lx123

Test Harness

npm start will run the test harness, which accepts POST requests with a body of the form

{
  "lxMessage": {...},
  "parameters": {...}
}

Where lxMessage is the triggering event, and parameters is the extensions install.

Example

The following example will trigger an email reaction.

{
  "lxMessage": {
    "subject": "recordChangePostCommit",
    "message": {
      "contents": {
        "record": {
          "id": 12732137,
          "apiName": "beer"
        },
        "priorState": {
          "name": "Coopers Stout",
          "unit_count": 21,
          "gluten_free": { "tag": "true", "value": {} },
          "foo": "bar"
        },
        "changeSet": {
          "unit_count": 18
        }
      }
    }
  },
  "parameters": {
    "args": {
      "field-unit_count": {
        "fieldApiName": "unit_count",
        "resolver": "recordField"
      },
      "email": {
        "html": "Didja get that thing I sent you?",
        "from": "Christie",
        "text": "Didja get that thing I sent you?",
        "subject": "That thing I sent you",
        "recipients": "xie.williams@lanetix.com"
      }
    },
    "condition": {
      "qualifier": "bogan",
      "expression": {
        "expressions": [
          {
            "operands": [
              {
                "::argId": "field-unit_count"
              },
              20
            ],
            "operator": "<="
          }
        ],
        "operator": "&"
      }
    },
    "subject": "recordChangePostCommit",
    "context": {
      "record": {
        "apiName": "beer"
      }
    },
    "name": "Unit Count Low",
    "description": "Sends an email when unit count drops below threshold.",
    "reactions": [
      {
        "handler": "email",
        "argId": "email"
      }
    ],
    "id": "triggerpullerb0625452cadc4ce0aa75cef02427f606"
  }
}

Types

We're not flow typed yet, but for documentation's sake.

type LxMessage = {
  subject: string,
  message: Object
}

type Condition = {
  qualifier: 'bogan' | 'alwaysTrue',
  expression?: Object
}

type Reaction = {
  handler: 'dump' | 'email',
  argId?: string
}

type Trigger = {
  id: string,
  args: Object,
  name: string,
  subject: 'recordChangePostCommit',
  condition: Condition,
  reactions: Array<Reaction>
}

Publishing to trigger-puller

After merging your branch on Github, it doesn't automatically "deploy" once circle finishes building master. You also need to publish to extensions.

  1. On your local, switch back to master branch of trigger-puller and run git pull
  2. Run npm i -g @lanetix/lxt. This is the extensions cli found here
  3. Run npm version minor (This can be major, minor, patch)
  4. Run lxt publish. It will ask for your Lanetix login credentials. Input them.
  5. Finally, git push to update the version in github.
  6. Validate your code changes 1) by testing in production and 2) looking up the extensions table in dynamoDB to see the new version is indeed published, and it is at the @latest. Here is the link to the dynamoDB extensions table