(onEndpointOptions)
| 480 | options.onGroup?.(onGroupOptions) |
| 481 | }, |
| 482 | onEndpoint(onEndpointOptions) { |
| 483 | const { group, endpoint, mergedAnnotations } = onEndpointOptions |
| 484 | const parseOptions = HttpApi.getSlotParseOptions(mergedAnnotations) |
| 485 | const makeUrl = compilePath(endpoint.path, endpoint.params) |
| 486 | const upgrade = getUpgradeSuccessSchema(endpoint) |
| 487 | const decodeEndpointResponse = makeEndpointDecoder(onEndpointOptions) |
| 488 | |
| 489 | const encodeParams = UndefinedOr.map( |
| 490 | endpoint.params, |
| 491 | (schema) => Schema.encodeUnknownEffect(schema, parseOptions.params) |
| 492 | ) |
| 493 | |
| 494 | const payloadSchemas: Array<Schema.Top> = [] |
| 495 | let streamPayload: StreamPayloadSchema | undefined |
| 496 | for (const schema of HttpApiEndpoint.getPayloadSchemas(endpoint)) { |
| 497 | if (HttpApiSchema.isStreamUint8Array(schema) || HttpApiSchema.isStreamNdjson(schema)) { |
| 498 | streamPayload = schema |
| 499 | } else { |
| 500 | payloadSchemas.push(schema) |
| 501 | } |
| 502 | } |
| 503 | const streamPayloadEncoder = UndefinedOr.map(streamPayload, (schema) => ({ |
| 504 | contentType: schema.contentType, |
| 505 | encode: makeStreamPayloadEncoder(schema, parseOptions.payload) |
| 506 | })) |
| 507 | const encodePayload = Arr.isArrayNonEmpty(payloadSchemas) ? |
| 508 | Schema.encodeUnknownEffect( |
| 509 | HttpMethod.hasBody(endpoint.method) |
| 510 | ? getEncodePayloadSchema(payloadSchemas, endpoint.method) |
| 511 | : Schema.Union(payloadSchemas), |
| 512 | parseOptions.payload |
| 513 | ) : |
| 514 | undefined |
| 515 | |
| 516 | const encodeHeaders = UndefinedOr.map( |
| 517 | endpoint.headers, |
| 518 | (schema) => Schema.encodeUnknownEffect(schema, parseOptions.headers) |
| 519 | ) |
| 520 | const encodeQuery = UndefinedOr.map( |
| 521 | endpoint.query, |
| 522 | (schema) => Schema.encodeUnknownEffect(schema, parseOptions.query) |
| 523 | ) |
| 524 | |
| 525 | const middlewareKeys = Array.from(onEndpointOptions.middleware, (tag) => `${tag.key}/Client`) |
| 526 | const redactedNames = HttpApi.getEndpointRedactedNames(api, group, endpoint) |
| 527 | const redactedParams = HttpApi.getEndpointRedactedParams(api, group, endpoint) |
| 528 | // Names declared on the API or group may belong to other endpoints. |
| 529 | const redactsPath = redactedParams.all || |
| 530 | redactedParams.names.some((name) => endpoint.path.includes(`:${name}`)) |
| 531 | |
| 532 | const declaredPath: ClientPath = { template: endpoint.path, path: endpoint.path } |
| 533 | |
| 534 | const endpointFn = Effect.fnUntraced(function*( |
| 535 | request: { |
| 536 | readonly params: Record<string, string> | undefined |
| 537 | readonly query: unknown |
| 538 | readonly payload: unknown |
| 539 | readonly headers: Record<string, string> | undefined |
nothing calls this directly
no test coverage detected