Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion shortcuts/base/record_export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ func TestRecordListNDJSONOutputInfersFormatAndNormalizesValues(t *testing.T) {
if tags, ok := rows[0]["Tags"].([]any); !ok || len(tags) != 0 {
t.Fatalf("empty Tags = %#v", rows[0]["Tags"])
}
if got := rows[0]["When"]; got != "2026-08-04T12:30:00+08:00" {
if got := rows[0]["When"]; got != "2026-08-04 12:30:00" {
t.Fatalf("When = %#v", got)
}
if rows[1]["Name"] != nil {
Expand Down
4 changes: 2 additions & 2 deletions shortcuts/base/recordexport/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

The NDJSON exporter validates matrix dimensions and preserves column alignment.
Known Base v3 field types use their declared cell shape: array fields normalize
null to `[]`, checkboxes normalize null to `false`, and timestamps normalize to
RFC3339. Buttons have no record value and export as null with physical type `null`.
null to `[]`, checkboxes normalize null to `false`, and timestamp strings pass
through unchanged. Buttons have no record value and export as null with physical type `null`.

Unknown field types export with manifest `field_type: "not_support"` and
`physical_type: "json"`. Their decoded JSON values pass through without cell
Expand Down
23 changes: 2 additions & 21 deletions shortcuts/base/recordexport/dataset.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"fmt"
"reflect"
"strings"
"time"
)

const RecordIDColumnName = "record_id"
Expand Down Expand Up @@ -224,7 +223,7 @@ func ParseMatrix(data map[string]any) (Page, error) {
values := make([]any, 1, len(exportColumns))
values[0] = recordIDs[rowIndex]
for _, sourceIndex := range exportSourceIndexes {
value, err := normalizeCell(sourceColumns[sourceIndex], row[sourceIndex], timezone)
value, err := normalizeCell(sourceColumns[sourceIndex], row[sourceIndex])
if err != nil {
return Page{}, &MatrixError{Reason: fmt.Sprintf(
"row %d column %q: %v", rowIndex+1, sourceColumns[sourceIndex].Name, err,
Expand Down Expand Up @@ -291,7 +290,7 @@ func (d *Dataset) AppendPage(page Page) error {
return nil
}

func normalizeCell(column Column, value any, timezone string) (any, error) {
func normalizeCell(column Column, value any) (any, error) {
spec, ok := specForFieldType(column.FieldType)
if !ok || spec.kind == KindJSON {
return value, nil
Expand Down Expand Up @@ -332,9 +331,6 @@ func normalizeCell(column Column, value any, timezone string) (any, error) {
if !ok {
return nil, newDetailErrorf("expected string, got %T", value)
}
if column.FieldType == "datetime" || column.FieldType == "created_at" || column.FieldType == "updated_at" {
return normalizeDateTime(text, timezone)
}
return text, nil
case KindNumber:
switch value.(type) {
Expand All @@ -358,21 +354,6 @@ func normalizeCell(column Column, value any, timezone string) (any, error) {
}
}

func normalizeDateTime(value, timezone string) (string, error) {
if _, err := time.Parse(time.RFC3339Nano, value); err == nil {
return value, nil
}
location, err := time.LoadLocation(timezone)
if err != nil {
return "", wrapDetailErrorf(err, "invalid timezone %q", timezone)
}
parsed, err := time.ParseInLocation("2006-01-02 15:04:05", value, location)
if err != nil {
return "", newDetailErrorf("expected YYYY-MM-DD HH:mm:ss or RFC3339, got %q", value)
}
return parsed.Format(time.RFC3339), nil
}

func stringList(raw any, name string) ([]string, error) {
items, ok := raw.([]any)
if !ok {
Expand Down
13 changes: 1 addition & 12 deletions shortcuts/base/recordexport/dataset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ func TestParseMatrixNormalizesTypedRows(t *testing.T) {
if owners, ok := first[3].([]any); !ok || len(owners) != 0 {
t.Fatalf("empty Owner = %#v, want []", first[3])
}
if got := first[4]; got != "2026-08-04T12:30:00+08:00" {
if got := first[4]; got != "2026-08-04 12:30:00" {
t.Fatalf("Due = %#v", got)
}
if got := first[6]; got != false {
Expand Down Expand Up @@ -226,17 +226,6 @@ func TestParseMatrixNormalizesTypedRows(t *testing.T) {
}
}

func TestNormalizeDateTimePreservesUpstreamOffset(t *testing.T) {
value := "2026-11-01T01:30:00.123456-04:00"
got, err := normalizeDateTime(value, "America/New_York")
if err != nil {
t.Fatalf("normalizeDateTime() error = %v", err)
}
if got != value {
t.Fatalf("normalizeDateTime() = %q, want unchanged %q", got, value)
}
}

func TestManifestDeclaresKnownObjectStructsWithoutRewritingRows(t *testing.T) {
page, err := ParseMatrix(map[string]any{
"timezone": "UTC",
Expand Down
Loading