ui/server/src/componentsApi
The Components screen's API.
Cockpit server, next. Source: ui/server/src/componentsApi.mjs.
Variables#
MAX_COMPONENT_BYTES#
constMAX_COMPONENT_BYTES:number
Defined in: ui/server/src/componentsApi.mjs:28
MAX_EDIT_BYTES#
constMAX_EDIT_BYTES:number
Defined in: ui/server/src/componentsApi.mjs:30
Functions#
componentDescribe()#
componentDescribe(
root,rel,options?):Promise<{body: {code:any;error:any;ok:boolean; };status:any; } | {body:any;status:number; }>
Defined in: ui/server/src/componentsApi.mjs:78
Parameters#
root
any
rel
any
options?
Returns#
Promise<{ body: { code: any; error: any; ok: boolean; }; status: any; } | { body: any; status: number; }>
componentSave()#
componentSave(
root,body,__namedParameters?): {body: {code:any;error:any;ok:boolean; };status:any; } | {body: {after:string;autoCommit?:undefined;before:any;changed:boolean;contentHash:string;ok:boolean;path?:undefined;unchanged?:undefined;violations?:undefined; };status:number; } | {body: {after?:undefined;autoCommit?:undefined;before?:undefined;changed?:undefined;contentHash:string;ok:boolean;path:any;unchanged:boolean;violations:any[]; };status:number; } | {body: {after?:undefined;autoCommit:any;before?:undefined;changed?:undefined;contentHash:string;ok:boolean;path:any;unchanged?:undefined;violations:any[]; };status:number; }
Defined in: ui/server/src/componentsApi.mjs:151
Preview (commit false: nothing written, returns before/after) or save (commit true). The file's text is the
only thing the client sends; where it goes is decided here. afterSave(root, rel) is commit-on-save.
Parameters#
root
any
body
any
__namedParameters?
afterSave?
() => any = ...
Returns#
{ body: { code: any; error: any; ok: boolean; }; status: any; } | { body: { after: string; autoCommit?: undefined; before: any; changed: boolean; contentHash: string; ok: boolean; path?: undefined; unchanged?: undefined; violations?: undefined; }; status: number; } | { body: { after?: undefined; autoCommit?: undefined; before?: undefined; changed?: undefined; contentHash: string; ok: boolean; path: any; unchanged: boolean; violations: any[]; }; status: number; } | { body: { after?: undefined; autoCommit: any; before?: undefined; changed?: undefined; contentHash: string; ok: boolean; path: any; unchanged?: undefined; violations: any[]; }; status: number; }
componentsIndex()#
componentsIndex(
root):object
Defined in: ui/server/src/componentsApi.mjs:58
Parameters#
root
any
Returns#
object
body
body:
object
body.components
components:
any
body.count
count:
any=components.length
body.ok
ok:
boolean=true
status
status:
number=200
componentSource()#
componentSource(
root,rel):Promise<{body: {code:any;error:any;ok:boolean; };status:any; } | {body: {contentHash:string;diagnostics:any[];editable:boolean;feature:any;frozen?:boolean;name:any;ok:boolean;path:any;source:any; };status:number; }>
Defined in: ui/server/src/componentsApi.mjs:101
Parameters#
root
any
rel
any
Returns#
Promise<{ body: { code: any; error: any; ok: boolean; }; status: any; } | { body: { contentHash: string; diagnostics: any[]; editable: boolean; feature: any; frozen?: boolean; name: any; ok: boolean; path: any; source: any; }; status: number; }>
componentUsedBy()#
componentUsedBy(
root,rel): {body: {code:any;error:any;ok:boolean; };status:any; } | {body: {ok:boolean;pages:any;path:any; };status:number; }
Defined in: ui/server/src/componentsApi.mjs:120
"Used by": which pages import this component, transitively, with the feature each lands in. Reuses the impact engine seeded with this one file; unbounded depth so a component wrapped by another component still surfaces the page at the top. Never fails the request — impact is a bonus.
Parameters#
root
any
rel
any
Returns#
{ body: { code: any; error: any; ok: boolean; }; status: any; } | { body: { ok: boolean; pages: any; path: any; }; status: number; }
componentWorkflow()#
componentWorkflow(
root,rel): {body: {code:any;error:any;ok:boolean; };status:any; } | {body: {feature?:undefined;file?:undefined;machines:any[];ok:boolean;path:any; };status:number; } | {body: {feature:any;file:string;machines:any[];ok:boolean;path:any; };status:number; }
Defined in: ui/server/src/componentsApi.mjs:137
"State switcher": the workflow machine that drives this component, found by a fixed convention (no
inference, no guessing) — a same-named file in the SAME feature's workflows/ layer: <Name>.tsx, <Name>.ts,
or <Name>Workflow.ts(x). Returns machines: [] (never an error) when the component has none; this is the
common case, not a failure.
Parameters#
root
any
rel
any
Returns#
{ body: { code: any; error: any; ok: boolean; }; status: any; } | { body: { feature?: undefined; file?: undefined; machines: any[]; ok: boolean; path: any; }; status: number; } | { body: { feature: any; file: string; machines: any[]; ok: boolean; path: any; }; status: number; }
createComponentsRouter()#
createComponentsRouter(
deps):any
Defined in: ui/server/src/componentsApi.mjs:172
Parameters#
deps
afterSave?
(root, rel) => unknown
clientOrigin?
string
describeOptions?
any = {}
getRoot
() => { ok: true; root: string; } | { error: string; ok: false; }
Returns#
any
listComponents()#
listComponents(
root):any
Defined in: ui/server/src/componentsApi.mjs:37
Every component file of the project: { name, path, feature } (feature is null outside features/).
Parameters#
root
any
Returns#
any