feat(cli): record 写入 --typecast/--order/--field-key-type + 附件字段 URL 导入 skill 文档 (0.2.0)
This commit is contained in:
@@ -82,7 +82,32 @@ smoke "field update --options" $CLI field update "$TBL" Status --options '{"
|
||||
smoke "field delete" $CLI field delete "$TBL" Extra
|
||||
|
||||
# ---------- record ----------
|
||||
smoke "field create (attachment)" $CLI field create --table-id "$TBL" --name Files --type attachment
|
||||
smoke "record create --fields" $CLI record create --table-id "$TBL" --fields '{"Title":"r1","Status":"todo","Num":1}'
|
||||
# Attachment fields accept http(s) urls: string form needs --typecast, object
|
||||
# form works without. Downloads a real file from the local gitea; a network
|
||||
# failure degrades to a warning (feature check, not a route-shape check).
|
||||
ATT_URL='https://gitea.inkreach.cc/inkreachhub/inkreach-teable-cli/raw/branch/main/README.md'
|
||||
ATT_OUT=$($CLI record create --table-id "$TBL" --typecast --fields "{\"Title\":\"att1\",\"Files\":\"$ATT_URL\"}" --json 2>&1)
|
||||
if echo "$ATT_OUT" | grep -qE "$FAILPAT"; then
|
||||
FAIL=$((FAIL+1)); FAILED_CASES+=("record create attachment-url (typecast)")
|
||||
echo "FAIL record create attachment-url (typecast)"
|
||||
echo "$ATT_OUT" | grep -E "$FAILPAT" | head -2 | sed 's/^/ /'
|
||||
elif echo "$ATT_OUT" | grep -q '"token"'; then
|
||||
PASS=$((PASS+1)); [ "${SMOKE_VERBOSE:-0}" = 1 ] && echo "pass record create attachment-url (typecast)"
|
||||
else
|
||||
echo "warn record create attachment-url (typecast): no attachment token in response (download failed?)"
|
||||
fi
|
||||
ATT_OUT2=$($CLI record create --table-id "$TBL" --fields "{\"Title\":\"att2\",\"Files\":[{\"url\":\"$ATT_URL\",\"name\":\"readme.md\"}]}" --json 2>&1)
|
||||
if echo "$ATT_OUT2" | grep -qE "$FAILPAT"; then
|
||||
FAIL=$((FAIL+1)); FAILED_CASES+=("record create attachment-url (object)")
|
||||
echo "FAIL record create attachment-url (object)"
|
||||
echo "$ATT_OUT2" | grep -E "$FAILPAT" | head -2 | sed 's/^/ /'
|
||||
elif echo "$ATT_OUT2" | grep -q '"token"'; then
|
||||
PASS=$((PASS+1)); [ "${SMOKE_VERBOSE:-0}" = 1 ] && echo "pass record create attachment-url (object)"
|
||||
else
|
||||
echo "warn record create attachment-url (object): no attachment token in response (download failed?)"
|
||||
fi
|
||||
smoke "record create --records" $CLI record create --table-id "$TBL" --records '[{"fields":{"Title":"r2"}},{"fields":{"Title":"r3"}}]'
|
||||
REC=$($CLI record list --table-id "$TBL" --json | j "d['records'][0]['id']")
|
||||
STATUS_FLD=$($CLI field list "$TBL" --json | j "[f['id'] for f in d if f['name']=='Status'][0]")
|
||||
@@ -96,6 +121,13 @@ smoke "record get --projection" $CLI record get --table-id "$TBL" --projectio
|
||||
smoke "record get-one" $CLI record get-one "$REC" --table-id "$TBL"
|
||||
smoke "record get --record-id" $CLI record get --record-id "$REC" --table-id "$TBL"
|
||||
smoke "record update" $CLI record update --table-id "$TBL" --records "[{\"id\":\"$REC\",\"fields\":{\"Num\":42}}]"
|
||||
# --field-key-type / --order are body keys of create/updateRecordsRoSchema
|
||||
VIEW=$($CLI view list "$TBL" --json | j "d[0]['id']")
|
||||
TITLE_FLD=$($CLI field list "$TBL" --json | j "[f['id'] for f in d if f['name']=='Title'][0]")
|
||||
REC2=$($CLI record list --table-id "$TBL" --json | j "d['records'][1]['id']")
|
||||
smoke "record create --field-key-type id" $CLI record create --table-id "$TBL" --field-key-type id --fields "{\"$TITLE_FLD\":\"by-fld-id\"}"
|
||||
smoke "record create --order" $CLI record create --table-id "$TBL" --order "{\"viewId\":\"$VIEW\",\"anchorId\":\"$REC2\",\"position\":\"before\"}" --fields '{"Title":"ordered-create"}'
|
||||
smoke "record update --order" $CLI record update --table-id "$TBL" --order "{\"viewId\":\"$VIEW\",\"anchorId\":\"$REC2\",\"position\":\"after\"}" --records "[{\"id\":\"$REC\",\"fields\":{\"Num\":7}}]"
|
||||
smoke "record visible-choices" $CLI field visible-choices "$TBL" "$REC" Status
|
||||
smoke "record delete (positional)" $CLI record delete "$REC" --table-id "$TBL"
|
||||
smoke "record delete (--csv)" $CLI record delete --record-ids "$($CLI record list --table-id "$TBL" --json | j "','.join(r['id'] for r in d['records'])")" --table-id "$TBL"
|
||||
|
||||
Reference in New Issue
Block a user