Skip to content

krateoplatformops/smithery

Repository files navigation

Smithery

Go Report Card

This service transforms a user-defined JSONSchema into a Kubernetes Custom Resource Definition (CRD) that defines the structure and behavior of UI components.

It's designed for front-end developers to describe component configuration declaratively, while enabling runtime enrichment and action handling via a companion service called Snowplow.


Purpose

Front-end developers use Smithery to define the properties of a UI component using JSONSchema, specifically under the widgetData section.

Smithery:

  1. Parses and validates the user-defined schema.
  2. Injects additional schema sections that enable runtime logic, templating, and remote interactions.
  3. Outputs a complete CRD that is Kubernetes-compatible.

Workflow Overview

Workflow Overview


Injected Schema Sections

Before generating the CRD, Smithery automatically injects the following three JSONSchema sections into the root level of the user’s schema. These allow CRs to be dynamically enriched and to interact with external systems at runtime.

Field Type Description
apiRef object Defines a RESTAction that acts as a data source. The response (JSON) will be available for JQ expression resolution in templates.
widgetDataTemplate object A template layer on top of widgetData using JQ expressions. These are evaluated at runtime by Snowplow, with data from apiRef.
resourcesRefs object Describes a set of runtime actions (e.g., REST operations) triggered by the component (e.g., onClick for a button).
resourcesRefsTemplate object Describes one or more templates to generate set of runtime actions (e.g., REST operations) triggered by the component (e.g., onClick for a button).

These sections are located in the Smithery repo under /assets.


apiRef – External Data Source

  • Located at: apiRef.json
  • Defines a single REST request (method, URL, headers, body) with optional parameters.
  • Snowplow executes this and stores the result as a JSON object, accessible to templates and logic elsewhere in the CR.

Example Use Case:

Fetching a list of users from an external API to populate a dropdown.


widgetDataTemplate – JQ-based Field Templating

  • Located at: widgetDataTemplate.json

  • Defines an array of pairs of path to widgetData properties and a related JQ expression.

  • At runtime, Snowplow evaluates these using the apiRef result as input and merges the evaluated data into widgetData specs.

Example Use Case:

Filling a widget fields with data from an external remote HTTP service (or internal Kubernetes API call).


resourcesRefs – Declarative Actions

  • Located at: resourcesRefs.json
  • Defines runtime actions triggered by the widget, such as HTTP POST requests when a button is clicked.
  • These can be tied to UI events and can have different HTTP methods, payloads, etc.

Example Use Case:

When a button is clicked, send a POST request to submit form data to an external API (or to Kubernetes API Server).


resourcesRefsTemplate – Declarative Actions Templates

  • Located at: resourcesRefs.json

  • Allows for the definition of one or more templates to dynamically generate resourcesRefs objects. In this context, "dynamically" means that the properties (i.e., their values) are the results of JQ expressions evaluated against the output obtained from a previous resolution of an apiRef.

This mechanism enables the flexible and automated creation of resource references based on dynamic data, facilitating more adaptable and efficient workflows.


Resources

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages