mirror of
https://github.com/larksuite/cli.git
synced 2026-09-14 18:42:53 +08:00
cb1bb1d004
* docs(base): add common filter condition examples * docs(base): restructure skill routing and guidance * docs(base): simplify identity selection guidance * docs(base): restore concise recovery contracts * docs(base): condense recovery guidance * docs(base): retain only high-value recovery guidance * docs(base): clarify full field update semantics * docs(base): prioritize common text filter examples * docs(base): deduplicate auto number update guidance * fix(base): align ndjson dry-run page size * docs(base): align permission identity guidance * test(base): align ndjson dry-run page size * docs(base): recommend dynamic select option reuse * docs(base): require SOP for record reads * docs(base): streamline record read guidance * docs(base): clarify record format guidance * docs(base): reduce hidden record flag exposure * docs(base): merge record read gate * docs(base): reduce table discovery guidance * docs(base): centralize block discovery guidance * docs(base): restore table analysis chain * docs(base): restore table resource guidance * docs(base): use resource-specific list commands * docs(base): restore folder listing command * docs(base): minimize probe stdout
39 lines
1.6 KiB
Go
39 lines
1.6 KiB
Go
// Copyright (c) 2026 Lark Technologies Pte. Ltd.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package base
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/larksuite/cli/shortcuts/common"
|
|
)
|
|
|
|
var BaseRecordUpsert = common.Shortcut{
|
|
Service: "base",
|
|
Command: "+record-upsert",
|
|
Description: "Create or update a record",
|
|
Risk: "write",
|
|
Scopes: []string{"base:record:create", "base:record:update"},
|
|
AuthTypes: authTypes(),
|
|
Flags: []common.Flag{
|
|
baseTokenFlag(true),
|
|
tableRefFlag(true),
|
|
recordRefFlag(false),
|
|
{Name: "json", Desc: `record field map JSON object, e.g. {"Name":"Alice","Status":["Todo"]}; do not wrap in fields`, Required: true},
|
|
},
|
|
Tips: append([]string{
|
|
"Happy path JSON is a top-level field map: each key is a real field name or field ID, each value is that field's CellValue.",
|
|
"Without --record-id this creates a record; with --record-id this updates that record. It does not auto-upsert by business key.",
|
|
"Before writing, use +field-list to confirm real writable fields; do not write system fields, formula, lookup, or attachment fields as normal CellValue.",
|
|
"Sub-record/child-record path: when a one-way/two-way link field represents hierarchy, create a normal record and set that link field to a parent record reference array, e.g. {\"Parent Link\":[{\"id\":\"rec_xxx\"}]}; do not look for parent_record_id or a separate child-record API.",
|
|
}, recordCellValueHappyPathTips...),
|
|
Validate: func(ctx context.Context, runtime *common.RuntimeContext) error {
|
|
return validateRecordJSON(runtime)
|
|
},
|
|
DryRun: dryRunRecordUpsert,
|
|
Execute: func(ctx context.Context, runtime *common.RuntimeContext) error {
|
|
return executeRecordUpsert(runtime)
|
|
},
|
|
}
|