跳转到内容
EN

引入组件库

POST /canvas/v1/canvases/{canvas_id}/imports

Make a published library’s components usable in this canvas under an alias, or move an existing alias to another library version. Supply this canvas’s canvas_id and the library’s canvas id from libraries.list; the library must have been published at least once, and a library cannot itself import another library. After importing, reference a component as alias:component_id (for example ref ui:btn in a script) and a library variable as $alias:name; library nodes are read-only here. Moving an alias to a newer version keeps every instance and its overrides. The import is one new canvas version, so restoring an earlier version also restores the library versions it used. Importing the same alias and version again changes nothing. Component libraries are available only to organizations where the canvas-libraries feature is enabled.

支持状态: supported

参数

名称位置类型必填说明
canvas_idpathstringtrueCanvas id returned by create or list, in the form cvs_ followed by 16 lowercase letters or digits; a display name is not accepted.

请求体 (application/json)

必填: true

名称类型说明
aliasstringAlias to import under, 1-32 characters, a lower-case letter then lower-case letters, digits or hyphens.
librarystringCanvas id of the library, from libraries.list; it must belong to your organization and have been published.
versionstringLibrary version to use, from library_versions; the latest when omitted.
expected_versionstringCurrent canvas version from retrieve; the import is refused with REVISION_CONFLICT if the canvas has moved on. Omission imports whatever is current.
{
"type": "object",
"required": [
"alias",
"library"
],
"properties": {
"alias": {
"type": "string",
"pattern": "^[a-z][a-z0-9-]{0,31}$",
"example": "ui",
"description": "Alias to import under, 1-32 characters, a lower-case letter then lower-case letters, digits or hyphens."
},
"library": {
"type": "string",
"pattern": "^cvs_[0-9a-z]{16}$",
"example": "cvs_0123456789abcdef",
"description": "Canvas id of the library, from libraries.list; it must belong to your organization and have been published."
},
"version": {
"type": "string",
"pattern": "^[0-9]+$",
"example": "2",
"description": "Library version to use, from library_versions; the latest when omitted."
},
"expected_version": {
"type": "string",
"pattern": "^[0-9]+$",
"example": "12",
"description": "Current canvas version from retrieve; the import is refused with REVISION_CONFLICT if the canvas has moved on. Omission imports whatever is current."
}
}
}

响应

HTTP 200

The canvas version after the import and the library version now in use.

application/json

名称 类型 说明
version string Current revision as a decimal string, incremented by one after each successful write; pass it as expected_version to guard a subsequent execute call.
alias string The alias the library is imported under.
library string The library's canvas id.
library_version string The library version now in use.
previous_library_version string | null The library version this alias used before, or null for a first import.
component_count integer Number of components the imported version offers; components removed from the library are not counted.