(
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 = {},
)
| 1263 | // --------------------------------------------------------------------------- |
| 1264 | |
| 1265 | export const invokeWithLayer = ( |
| 1266 | operation: OperationBinding, |
| 1267 | args: Record<string, unknown>, |
| 1268 | baseUrl: string, |
| 1269 | resolvedHeaders: Record<string, string>, |
| 1270 | integrationQueryParams: Record<string, string>, |
| 1271 | httpClientLayer: Layer.Layer<HttpClient.HttpClient, never, never>, |
| 1272 | options: InvokeOptions = {}, |
| 1273 | ) => { |
| 1274 | const effectiveBaseUrl = resolveRequestHost(operation.servers ?? [], args.server, baseUrl); |
| 1275 | const clientWithBaseUrl = effectiveBaseUrl |
| 1276 | ? Layer.effect( |
| 1277 | HttpClient.HttpClient, |
| 1278 | Effect.map( |
| 1279 | Effect.service(HttpClient.HttpClient), |
| 1280 | HttpClient.mapRequest(HttpClientRequest.prependUrl(effectiveBaseUrl)), |
| 1281 | ), |
| 1282 | ).pipe(Layer.provide(httpClientLayer)) |
| 1283 | : httpClientLayer; |
| 1284 | |
| 1285 | return invoke(operation, args, resolvedHeaders, integrationQueryParams, options).pipe( |
| 1286 | Effect.provide(clientWithBaseUrl), |
| 1287 | // `invoke` annotates http.status_code on ITS span (`OpenApi.invoke`, |
| 1288 | // via Effect.fn) — annotateCurrentSpan inside it never reaches this |
| 1289 | // wrapper span. Stamp the status here too so queries against |
| 1290 | // `plugin.openapi.invoke` see the upstream outcome directly. |
| 1291 | Effect.tap((result) => Effect.annotateCurrentSpan({ "http.status_code": result.status })), |
| 1292 | Effect.withSpan("plugin.openapi.invoke", { |
| 1293 | attributes: { |
| 1294 | "plugin.openapi.method": operation.method.toUpperCase(), |
| 1295 | "plugin.openapi.path_template": operation.pathTemplate, |
| 1296 | "plugin.openapi.base_url": effectiveBaseUrl, |
| 1297 | }, |
| 1298 | }), |
| 1299 | ); |
| 1300 | }; |
| 1301 | |
| 1302 | // --------------------------------------------------------------------------- |
| 1303 | // Derive annotations from HTTP method |
no test coverage detected