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

Function createPluginAtomClient

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

Source from the content-addressed store, hash-verified

420 * React tree without colliding.
421 */
422export const createPluginAtomClient = <
423 G extends HttpApiGroup.HttpApiGroup<string, HttpApiEndpoint.Any, boolean>,
424>(
425 group: G,
426 options: CreatePluginAtomClientOptions = {},
427) => {
428 const { baseUrl = "/api", authorizationHeader, headers } = options;
429 const pluginId = group.identifier;
430 const bundle = HttpApi.make(`plugin-${pluginId}`).add(group);
431 const getBaseUrl = typeof baseUrl === "function" ? baseUrl : null;
432 const staticBaseUrl = typeof baseUrl === "function" ? undefined : baseUrl;
433 const getAuthorizationHeader =
434 typeof authorizationHeader === "function" ? authorizationHeader : null;
435 const hasAuthorization = authorizationHeader !== undefined && authorizationHeader !== null;
436 const hasHeaders = headers !== undefined;
437 const transformClient =
438 getBaseUrl || hasAuthorization || hasHeaders
439 ? HttpClient.mapRequest((request) =>
440 applyPluginAtomClientRequestTransform(request, {
441 ...(getBaseUrl ? { baseUrl: getBaseUrl } : {}),
442 ...(getAuthorizationHeader
443 ? { authorizationHeader: getAuthorizationHeader }
444 : authorizationHeader !== undefined
445 ? { authorizationHeader }
446 : {}),
447 ...(headers !== undefined ? { headers } : {}),
448 }),
449 )
450 : undefined;
451
452 return AtomHttpApi.Service<`Plugin_${G["identifier"]}Client`>()(`Plugin_${pluginId}Client`, {
453 api: bundle,
454 httpClient: FetchHttpClient.layer,
455 ...(staticBaseUrl !== undefined ? { baseUrl: staticBaseUrl } : {}),
456 ...(transformClient ? { transformClient } : {}),
457 });
458};
459
460// ---------------------------------------------------------------------------
461// 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