(
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 = {},
)
| 1418 | // --------------------------------------------------------------------------- |
| 1419 | |
| 1420 | export const invokeWithLayer = ( |
| 1421 | operation: OperationBinding, |
| 1422 | args: Record<string, unknown>, |
| 1423 | baseUrl: string, |
| 1424 | resolvedHeaders: Record<string, string>, |
| 1425 | integrationQueryParams: Record<string, string>, |
| 1426 | httpClientLayer: Layer.Layer<HttpClient.HttpClient, never, never>, |
| 1427 | options: InvokeOptions = {}, |
| 1428 | ) => { |
| 1429 | const effectiveBaseUrl = baseUrlForPathTemplate( |
| 1430 | resolveRequestHost(operation.servers ?? [], args.server, baseUrl), |
| 1431 | operation.pathTemplate, |
| 1432 | ); |
| 1433 | |
| 1434 | const clientWithBaseUrl = effectiveBaseUrl |
| 1435 | ? Layer.effect( |
| 1436 | HttpClient.HttpClient, |
| 1437 | Effect.map( |
| 1438 | Effect.service(HttpClient.HttpClient), |
| 1439 | HttpClient.mapRequest(HttpClientRequest.prependUrl(effectiveBaseUrl)), |
| 1440 | ), |
| 1441 | ).pipe(Layer.provide(httpClientLayer)) |
| 1442 | : httpClientLayer; |
| 1443 | |
| 1444 | return invoke(operation, args, resolvedHeaders, integrationQueryParams, options).pipe( |
| 1445 | Effect.provide(clientWithBaseUrl), |
| 1446 | // `invoke` annotates http.status_code on ITS span (`OpenApi.invoke`, |
| 1447 | // via Effect.fn) — annotateCurrentSpan inside it never reaches this |
| 1448 | // wrapper span. Stamp the status here too so queries against |
| 1449 | // `plugin.openapi.invoke` see the upstream outcome directly. |
| 1450 | Effect.tap((result) => Effect.annotateCurrentSpan({ "http.status_code": result.status })), |
| 1451 | Effect.withSpan("plugin.openapi.invoke", { |
| 1452 | attributes: { |
| 1453 | "plugin.openapi.method": operation.method.toUpperCase(), |
| 1454 | "plugin.openapi.path_template": operation.pathTemplate, |
| 1455 | "plugin.openapi.base_url": effectiveBaseUrl, |
| 1456 | }, |
| 1457 | }), |
| 1458 | ); |
| 1459 | }; |
| 1460 | |
| 1461 | // --------------------------------------------------------------------------- |
| 1462 | // Derive annotations from HTTP method |
no test coverage detected