MCPcopy
hub / github.com/Effect-TS/effect / toHttpApiGroup

Function toHttpApiGroup

packages/workflow/src/WorkflowProxy.ts:122–146  ·  view source on GitHub ↗
(
  name: Name,
  workflows: Workflows
)

Source from the content-addressed store, hash-verified

120 * @category Constructors
121 */
122export const toHttpApiGroup = <const Name extends string, const Workflows extends NonEmptyReadonlyArray<Workflow.Any>>(
123 name: Name,
124 workflows: Workflows
125): HttpApiGroup.HttpApiGroup<Name, ConvertHttpApi<Workflows[number]>> => {
126 let group = HttpApiGroup.make(name)
127 for (const workflow of workflows) {
128 const path = `/${tagToPath(workflow.name)}` as const
129 group = group.add(
130 HttpApiEndpoint.post(workflow.name, path)
131 .setPayload(workflow.payloadSchema)
132 .addSuccess(workflow.successSchema)
133 .addError(workflow.errorSchema as any)
134 .annotateContext(workflow.annotations)
135 ).add(
136 HttpApiEndpoint.post(workflow.name + "Discard", `${path}/discard`)
137 .setPayload(workflow.payloadSchema)
138 .annotateContext(workflow.annotations)
139 ).add(
140 HttpApiEndpoint.post(workflow.name + "Resume", `${path}/resume`)
141 .setPayload(ResumePayload)
142 .annotateContext(workflow.annotations)
143 ) as any
144 }
145 return group as any
146}
147
148const tagToPath = (tag: string): string =>
149 tag

Callers

nothing calls this directly

Calls 7

addSuccessMethod · 0.80
tagToPathFunction · 0.70
makeMethod · 0.65
addMethod · 0.65
annotateContextMethod · 0.65
addErrorMethod · 0.65
setPayloadMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…