feat: chained notebooks with when sections and host blocks (#11)
A notebook can include another one and continue with what it produced:
- core: parse :::when{param=a,b}, ::use{notebook= as= with=} and
::host{name= address= user= port= capture=}; composeNotebook namespaces
an included notebook's params, steps, captures and templates by alias
(cycles, missing files, depth > 4 and child errors are reported on the
use line). Defaults may reference captures and builtins
({{shellbook.public_key}}); required params and secrets gate only steps
of their own scope; secretEnv passes a scope's secrets under local names.
- protocol: NotebookResponse gains includes and builtins.
- server: compose includes on load, inject builtins (client values are
ignored), refuse steps in inactive when sections.
- web: render when/use/host blocks, group included params in the form,
add a created machine to Hosts and capture its name, reload when an
included notebook changes, run all checks only for active steps,
authoring snippets for when, use and host.
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
import type {
|
||||
HostInfo,
|
||||
HostInventoryResponse,
|
||||
SaveHostRequest,
|
||||
NotebookListResponse,
|
||||
HostsResponse,
|
||||
NotebookResponse,
|
||||
@@ -66,6 +69,8 @@ export interface Api {
|
||||
baseVersion: string,
|
||||
): Promise<SaveNotebookResponse>;
|
||||
run(request: StartRunRequest): Promise<StartRunResponse>;
|
||||
/** Add a host to the inventory (a notebook's `::host` block); 409 if the name is taken. */
|
||||
addHost(host: HostInfo): Promise<void>;
|
||||
events(
|
||||
receive: (event: ServerEvent) => void,
|
||||
connection: (connected: boolean) => void,
|
||||
@@ -93,6 +98,11 @@ export const liveApi: Api = {
|
||||
baseVersion,
|
||||
}),
|
||||
run: (request) => json("/runs", "POST", request),
|
||||
async addHost(host) {
|
||||
const { version } = await json<HostInventoryResponse>("/host-management");
|
||||
const request: SaveHostRequest = { host, baseVersion: version };
|
||||
await json("/host-management", "POST", request);
|
||||
},
|
||||
artifact: (id, name) =>
|
||||
`/api/runs/${encodeURIComponent(id)}/artifacts/${encodeURIComponent(name)}`,
|
||||
events(receive, connection) {
|
||||
|
||||
Reference in New Issue
Block a user