Add plugin authoring best-practices section and ref docs#621
Conversation
|
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
varlock-website | 7640356 | Commit Preview URL Branch Preview URL |
Jun 16 2026, 07:16 AM |
commit: |
There was a problem hiding this comment.
Thanks for adding the docs! It comes in handy as we're looking to build a custom internal plugin.
I started following the WIP docs. When using strict: true, I got a few errors that I needed to resolve with !.
This might not be the most elegant solution, but I just wanted to put on your radar that the examples require some coercion or checks.
| async execute({ id, tokenResolver }) { | ||
| // Await dynamic values (these may reference other schema items) | ||
| const token = await tokenResolver?.resolve(); | ||
| instances[id].token = token ? String(token) : undefined; | ||
| }, | ||
| }); |
There was a problem hiding this comment.
| async execute({ id, tokenResolver }) { | |
| // Await dynamic values (these may reference other schema items) | |
| const token = await tokenResolver?.resolve(); | |
| instances[id].token = token ? String(token) : undefined; | |
| }, | |
| }); | |
| async execute({ id, tokenResolver }) { | |
| // Await dynamic values (these may reference other schema items) | |
| const token = await tokenResolver?.resolve(); | |
| instances[id]!.token = token ? String(token) : undefined; | |
| } |
| process() { | ||
| let instanceId = '_default'; | ||
| let refResolver: Resolver; | ||
|
|
||
| if (this.arrArgs!.length === 1) { | ||
| refResolver = this.arrArgs![0]; | ||
| } else { | ||
| // first arg is the instance id – must be a literal | ||
| if (!this.arrArgs![0].isStatic) { | ||
| throw new SchemaError('Instance id must be a static value'); | ||
| } | ||
| instanceId = String(this.arrArgs![0].staticValue); | ||
| refResolver = this.arrArgs![1]; | ||
| } |
There was a problem hiding this comment.
| process() { | |
| let instanceId = '_default'; | |
| let refResolver: Resolver; | |
| if (this.arrArgs!.length === 1) { | |
| refResolver = this.arrArgs![0]; | |
| } else { | |
| // first arg is the instance id – must be a literal | |
| if (!this.arrArgs![0].isStatic) { | |
| throw new SchemaError('Instance id must be a static value'); | |
| } | |
| instanceId = String(this.arrArgs![0].staticValue); | |
| refResolver = this.arrArgs![1]; | |
| } | |
| process() { | |
| let instanceId = '_default'; | |
| let refResolver: Resolver; | |
| if (this.arrArgs!.length === 1) { | |
| refResolver = this.arrArgs![0]!; | |
| } else { | |
| // first arg is the instance id – must be a literal | |
| if (!this.arrArgs![0]!.isStatic) { | |
| throw new SchemaError('Instance id must be a static value'); | |
| } | |
| instanceId = String(this.arrArgs![0]!.staticValue); | |
| refResolver = this.arrArgs![1]!; | |
| } | |
| if (!instances[instanceId]) { | |
| throw new SchemaError( | |
| `No MyPlugin instance "${instanceId}" found`, | |
| { tip: 'Add @initMyPlugin() to your .env.schema file' }, | |
| ); | |
| } | |
| return { instanceId, refResolver }; | |
| } |
|
Thanks @selfire1, we'll revisit and get something merged this week. |
Adds a plugin authoring best-practices section (design conventions, scaffolding, the four register* primitives, caching, error handling, packaging, testing) to the plugins guide, plus a Plugin API reference page documenting varlock/plugin-lib. Also notes the labeler.yaml step for new monorepo plugins in AGENTS.md.
5f9dccb to
371eedb
Compare
The consumer plugins guide (guides/plugins) is now install/scope/init/use only. The authoring how-to lives at plugins/authoring (Plugins sidebar group, after Overview); the Plugin API reference stays under Reference. Cross-linked from the overview, consumer guide, and reference page.
reference/plugin-api/folder (5 individual pages removed)reference/plugin-api.mdx— single page in the style of root-decorators / functions reference pagesastro.config.tssidebar to add one "Plugin API" entry under Reference