(
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 = {},
)
| 1312 | // --------------------------------------------------------------------------- |
| 1313 | |
| 1314 | export const invokeWithLayer = ( |
| 1315 | operation: OperationBinding, |
| 1316 | args: Record<string, unknown>, |
| 1317 | baseUrl: string, |
| 1318 | resolvedHeaders: Record<string, string>, |
| 1319 | integrationQueryParams: Record<string, string>, |
| 1320 | httpClientLayer: Layer.Layer<HttpClient.HttpClient, never, never>, |
| 1321 | options: InvokeOptions = {}, |
| 1322 | ) => { |
| 1323 | const effectiveBaseUrl = baseUrlForPathTemplate( |
| 1324 | resolveRequestHost(operation.servers ?? [], args.server, baseUrl), |
| 1325 | operation.pathTemplate, |
| 1326 | ); |
| 1327 | |
| 1328 | const clientWithBaseUrl = effectiveBaseUrl |
| 1329 | ? Layer.effect( |
| 1330 | HttpClient.HttpClient, |
| 1331 | Effect.map( |
| 1332 | Effect.service(HttpClient.HttpClient), |
| 1333 | HttpClient.mapRequest(HttpClientRequest.prependUrl(effectiveBaseUrl)), |
| 1334 | ), |
| 1335 | ).pipe(Layer.provide(httpClientLayer)) |
| 1336 | : httpClientLayer; |
| 1337 | |
| 1338 | return invoke(operation, args, resolvedHeaders, integrationQueryParams, options).pipe( |
| 1339 | Effect.provide(clientWithBaseUrl), |
| 1340 | // `invoke` annotates http.status_code on ITS span (`OpenApi.invoke`, |
| 1341 | // via Effect.fn) — annotateCurrentSpan inside it never reaches this |
| 1342 | // wrapper span. Stamp the status here too so queries against |
| 1343 | // `plugin.openapi.invoke` see the upstream outcome directly. |
| 1344 | Effect.tap((result) => Effect.annotateCurrentSpan({ "http.status_code": result.status })), |
| 1345 | Effect.withSpan("plugin.openapi.invoke", { |
| 1346 | attributes: { |
| 1347 | "plugin.openapi.method": operation.method.toUpperCase(), |
| 1348 | "plugin.openapi.path_template": operation.pathTemplate, |
| 1349 | "plugin.openapi.base_url": effectiveBaseUrl, |
| 1350 | }, |
| 1351 | }), |
| 1352 | ); |
| 1353 | }; |
| 1354 | |
| 1355 | // --------------------------------------------------------------------------- |
| 1356 | // Derive annotations from HTTP method |
no test coverage detected