Documentation
¶
Overview ¶
Copyright (c) 2026 Lark Technologies Pte. Ltd. SPDX-License-Identifier: MIT
Index ¶
Constants ¶
const ( // WhiteboardQueryAsImage exports a whiteboard preview image. WhiteboardQueryAsImage = "image" // WhiteboardQueryAsSvg exports a whiteboard as SVG. WhiteboardQueryAsSvg = "svg" // WhiteboardQueryAsCode exports Mermaid or PlantUML source extracted from the whiteboard. WhiteboardQueryAsCode = "code" // WhiteboardQueryAsRaw exports the raw whiteboard node payload. WhiteboardQueryAsRaw = "raw" )
const ( // FormatRaw sends raw whiteboard node JSON to the create-nodes API. FormatRaw = "raw" // FormatPlantUML sends PlantUML source through the diagram import API. FormatPlantUML = "plantuml" // FormatMermaid sends Mermaid source through the diagram import API. FormatMermaid = "mermaid" // FormatSVG sends SVG source through the diagram import API. FormatSVG = "svg" )
const WhiteboardUpdateDescription = "" /* 137-byte string literal not displayed */
WhiteboardUpdateDescription describes the whiteboard update shortcut.
Variables ¶
var SyntaxTypeExtensionMap = map[SyntaxType]string{ SyntaxTypePlantUML: ".puml", SyntaxTypeMermaid: ".mmd", }
SyntaxTypeExtensionMap maps whiteboard syntax types to their default file extensions.
var SyntaxTypeNameMap = map[SyntaxType]string{ SyntaxTypePlantUML: "plantuml", SyntaxTypeMermaid: "mermaid", }
SyntaxTypeNameMap maps whiteboard syntax types to their CLI output names.
var WhiteboardQuery = common.Shortcut{ Service: "whiteboard", Command: "+query", Description: "Query a existing whiteboard, export it as preview image or raw nodes structure.", Risk: "read", Scopes: []string{"board:whiteboard:node:read"}, AuthTypes: []string{"user", "bot"}, Flags: []common.Flag{ {Name: "whiteboard-token", Desc: "whiteboard token of the whiteboard. You will need read permission to download preview image.", Required: true}, {Name: "output_as", Desc: "output whiteboard as: image | svg | code | raw.", Required: true}, {Name: "output", Desc: "output directory. It is required when output as image. If not specified when --output_as svg/code/raw, it will output directly.", Required: false}, {Name: "overwrite", Desc: "overwrite existing file if it exists", Required: false, Type: "bool"}, }, HasFormat: true, Validate: func(ctx context.Context, runtime *common.RuntimeContext) error { token := runtime.Str("whiteboard-token") if err := common.RejectDangerousCharsTyped("--whiteboard-token", token); err != nil { return err } out := runtime.Str("output") if out != "" { if _, err := runtime.ResolveSavePath(out); err != nil { return errs.NewValidationError(errs.SubtypeInvalidArgument, "invalid output path: %s", err).WithParam("--output").WithCause(err) } } if out == "" && runtime.Str("output_as") == WhiteboardQueryAsImage { return errs.NewValidationError(errs.SubtypeInvalidArgument, "need a output directory to query whiteboard as image").WithParam("--output") } as := runtime.Str("output_as") if as != WhiteboardQueryAsImage && as != WhiteboardQueryAsSvg && as != WhiteboardQueryAsCode && as != WhiteboardQueryAsRaw { return errs.NewValidationError(errs.SubtypeInvalidArgument, "--output_as flag must be one of: image | svg | code | raw").WithParam("--output_as") } return nil }, DryRun: func(ctx context.Context, runtime *common.RuntimeContext) *common.DryRunAPI { as := runtime.Str("output_as") token := runtime.Str("whiteboard-token") switch as { case WhiteboardQueryAsImage: return common.NewDryRunAPI(). GET(fmt.Sprintf("/open-apis/board/v1/whiteboards/%s/download_as_image", common.MaskToken(url.PathEscape(token)))). Desc("Export preview image of given whiteboard") case WhiteboardQueryAsCode: return common.NewDryRunAPI(). GET(fmt.Sprintf("/open-apis/board/v1/whiteboards/%s/nodes", common.MaskToken(url.PathEscape(token)))). Desc("Extract Mermaid/Plantuml code from given whiteboard") case WhiteboardQueryAsRaw: return common.NewDryRunAPI(). GET(fmt.Sprintf("/open-apis/board/v1/whiteboards/%s/nodes", common.MaskToken(url.PathEscape(token)))). Desc("Extract raw nodes structure from given whiteboard") case WhiteboardQueryAsSvg: return common.NewDryRunAPI(). POST(fmt.Sprintf("/open-apis/board/v1/whiteboards/%s/export", common.MaskToken(url.PathEscape(token)))). Body(map[string]string{"export_type": "svg"}). Desc("Export SVG of given whiteboard") default: return common.NewDryRunAPI().Desc("invalid --output_as flag, must be one of: image | svg | code | raw") } }, Execute: func(ctx context.Context, runtime *common.RuntimeContext) error { token := runtime.Str("whiteboard-token") outDir := runtime.Str("output") as := runtime.Str("output_as") switch as { case WhiteboardQueryAsImage: return exportWhiteboardPreview(ctx, runtime, token, outDir) case WhiteboardQueryAsSvg: return exportWhiteboardSvg(runtime, token, outDir) case WhiteboardQueryAsCode: return exportWhiteboardCode(runtime, token, outDir) case WhiteboardQueryAsRaw: return exportWhiteboardRaw(runtime, token, outDir) default: return errs.NewValidationError(errs.SubtypeInvalidArgument, "--output_as flag must be one of: image | svg | code | raw").WithParam("--output_as") } }, }
WhiteboardQuery registers the `whiteboard +query` shortcut.
var WhiteboardUpdate = common.Shortcut{ Service: "whiteboard", Command: "+update", Description: WhiteboardUpdateDescription, Risk: "write", Scopes: wbUpdateScopes, AuthTypes: wbUpdateAuthTypes, Flags: wbUpdateFlags, HasFormat: false, Validate: wbUpdateValidate, DryRun: wbUpdateDryRun, Execute: wbUpdateExecute, }
WhiteboardUpdate registers the `whiteboard +update` shortcut.
var WhiteboardUpdateOld = common.Shortcut{ Service: "docs", Command: "+whiteboard-update", Description: WhiteboardUpdateDescription, Risk: "write", Scopes: wbUpdateScopes, AuthTypes: wbUpdateAuthTypes, Flags: wbUpdateFlags, HasFormat: false, Validate: wbUpdateValidate, DryRun: wbUpdateDryRun, Execute: wbUpdateExecute, }
WhiteboardUpdateOld 向前兼容历史版本 Doc 域下的更新命令
Functions ¶
Types ¶
type SyntaxType ¶ added in v1.0.8
type SyntaxType int
SyntaxType identifies the diagram syntax extracted from whiteboard code blocks.
const ( // SyntaxTypePlantUML marks PlantUML code blocks. SyntaxTypePlantUML SyntaxType = 1 // SyntaxTypeMermaid marks Mermaid code blocks. SyntaxTypeMermaid SyntaxType = 2 )
func (SyntaxType) ExtensionName ¶ added in v1.0.8
func (s SyntaxType) ExtensionName() string
ExtensionName returns the default file extension for the syntax type.
func (SyntaxType) IsValid ¶ added in v1.0.8
func (s SyntaxType) IsValid() bool
IsValid reports whether the syntax type is one of the supported whiteboard code syntaxes.
func (SyntaxType) String ¶ added in v1.0.8
func (s SyntaxType) String() string
String returns the CLI-facing name for the syntax type.
type WbCliOutput ¶
type WbCliOutput struct {
Code int `json:"code"`
Data WbCliOutputData
RawNodes []interface{} `json:"nodes"` // 从 whiteboard-cli -t openapi 输出的原始请求格式
}
type WbCliOutputData ¶
type WbCliOutputData struct {
To string `json:"to"`
Result struct {
Nodes []interface{} `json:"nodes"`
} `json:"result"`
}