Class UiApiInvoker

java.lang.Object
com.kingsrook.qqq.middleware.javalin.specs.invoke.UiApiInvoker

public class UiApiInvoker extends Object
Invokes UI API (`/qqq/v1`) operations from inside the server, with a given user's session, with exactly the semantics of an HTTP client: the call is a loopback HTTP request to the running server, so it passes through the same session setup, permission checks, filters, logging and error mapping as a request from the UI. Used by the AI assistant, which must be held to the user's own security boundaries. See docs/UI-API-EXTENSIONS.md. - Only operations described by an endpoint spec (core or extension) can be invoked; anything else is refused before a request is made. - The caller's credentials are required and are forwarded exactly as the caller's request carried them (session cookies, Authorization, x-api-key), so the call authenticates as the same user with any authentication module; there is no service session and no elevation. - Nested invocation on one thread is limited to MAX_DEPTH.
  • Field Details

  • Constructor Details

    • UiApiInvoker

      public UiApiInvoker(Supplier<String> baseUrlSupplier, AbstractMiddlewareVersion middlewareVersion)
      Constructor
      Parameters:
      baseUrlSupplier - scheme, host and port of the server, e.g. http://127.0.0.1:8000
      middlewareVersion - the UI API version whose operations may be invoked
  • Method Details

    • forServer

      public static UiApiInvoker forServer(QApplicationJavalinServer server)
      An invoker for a running server's first (current) UI API version, calling it on the loopback interface.
    • forServer

      public static UiApiInvoker forServer(QApplicationJavalinServer server, String clientChannel)
      An invoker for a running server, labelling every call with a client channel (e.g. assistant) - fixed here, server side: a request can only add detail (assistant/), never change or remove the channel.
    • withClientChannel

      public UiApiInvoker withClientChannel(String clientChannel)
      Set the client channel name every call is labelled with (default api).
    • getClientChannel

      public String getClientChannel()
      Getter for clientChannel
    • forBaseUrl

      public static UiApiInvoker forBaseUrl(String baseUrl, AbstractMiddlewareVersion middlewareVersion)
      An invoker for a server at a given base URL (scheme, host and port).
    • listOperations

      public List<UiApiOperation> listOperations()
      Every operation that can be invoked, from the same specs that generate the OpenAPI document.
    • findOperation

      public Optional<UiApiOperation> findOperation(HttpMethod method, String pathTemplate)
      Find the operation for a method and path template.
    • invoke

      public UiApiResponse invoke(UiApiRequest request) throws QException
      Invoke an operation with the request's session.
      Throws:
      QException
    • invokeForStream

      public UiApiStreamResponse invokeForStream(UiApiRequest request) throws QException
      Invoke with a streamed body. The caller must close the returned response. Invocation depth is released on return, independently of stream lifetime.
      Throws:
      QException