Add convenience result builder APIs and fix critical bugs#1
Merged
Conversation
Implements a result builder-based API for creating Slack messages with a more declarative and ergonomic syntax. Changes: - Add MessageBuilder result builder for block construction - Add convenience functions for all block types (Section, Divider, Header, Image, Context, Actions, Input, Call) - Add Message initializer supporting builder syntax with all Message options - Add tests for builder API including conditional blocks and all options - Update README with builder API examples This maintains full backward compatibility while providing a cleaner API for common use cases.
- Add result builders for ActionsBlock, ContextBlock, and SectionBlock fields - Add result builders for StaticSelectElement, MultiStaticSelectElement, OverflowElement, and OptionGroup - Add Field helper enum for cleaner Section fields API - Update README and all tests to use new builder syntax - Add comprehensive integration test suite with documentation - Configure integration tests to use SLACK_TEST_WEBHOOK_URL environment variable All builders support conditionals, loops, and optional elements for cleaner, more expressive message construction.
- Fix rate limit handling by checking 429 before isSuccess - Fix InputBlock dispatch_action coding key (was dispatch_action_config) - Fix InputBlock element decoding using superDecoder - Fix DatePickerElement initialDate to String (YYYY-MM-DD format) - Fix TextContextElement to support configurable type field - Remove unused decoder from URLSessionNetworkClient - Add formatDate helper to DatePickerElement for proper date formatting - Add markdown static helper to TextContextElement
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a7eb8abd97
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Set blocks to nil when builder produces empty array to avoid Slack API rejection
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds comprehensive result builder syntax for Slack Block Kit components and fixes several critical bugs identified in code review.
New Features
Result Builder APIs
Added
@resultBuildersupport for cleaner, more Swift-like construction of Slack blocks:Actions { ButtonElement(...) }instead ofActions([...])Context { TextContextElement(...) }instead ofContext([...])Section(fields: Fields { Field.markdown("...") })StaticSelectElement(options: Options { Option(...) })OverflowElement(options: Options { ... })OptionGroup(options: Options { ... })Supports conditional statements (
if,switch) and loops (for,while) within builders.Convenience Helpers
Field.markdown()/Field.plainText()for section fieldsTextContextElement.markdown()for markdown context elementsDatePickerElement.formatDate()for YYYY-MM-DD date formattingIntegration Tests
SLACK_TEST_WEBHOOK_URLenvironment variable for configurationBug Fixes
isSuccess)dispatch_actioncoding key (was incorrectlydispatch_action_config)superDecoder()for nested typesinitialDatefromInttoString(YYYY-MM-DD format)typefield for proper markdown/plain_text supportdecoderpropertyTest Results
All 88 tests pass.
API Compatibility
All changes verified against official Slack Block Kit API.