CreatingManifests
Previous: Creating a Custom Node | Table of Contents | Next: Best Practices
Creating Manifest Nodes
Polyform operates on Directed Acyclic Graphs (DAGs), where each node performs a specific task and connects to other nodes through inputs and outputs.
Manifest nodes are special types of nodes that define the final output of a graph, typically writing one or more files to the filesystem.
What is a Manifest?
A manifest is a structure that encapsulates a set of named entries, each representing an output artifact such as an image, mesh, or any other serializable content. It also optionally defines a "main" entry, which can help tell viewers the first entry to download.
For example, if we have a manifest for a textured GLTF, you might have 2 entries: the GLTF itself, and a seperate image file the GLTF references. In this scenario, we'd set the GLTF file to be the main entry that a viewer would initially download.
Here's the core structure used for manifests:
type Entry struct {
Metadata map[string]any `json:"metadata"` // Descriptive metadata about the artifact
Artifact Artifact `json:"-"` // The actual data to be written
}
type Manifest struct {
Main string `json:"main"` // Optional: name of the main entry
Entries map[string]Entry `json:"entries"` // All entries in the manifest
}Artifacts
The Artifact interface defines what it means to be a serializable output. Any type that implements this interface can be written as part of a manifest.
Here's a minimal example for a text file:
Then you can include this in your manifest entry:
Creating a Manifest Node
A manifest node in Polyform is simply a node whose output type is manifest.Manifest. When Polyform runs a graph and reaches this node, it knows how to gather the manifest entries and process them as final outputs.
Here’s an example of what a simple manifest node might look like:
Note:
manifest.ImageArtifactin this example is a hypothetical implementation of theArtifactinterface that knows how to write an image as PNG.
Last updated