(
operation: OperationBinding,
args: Record<string, unknown>,
baseUrl: string,
resolvedHeaders: Record<string, string>,
integrationQueryParams: Record<string, string>,
httpClientLayer: Layer.Layer<HttpClient.HttpClient, never, never>,
options: InvokeOptions = {},
)
| 1378 | // --------------------------------------------------------------------------- |
| 1379 | |
| 1380 | export const invokeWithLayer = ( |
| 1381 | operation: OperationBinding, |
| 1382 | args: Record<string, unknown>, |
| 1383 | baseUrl: string, |
| 1384 | resolvedHeaders: Record<string, string>, |
| 1385 | integrationQueryParams: Record<string, string>, |
| 1386 | httpClientLayer: Layer.Layer<HttpClient.HttpClient, never, never>, |
| 1387 | options: InvokeOptions = {}, |
| 1388 | ) => { |
| 1389 | const effectiveBaseUrl = baseUrlForPathTemplate( |
| 1390 | resolveRequestHost(operation.servers ?? [], args.server, baseUrl), |
| 1391 | operation.pathTemplate, |
| 1392 | ); |
| 1393 | |
| 1394 | const clientWithBaseUrl = effectiveBaseUrl |
| 1395 | ? Layer.effect( |
| 1396 | HttpClient.HttpClient, |
| 1397 | Effect.map( |
| 1398 | Effect.service(HttpClient.HttpClient), |
| 1399 | HttpClient.mapRequest(HttpClientRequest.prependUrl(effectiveBaseUrl)), |
| 1400 | ), |
| 1401 | ).pipe(Layer.provide(httpClientLayer)) |
| 1402 | : httpClientLayer; |
| 1403 | |
| 1404 | return invoke(operation, args, resolvedHeaders, integrationQueryParams, options).pipe( |
| 1405 | Effect.provide(clientWithBaseUrl), |
| 1406 | // `invoke` annotates http.status_code on ITS span (`OpenApi.invoke`, |
| 1407 | // via Effect.fn) — annotateCurrentSpan inside it never reaches this |
| 1408 | // wrapper span. Stamp the status here too so queries against |
| 1409 | // `plugin.openapi.invoke` see the upstream outcome directly. |
| 1410 | Effect.tap((result) => Effect.annotateCurrentSpan({ "http.status_code": result.status })), |
| 1411 | Effect.withSpan("plugin.openapi.invoke", { |
| 1412 | attributes: { |
| 1413 | "plugin.openapi.method": operation.method.toUpperCase(), |
| 1414 | "plugin.openapi.path_template": operation.pathTemplate, |
| 1415 | "plugin.openapi.base_url": effectiveBaseUrl, |
| 1416 | }, |
| 1417 | }), |
| 1418 | ); |
| 1419 | }; |
| 1420 | |
| 1421 | // --------------------------------------------------------------------------- |
| 1422 | // Derive annotations from HTTP method |
no test coverage detected