MCPcopy Create free account
hub / github.com/Effect-TS/effect / toHttpApiGroup

Function toHttpApiGroup

packages/effect/src/unstable/workflow/WorkflowProxy.ts:141–164  ·  view source on GitHub ↗
(
  name: Name,
  workflows: Workflows
)

Source from the content-addressed store, hash-verified

139 * @since 4.0.0
140 */
141export const toHttpApiGroup = <const Name extends string, const Workflows extends NonEmptyReadonlyArray<Workflow.Any>>(
142 name: Name,
143 workflows: Workflows
144): HttpApiGroup.HttpApiGroup<Name, ConvertHttpApi<Workflows[number]>> => {
145 let group = HttpApiGroup.make(name)
146 for (const workflow_ of workflows) {
147 const workflow = workflow_ as Workflow.AnyWithProps
148 const path = `/${tagToPath(workflow._tag)}` as const
149 group = group.add(
150 HttpApiEndpoint.post(workflow._tag, path, {
151 payload: workflow.payloadSchema,
152 success: workflow.successSchema,
153 error: workflow.errorSchema
154 }).annotateMerge(workflow.annotations),
155 HttpApiEndpoint.post(workflow._tag + "Discard", `${path}/discard`, {
156 payload: workflow.payloadSchema
157 }).annotateMerge(workflow.annotations),
158 HttpApiEndpoint.post(workflow._tag + "Resume", `${path}/resume`, {
159 payload: ResumePayload
160 }).annotateMerge(workflow.annotations)
161 ) as any
162 }
163 return group as any
164}
165
166const tagToPath = (tag: string): string =>
167 tag

Callers

nothing calls this directly

Calls 4

tagToPathFunction · 0.70
makeMethod · 0.65
addMethod · 0.65
annotateMergeMethod · 0.65

Tested by

no test coverage detected