Documentation
¶
Overview ¶
Package aitableprotocol contains small, stable validations shared by the native AI Table commands and their shortcut adapters.
Index ¶
- Constants
- func BindReferences(value any, resources map[string]map[string]any) (any, error)
- func DatasourceSourceConfig(payload map[string]any) (string, error)
- func ExpandChartTemplate(template, parameters map[string]any) (map[string]any, error)
- func FieldCapabilityReadError(product, tool string, body map[string]any) error
- func FieldGroupMutationError(product, tool string, body map[string]any) error
- func IsSQLSheetKeyOperation(product, tool string) bool
- func ParseJSONC(raw string) (map[string]any, error)
- func ParseRecordFilters(raw string) (map[string]any, error)
- func ProjectChartTemplates(raw string, types []string) (map[string]any, error)
- func ProjectStructuredChartTemplates(value any, types []string) (map[string]any, error)
- func ResolveDashboardRootColumns(payload map[string]any, expectedBaseID, expectedDashboardID string, ...) (int, error)
- func SQLSheetKeyCallError(tool string, err error) error
- func SQLSheetKeyFailure(tool, code string) error
- func SQLSheetKeyProfileError() error
- func SQLSheetKeyResponseError(tool string, body map[string]any, isError bool) error
- func UTF16Length(value string) int
- func ValidateClientToken(value string) error
- func ValidateDashboardPersistentMetadata(flag string, value map[string]any) error
- func ValidateFieldName(value string) error
- func ValidateRootChartLayout(layout map[string]any, totalColumns int) error
- type LayoutIssue
- type LayoutRegion
- type LayoutRegionResult
Constants ¶
const ( DashboardGridColumnsV1 = 12 DashboardGridColumnsV2 = 48 RootResponsiveLayoutParent = "root-responsive-layout" )
const MaxFieldNameUTF16Length = 150
const RecordFilterOperators = "" /* 133-byte string literal not displayed */
const RecordFiltersHelp = `记录筛选 JSON:{"operator":"and|or","operands":[{"operator":"gt","operands":["<fieldId>",5]}]};子条件也支持 {"fieldId":"<fieldId>","operator":"gt","value":5}。操作符:` + RecordFilterOperators + `;exist/un_exist 只传 fieldId;日期使用日期字符串或整数毫秒数,不接受 View relative/exact Scheme`
Variables ¶
This section is empty.
Functions ¶
func BindReferences ¶ added in v1.0.66
BindReferences substitutes only an entire {"$ref":"logical.property"} object, including nested object properties. Unresolved or ambiguous references stop execution; strings are literal.
func DatasourceSourceConfig ¶
DatasourceSourceConfig reads the reviewed get_datasource_config envelope. Keep the original JSON string: decoding and re-encoding an opaque stored config could lose number precision or fields unknown to this CLI version.
func ExpandChartTemplate ¶ added in v1.0.66
ExpandChartTemplate copies a complete template then applies typed parameters. Nested objects merge, arrays replace, and chartType cannot change identity.
func FieldCapabilityReadError ¶ added in v1.0.66
FieldCapabilityReadError preserves the MCP read receipt at both the runner and helper boundaries. Scope is explicit: neither writes nor other products inherit retry advice from a similarly shaped error envelope.
func FieldGroupMutationError ¶ added in v1.0.66
FieldGroupMutationError projects only reviewed stage codes. Retry guidance requires both a known pre-submission stage and an explicit boolean hint; neither raw diagnostics nor unknown outcomes authorize another write.
func IsSQLSheetKeyOperation ¶ added in v1.0.63
IsSQLSheetKeyOperation identifies credential-management calls by product and tool.
func ParseJSONC ¶ added in v1.0.66
ParseJSONC removes comments outside strings and trailing commas. It does not repair invalid JSON or change URLs, escaped quotes or comment-like text.
func ParseRecordFilters ¶ added in v1.0.64
ParseRecordFilters validates both public spellings before constructing the wire filter. An invalid selector must never widen a bulk write.
func ProjectChartTemplates ¶ added in v1.0.66
ProjectChartTemplates selects exact published chart types; unknown types fail before a writer sees a partially generated configuration.
func ProjectStructuredChartTemplates ¶ added in v1.0.66
ProjectStructuredChartTemplates shares the typed-response projection used by native and composite callers. Both accept only the same validated templates.
func ResolveDashboardRootColumns ¶
func ResolveDashboardRootColumns( payload map[string]any, expectedBaseID, expectedDashboardID string, isAppMode bool, ) (int, error)
ResolveDashboardRootColumns selects the root Dashboard grid using the public MCP protocol. The read response must identify the requested Base/Dashboard before either application-mode context or stored metadata can select a grid. Ordinary Dashboards require the original schemaVersion JSON type to be verified so a numeric 2 cannot be confused with the legacy string "2".
func SQLSheetKeyCallError ¶ added in v1.0.63
SQLSheetKeyCallError preserves known local failures and safe business codes.
func SQLSheetKeyFailure ¶ added in v1.0.63
SQLSheetKeyFailure projects known error codes to messages safe for output and audit.
func SQLSheetKeyProfileError ¶ added in v1.0.63
func SQLSheetKeyProfileError() error
SQLSheetKeyProfileError reports the single-identity command contract.
func SQLSheetKeyResponseError ¶ added in v1.0.63
SQLSheetKeyResponseError classifies the business envelope before runtime audit is emitted. Successful gateway responses may represent an absent business error as null or {}.
func UTF16Length ¶
UTF16Length matches Java String.length and the Notable Core protocol.
func ValidateClientToken ¶
ValidateClientToken accepts the UUID v4 form used by idempotent record creates.
func ValidateDashboardPersistentMetadata ¶
ValidateDashboardPersistentMetadata rejects read-only protocol evidence from Dashboard/Chart write objects. isAppMode belongs to caller context and schemaVersion belongs to storage metadata; neither may be persisted by CLI adapters or shortcuts.
func ValidateFieldName ¶
ValidateFieldName applies the public AI Table field-name contract.
func ValidateRootChartLayout ¶
ValidateRootChartLayout validates the writable x/y/w/h geometry against a trusted root grid width. Child containers and Tabs have independent column systems that the public Dashboard response does not expose, so they fail closed instead of inheriting the root 12/48-column rule.
Types ¶
type LayoutIssue ¶ added in v1.0.66
type LayoutIssue struct {
ChartID string `json:"chartId"`
OtherID string `json:"otherId,omitempty"`
Code string `json:"code"`
Message string `json:"message"`
}
func CompareRootLayout ¶ added in v1.0.66
func CompareRootLayout(actual, expected []map[string]any, columns int) ([]LayoutIssue, error)
CompareRootLayout compares the complete declared design by ID and geometry. Intended overlaps may match a design even when the separate overlap check fails.
func DiagnoseRootLayout ¶ added in v1.0.66
func DiagnoseRootLayout(items []map[string]any, columns int) []LayoutIssue
DiagnoseRootLayout checks geometry and declared minW/minH in the current snapshot. It never claims component readability or guesses child grid widths.
type LayoutRegion ¶ added in v1.0.66
type LayoutRegion struct {
ID string `json:"id"`
X int `json:"x"`
Y int `json:"y"`
W int `json:"w"`
H int `json:"h"`
ChartIDs []string `json:"chartIds,omitempty"`
}
LayoutRegion requires the union of the selected cards to cover this rectangle. Empty ChartIDs selects all cards. Coordinates always use the root grid.
type LayoutRegionResult ¶ added in v1.0.66
type LayoutRegionResult struct {
ID string `json:"id"`
Covered bool `json:"covered"`
UncoveredColumns []int `json:"uncoveredColumns"`
}
func CheckLayoutRegions ¶ added in v1.0.66
func CheckLayoutRegions(items []map[string]any, regions []LayoutRegion, columns int) ([]LayoutRegionResult, error)
CheckLayoutRegions verifies coverage by interval union in each grid column. It never sums overlapping areas, multiplies unbounded heights, or treats a region's bounding box as proof of coverage. Only valid root cards contribute.