step.dhall 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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 renderSetPipeline =
  21. λ(s : Types.SetPipelineStep) →
  22. λ(hooks : Types.StepHooks JSON.Type) →
  23. concatJSONs [ ./setPipelineStep.dhall s, ./stepHooks.dhall hooks ]
  24. let renderLoadVar =
  25. λ(l : Types.LoadVarStep) →
  26. λ(hooks : Types.StepHooks JSON.Type) →
  27. concatJSONs [ ./loadVarStep.dhall l, ./stepHooks.dhall hooks ]
  28. let renderAggregate =
  29. λ(steps : List JSON.Type) →
  30. λ(hooks : Types.StepHooks JSON.Type) →
  31. concatJSONs
  32. [ toMap { aggregate = JSON.array steps }, ./stepHooks.dhall hooks ]
  33. let renderDo =
  34. λ(steps : List JSON.Type) →
  35. λ(hooks : Types.StepHooks JSON.Type) →
  36. concatJSONs [ toMap { do = JSON.array steps }, ./stepHooks.dhall hooks ]
  37. let renderTry =
  38. λ(step : JSON.Type) →
  39. λ(hooks : Types.StepHooks JSON.Type) →
  40. concatJSONs [ toMap { try = step }, ./stepHooks.dhall hooks ]
  41. let renderInParallel =
  42. λ(config : Types.InParallelStep JSON.Type) →
  43. λ(hooks : Types.StepHooks JSON.Type) →
  44. concatJSONs [ ./inParallelStep.dhall config, ./stepHooks.dhall hooks ]
  45. let render
  46. : Types.Step → JSON.Type
  47. = λ(step : Types.Step) →
  48. step
  49. JSON.Type
  50. { get = renderGet
  51. , put = renderPut
  52. , task = renderTask
  53. , set_pipeline = renderSetPipeline
  54. , load_var = renderLoadVar
  55. , aggregate = renderAggregate
  56. , do = renderDo
  57. , try = renderTry
  58. , in_parallel = renderInParallel
  59. }
  60. in render