Repository navigation
Conversation
Add the new `data_table` Block Kit layout block to the model: DataTableBlock plus its cell model (DataTableCell interface with RawTextDataTableCell, RawNumberDataTableCell, and RichTextBlock for rich_text cells), the GsonDataTableCellFactory deserializer, factory registration, and a `dataTable` builder DSL entry. Ref: https://docs.slack.dev/reference/block-kit/blocks/data-table-block Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1613 +/- ##
============================================
+ Coverage 73.91% 74.01% +0.10%
- Complexity 4797 4814 +17
============================================
Files 489 490 +1
Lines 14959 14987 +28
Branches 1562 1563 +1
============================================
+ Hits 11057 11093 +36
+ Misses 2977 2974 -3
+ Partials 925 920 -5
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
…table # Conflicts: # slack-api-model/src/main/java/com/slack/api/util/json/GsonLayoutBlockFactory.java # slack-api-model/src/test/java/test_locally/api/model/block/BlockKitTest.java
Mirror the reviewed node SDK PR (slackapi/node-slack-sdk#2638): - Correct the max row count: the model previously stated up to 100 data rows (101 including header); the reference documents 201 rows (200 data rows plus header). The 100 cap was page_size, not the row maximum. Drop the stale count from the javadoc rather than restate it. - Align each field's javadoc with the data-table-block reference Fields table verbatim (rows, caption, page_size, row_header_column_index). - Trim RawTextDataTableCell / RawNumberDataTableCell to the terse, docs-minimal descriptions (drop the invented sorting/formatting tails); document value and text per the docs. Ref: https://docs.slack.dev/reference/block-kit/blocks/data-table-block Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Blocks.java keeps the recently-added blocks (Alert, Card, Carousel, Container, TaskCard) in a cluster at the end rather than slotting them alphabetically into the original core entries. Move the dataTable(...) builder into that cluster (after container, before taskCard) so a net-new block sits with its peers instead of splitting the old core from the new group. Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
…ta_table The data_table cells (raw_text / raw_number / rich_text) are the same cell model the table block uses. Rather than ship a parallel DataTableCell family, adopt the shared TableCell interface and its RawTextTableCell / RawNumberTableCell implementations in com.slack.api.model.block.composition, deserialized by a single GsonTableCellFactory: - Remove DataTableCell, RawTextDataTableCell, RawNumberDataTableCell, and GsonDataTableCellFactory. - Add TableCell, RawTextTableCell, RawNumberTableCell (in ...block.composition) and GsonTableCellFactory (in ...util.json). - DataTableBlock.rows is now List<List<TableCell>>; RichTextBlock implements TableCell; the client and model-test GsonFactory register TableCell -> GsonTableCellFactory. This is the same cell model the sibling table-block PR (#1611) introduces, placed in the same package with identical definitions, so whichever of the two lands second drops the now-duplicate files in a trivial merge. Mirrors how node (@slack/types composition objects) and python (slack_sdk basic_components) also share one cell model across both blocks. Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
…bject Rename the concrete TableCell implementations from RawTextTableCell / RawNumberTableCell to RawTextObject / RawNumberObject, matching the composition-object naming used by the other SDKs (python RawTextObject / RawNumberObject) and this repo's own ...Object grammar (PlainTextObject, MarkdownTextObject, OptionObject). The shared TableCell interface is the supertype the list is parameterized on (Java has no union types, so List<List<TableCell>> is how the raw_text | raw_number | rich_text union is expressed); only the implementation names change. Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
…import - GsonLayoutBlockFactory: move the DataTableBlock case into alphabetical order (between ContextBlock and DividerBlock) instead of after SectionBlock. - RichTextBlock: import com.slack.api.model.block.composition.TableCell and use the simple name in the implements clause rather than the fully qualified type inline. Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
The raw_number schema marks text as required (required: [type, value, text], text minLength 1) — the javadoc wrongly called it optional. Match the schema: text carries the display representation of the value and must be at least one character long. Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Keep the text-is-display + min-length note, drop the "(for example a formatted string)" aside. Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Restructure RawNumberObject and RawTextObject to per-field javadoc, mirroring the node @slack/types descriptions and matching this repo's own per-field convention (OptionObject, ConfirmationDialogObject): - class: "Defines an object containing a numeric value." / "...some text." - value: "The numeric value." - text (number): "The text used to display the value. The minimum length is 1 character." - text (text): "The text for the block. The minimum length is 1 character." Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Add BlockCompositions.rawText(...) and rawNumber(...) factory helpers for the raw table cell objects, mirroring the plainText / markdownText DSL (configurator overload plus a convenience overload). Gives callers an ergonomic way to build data_table / table cells without the raw builder. Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
…Text Use the BlockCompositions.rawText(...) helper for the raw_text cells instead of RawTextObject.builder(), per the block-kit AGENTS.md guidance to build composition objects through BlockCompositions.* rather than raw builders. Depends on the rawText/rawNumber helpers added in slackapi/java-slack-sdk#1613. Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
RawNumberObject.value is a (nullable) Double; the two-arg rawNumber convenience overload took a primitive double, narrowing the model's type. Use Double so the helper mirrors the field exactly. Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
zimeg
left a comment
There was a problem hiding this comment.
☕ Ideas to share where included I callout a pattern I'm uncertain of around rawText and rawNumber!
There was a problem hiding this comment.
🦠 note: I have some confidence this is a consistent shared type but it's not clear if it's meant to be stable because it's not in reference. Hoping to add this here and #1611 for shared implementation!
| // RawNumberObject | ||
|
|
||
| public static RawNumberObject rawNumber(ModelConfigurator<RawNumberObject.RawNumberObjectBuilder> configurator) { | ||
| return configurator.configure(RawNumberObject.builder()).build(); | ||
| } | ||
|
|
||
| public static RawNumberObject rawNumber(Double value, String text) { | ||
| return RawNumberObject.builder().value(value).text(text).build(); | ||
| } |
There was a problem hiding this comment.
👁️🗨️ note: These introduce helper functions to BlockComposition that aren't documented but IMHO are helpful for:
- RawTextObject.builder().text("Name").build()
+ BlockCompositions.rawText("Name"),
zimeg
left a comment
There was a problem hiding this comment.
🦐 Solid but some notes and questions before requesting actual review.
| /** | ||
| * A raw_text or raw_number cell. | ||
| */ | ||
| private TableCell fallback; |
There was a problem hiding this comment.
🔭 note: This might be generic to other table cells but we leave validation to the API here.
Save the table block @see links for the table block PR and move the data_table tests to their alphabetical position before task_card. Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com> Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com> Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com> Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com> Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com> Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
srtaalej
left a comment
There was a problem hiding this comment.
Unit tests on this branch: BlockKitTest passes 63/63, including parseDataTableBlock, buildDataTableBlock, and both unknown-cell cases ✅ The model, the GsonTableCellFactory registration in both GsonFactorys, and the builder helpers look good to me.\n\nTwo things before I approve:\n- 🔀 It conflicts with main in Blocks.java. PlanBlock landed in the same spot as dataTable(...), so it should be a simple keep-both resolution.\n- 🧪 I haven't run the live chat.postMessage + conversations.history steps yet because my test bot token is inactive. I'll run those and approve once the rebase is in, unless you've already confirmed it renders with pagination.
…table Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
|
🔀 @srtaalej Thanks for the careful review! I merged 🧪 I ran the live check too. 👁️🗨️ |
WilliamBergamin
left a comment
There was a problem hiding this comment.
🧩 Thanks @zimeg! Sharing one TableCell model across table and data_table keeps this lined up with node and python, and the parse plus round-trip tests read really nicely.
One blocking comment around unknown cell types (the spec's action_cell trips it), the rest are take it or leave it 🙏
Co-authored-by: WilliamBergamin <25348381+WilliamBergamin@users.noreply.github.com> Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Co-authored-by: WilliamBergamin <25348381+WilliamBergamin@users.noreply.github.com> Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
WilliamBergamin
left a comment
There was a problem hiding this comment.
🧩 Thanks @zimeg, the test now builds cells with rawText and rawNumber and the factory Javadoc covers both table blocks, nice.
One blocking comment on the type of the action cell's fallback, since it can't be narrowed after release. The rest are optional 🙏
| /** | ||
| * A raw_text or raw_number cell. | ||
| */ | ||
| private TableCell fallback; |
There was a problem hiding this comment.
🚦 issue (blocking): The docs only allow a raw_text or raw_number fallback, but TableCell also accepts an action cell or rich text. Narrowing this type after release changes the public getter and setter, a major bump, so could we add a small interface (say ActionCellFallback) that only RawTextObject and RawNumberObject implement, and type fallback with it now?
|
|
||
| // ActionCellObject | ||
|
|
||
| public static ActionCellObject actionCell(ModelConfigurator<ActionCellObject.ActionCellObjectBuilder> configurator) { |
There was a problem hiding this comment.
🧪 suggestion (non-blocking): Neither actionCell overload is called by a test yet. Building the action cell in buildDataTableBlock with actionCell(c -> c.element(...).fallback(rawText("Open"))) would cover it.
| /** | ||
| * The numeric value. | ||
| */ |
There was a problem hiding this comment.
🪓 suggestion (non-blocking): Some field Javadoc here and in ActionCellObject and DataTableBlock only restates the field name and can drift from the docs page. Could we drop those lines and let the class @see link carry it?
| /** | |
| * The numeric value. | |
| */ |
| if (failOnUnknownProperties) { | ||
| throw new JsonParseException("Unknown table cell type: " + typeName); | ||
| } else { | ||
| return UnknownTableCell.class; |
There was a problem hiding this comment.
💯 praise: Falling back to UnknownTableCell unless failOnUnknownProperties is set matches GsonTextObjectFactory, so lenient parses stay safe when the next cell type ships.
This pull request adds the
data_tablelayout block to the Java SDK model.DataTableBlock(data_table) withrows,caption,pageSize,rowHeaderColumnIndex, andblockId.TableCellinterface incom.slack.api.model.block.composition, sorowsisList<List<TableCell>>.RawTextObject(raw_text) andRawNumberObject(raw_number) composition objects that implementTableCell, matching python'sRawTextObject/RawNumberObject.ActionCellObject(action_cell) implementsTableCellwith aButtonElementelementand an optionalfallback(raw_textorraw_number) for clients without action cell support. Action cells only work indata_table, nottable.RichTextBlock(rich_text) now also implementsTableCell.GsonTableCellFactorydeserializes cells bytype, and unknown cell types parse asUnknownTableCellunlessfailOnUnknownPropertiesis set, matchingUnknownBlockandUnknownTextObject. It's registered forTableCellin the clientGsonFactoryand the model testGsonFactory.DataTableBlockis registered inGsonLayoutBlockFactory.Blocks.dataTable(...), plusBlockCompositions.actionCell(...),BlockCompositions.rawText(...)andBlockCompositions.rawNumber(...).BlockKitTestparses and builds adata_tablewith all four cell types, and covers unknown cell types.The
tableblock in #1611 builds on these shared cell types.Kotlin DSL support is left for a follow-up that covers every block the Kotlin extension doesn't have yet.
Testing
Post a message with a
data_tableblock usingchat.postMessage:Confirm
response.isOk()and that the table renders in the channel with the caption, a header row, and pagination.Read the message back with
conversations.historyand confirm the block parses as aDataTableBlockwithRawTextObjectandRawNumberObjectcells.🤖 Generated with Claude Code