Add plugin authoring best-practices section and ref docs#621
Add plugin authoring best-practices section and ref docs#621
Conversation
Agent-Logs-Url: https://github.com/dmno-dev/varlock/sessions/5df62f64-9242-42ce-930b-beb085280d9a Co-authored-by: philmillman <3722211+philmillman@users.noreply.github.com>
Agent-Logs-Url: https://github.com/dmno-dev/varlock/sessions/5df62f64-9242-42ce-930b-beb085280d9a Co-authored-by: philmillman <3722211+philmillman@users.noreply.github.com>
|
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
varlock-website | caaadfb | Commit Preview URL Branch Preview URL |
Apr 15 2026, 07:32 PM |
Agent-Logs-Url: https://github.com/dmno-dev/varlock/sessions/1d76414c-3948-437f-9607-441289d4a2fd Co-authored-by: philmillman <3722211+philmillman@users.noreply.github.com>
Agent-Logs-Url: https://github.com/dmno-dev/varlock/sessions/1d76414c-3948-437f-9607-441289d4a2fd Co-authored-by: philmillman <3722211+philmillman@users.noreply.github.com>
Agent-Logs-Url: https://github.com/dmno-dev/varlock/sessions/1d76414c-3948-437f-9607-441289d4a2fd Co-authored-by: philmillman <3722211+philmillman@users.noreply.github.com>
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. |
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