MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / createPluginAtomClient

Function createPluginAtomClient

packages/core/sdk/src/client.ts:344–380  ·  view source on GitHub ↗
(
  group: G,
  options: CreatePluginAtomClientOptions = {},
)

Source from the content-addressed store, hash-verified

342 * React tree without colliding.
343 */
344export const createPluginAtomClient = <
345 G extends HttpApiGroup.HttpApiGroup<string, HttpApiEndpoint.Any, boolean>,
346>(
347 group: G,
348 options: CreatePluginAtomClientOptions = {},
349) => {
350 const { baseUrl = "/api", authorizationHeader, headers } = options;
351 const pluginId = group.identifier;
352 const bundle = HttpApi.make(`plugin-${pluginId}`).add(group);
353 const getBaseUrl = typeof baseUrl === "function" ? baseUrl : null;
354 const staticBaseUrl = typeof baseUrl === "function" ? undefined : baseUrl;
355 const getAuthorizationHeader =
356 typeof authorizationHeader === "function" ? authorizationHeader : null;
357 const hasAuthorization = authorizationHeader !== undefined && authorizationHeader !== null;
358 const hasHeaders = headers !== undefined;
359 const transformClient =
360 getBaseUrl || hasAuthorization || hasHeaders
361 ? HttpClient.mapRequest((request) =>
362 applyPluginAtomClientRequestTransform(request, {
363 ...(getBaseUrl ? { baseUrl: getBaseUrl } : {}),
364 ...(getAuthorizationHeader
365 ? { authorizationHeader: getAuthorizationHeader }
366 : authorizationHeader !== undefined
367 ? { authorizationHeader }
368 : {}),
369 ...(headers !== undefined ? { headers } : {}),
370 }),
371 )
372 : undefined;
373
374 return AtomHttpApi.Service<`Plugin_${G["identifier"]}Client`>()(`Plugin_${pluginId}Client`, {
375 api: bundle,
376 httpClient: FetchHttpClient.layer,
377 ...(staticBaseUrl !== undefined ? { baseUrl: staticBaseUrl } : {}),
378 ...(transformClient ? { transformClient } : {}),
379 });
380};
381
382// ---------------------------------------------------------------------------
383// ExecutorPluginsProvider + hooks — host-level distribution of the loaded

Callers 7

client.test.tsFile · 0.90
client.tsxFile · 0.90
page.tsxFile · 0.90
client.tsFile · 0.90
client.tsFile · 0.90
client.tsFile · 0.90
client.tsFile · 0.90

Tested by

no test coverage detected