The architecture of a plugin wrapper's code is flexible. Still, there are some simple requirements and best practices that may guide its code structure.
A plugin must export a
PluginFactory to be used by the Polywrap Client.
PluginFactory is a function that returns a
PluginPackageManifest and a
factory method that generates an instance of the plugin.
The Polywrap CLI's
build commands will generate a
wrap folder containing useful types.
The generated types will save you time and energy.
You won't have to manually create or update your types every time you change your schema, and your code will have fewer bugs.
You can forget about boilerplate code and focus on your plugin's logic.
While the types are not strictly required, we recommend them as a best practice.
The generated types include:
Module- An interface containing the methods declared in the plugin's schema
Args_*- An interface for each method, containing the method arguments declared in the schema
- Custom Types - An interface for each custom type declared in the schema