step.dhall 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. let Types = ../types/package.dhall
  2. let Prelude = ../lib/prelude.dhall
  3. let JSON = Prelude.JSON
  4. let TextJSONPair = { mapKey : Text, mapValue : JSON.Type }
  5. let concatJSONs =
  6. λ(xs : List Types.JSONObject)
  7. → JSON.object (Prelude.List.concat TextJSONPair xs)
  8. let renderGet =
  9. λ(get : Types.GetStep)
  10. → λ(hooks : Types.StepHooks JSON.Type)
  11. → concatJSONs [ ./getStep.dhall get, ./stepHooks.dhall hooks ]
  12. let renderPut =
  13. λ(put : Types.PutStep)
  14. → λ(hooks : Types.StepHooks JSON.Type)
  15. → concatJSONs [ ./putStep.dhall put, ./stepHooks.dhall hooks ]
  16. let renderTask =
  17. λ(task : Types.TaskStep)
  18. → λ(hooks : Types.StepHooks JSON.Type)
  19. → concatJSONs [ ./taskStep.dhall task, ./stepHooks.dhall hooks ]
  20. let renderAggregate =
  21. λ(steps : List JSON.Type)
  22. → λ(hooks : Types.StepHooks JSON.Type)
  23. → concatJSONs
  24. [ toMap { aggregate = JSON.array steps }, ./stepHooks.dhall hooks ]
  25. let renderDo =
  26. λ(steps : List JSON.Type)
  27. → λ(hooks : Types.StepHooks JSON.Type)
  28. → concatJSONs [ toMap { do = JSON.array steps }, ./stepHooks.dhall hooks ]
  29. let renderTry =
  30. λ(step : JSON.Type)
  31. → λ(hooks : Types.StepHooks JSON.Type)
  32. → concatJSONs [ toMap { try = step }, ./stepHooks.dhall hooks ]
  33. let renderInParallel =
  34. λ(config : Types.InParallelStep JSON.Type)
  35. → λ(hooks : Types.StepHooks JSON.Type)
  36. → concatJSONs [ ./inParallelStep.dhall config, ./stepHooks.dhall hooks ]
  37. let render
  38. : Types.Step → JSON.Type
  39. = λ(step : Types.Step)
  40. → step
  41. JSON.Type
  42. { get = renderGet
  43. , put = renderPut
  44. , task = renderTask
  45. , aggregate = renderAggregate
  46. , do = renderDo
  47. , try = renderTry
  48. , in_parallel = renderInParallel
  49. }
  50. in render