triggermesh icon indicating copy to clipboard operation
triggermesh copied to clipboard

(feat) add $ROOT variable in the shift operation to perform root payload shifting

Open nkreiger opened this issue 3 years ago • 3 comments

Signed-off-by: Noah Kreiger [email protected]

This change would support a variable $ROOT in the shift operation to move everything in the root payload under that key, it maintains backwards comp...and makes logical sense, aka, if you add a variable before you shift the root, it will shift with that variable, if you store a variable after the shift, you need to specify the path taking into account the shift...etc

Examples:

  context:
    - operation: store
      paths:
        - key: $id
          value: id
  data:
    - operation: store
      paths:
        - key: $tstore
          value: test
    - operation: add
      paths:
        - key: context.transaction
          value: $id
        - key: shifted.test
          value: noah
        - key: noah
          value: $tstore
    - operation: shift
      paths:
        - key: $ROOT:data

input ->

{
    "test": "teststore",
    "Shifter": {
        "some": "values"
    }
}

outputs from tsf ->

{
    "data": {
        "Shifter": {
            "some": "values"
        },
        "context": {
            "transaction": "say-hello"
        },
        "noah": "teststore",
        "shifted": {
            "test": "noah"
        },
        "test": "teststore"
    }
}

I didn't abstract the code as much as it could've been, because I couldn't think of another use case, so I thought I would keep it simple :)

nkreiger avatar Aug 06 '22 20:08 nkreiger

Also... I dont think you are in our community slack -> https://join.slack.com/t/triggermesh-community/shared_invite/zt-1e0wvv0ud-CoM_73OBunIDoYR29eMo8A @nkreiger jump in so I can bug you! 😁

JeffNeff avatar Aug 10 '22 16:08 JeffNeff

pre-approving, before test fixes.

JeffNeff avatar Aug 10 '22 16:08 JeffNeff

@JeffNeff it looks like the linting failed on a code file unrelated to my chagne, would you like me to resolve this as well?

nkreiger avatar Aug 12 '22 17:08 nkreiger

@nkreiger Thanks for the PR. Before I review the code, does this change somehow correlate with this https://github.com/triggermesh/triggermesh/pull/1049 ?

tzununbekov avatar Aug 15 '22 14:08 tzununbekov

@nkreiger Thanks for the PR. Before I review the code, does this change somehow correlate with this #1049 ?

@tzununbekov yes lol, exactly, I guess I should've looked at open PRs/Issues first but it was a quick thing so I didn't my bad...I can close this PR

nkreiger avatar Aug 15 '22 15:08 nkreiger