Skip to content

spec: ListView.exportOptions is typed as a bare array, but the only renderer reads exportOptions.formats #8010

Description

@baozhoutao

Reported from an app project (steedos-labs/os-project-titanwind-ehr#1161) on @objectstack/*@17.0.0-rc.6.

The divergence

@objectstack/spec types a list view's exportOptions as a bare array:

// packages/spec/src/ui/view.zod.ts:1438exportOptions: z.array(z.enum(['csv','xlsx','pdf','json'])).optional().describe('Available export format options'),

The only renderer of that property reads an object and looks for .formats:

// objectui/packages/plugin-grid/src/ObjectGrid.tsx:1394constdeclared=schema.exportOptions?.formats||['csv','json'];

objectui/packages/types/src/objectql.ts:785 declares the object shape
({ formats?, maxRecords?, includeHeaders?, fileNamePrefix? }) under the comment
"Aligned with @objectstack/spec ListViewSchema.exportOptions" — that comment is
false today; the two shapes have never matched.

Consequence for app projects

A project that follows the published spec type writes exportOptions: ['xlsx'].
At render time ['xlsx'].formats is undefined, so ObjectGrid falls back to
['csv', 'json'] and XLSX never appears in the export menu. Writing the object form
that Console actually reads makes the metadata fail its own @objectstack/spec type
check. There is no declaration that is both type-legal and functional, which is
what the reporting project hit.

Second defect on the same property: the dead 'pdf' member

The spec enum still admits 'pdf', but PDF export was closed NOT_PLANNED as
objectstack-ai/objectstack#1301, and ObjectGrid drops unsupported formats with only a
runtime console.warn (ObjectGrid.tsx:1403-1409). So exportOptions: ['xlsx','pdf']
type-checks, passes validate, passes tsc, and silently renders a menu without PDF —
the app author's only signal is a browser console line they may never see.

Repro

  1. Declare exportOptions: ['xlsx', 'pdf'] on any object list view (spec-legal form).
  2. Grant allowExport.
  3. Open the list's export menu → only CSV and JSON, no XLSX, no PDF, no build/validate diagnostic.

What we're asking for

  1. Pick one shape and make it the contract. Either spec adopts the object form
    Console implements (with array-form normalization for back-compat), or Console is
    fixed to read the array the spec publishes. Whichever side moves, the false
    "Aligned with @objectstack/spec" comment at objectui/packages/types/src/objectql.ts:785
    must be corrected in the same change.
  2. Resolve 'pdf'. Given objectstack#1301 is NOT_PLANNED, the spec enum should
    drop 'pdf' (a breaking-but-honest narrowing), or a declared-but-unrenderable format
    should surface as a validate-time diagnostic rather than a runtime console.warn.

Business impact at the reporting project

The customer spec (§7.7) promises "download/print supports PDF/Excel export". Both halves
are currently blocked platform-side: XLSX by the contract mismatch above, PDF by
objectstack#1301.

Related

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions