feat(push): support realtime message data in batch-publish channel items#355
feat(push): support realtime message data in batch-publish channel items#355maratal wants to merge 1 commit intofix/push-publish-message-shapefrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
Adds support for including an optional realtime message payload when using push:batch-publish with channel-based batch items (routing via /messages with extras.push), aligning the message parsing semantics with prepareMessageFromInput() used elsewhere in the CLI.
Changes:
- Extend
push:batch-publishchannel items to accept an optionalmessagefield and publish it alongside the push payload viaextras.push. - Reuse
prepareMessageFromInput()to derive realtimename,data, and optionalextrasfrom the providedmessage. - Add unit tests covering string message data, message objects with
name+data, name-only objects, and absence ofmessage.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/commands/push/batch-publish.ts |
Adds parsing/merging logic for optional message in channel-routed batch items and updates CLI examples/arg description. |
test/unit/commands/push/batch-publish.test.ts |
Adds unit tests validating the new message behavior for channel batch items. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
47411f5 to
295a823
Compare
fix(push publish): parse --message as a full Ably message shape
c0ddf56 to
2761a92
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
2761a92 to
a283c67
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ab90c88 to
dc2e45a
Compare
WalkthroughThis PR extends Changes
Review Notes
|
There was a problem hiding this comment.
Review Summary
| File | Status | Issues |
|---|---|---|
src/commands/push/batch-publish.ts |
OK | — |
test/unit/commands/push/batch-publish.test.ts |
OK | — |
Implementation correctness
The this.fail() call inside the .map() callback (line 330) is the right approach. Because fail() always throws (returns never), the exception propagates out of .map() to the outer try/catch, which calls this.fail() again on the caught error. The base class handles oclif re-throws automatically — no double JSON error envelope, no double output. The test at line 166 verifies the API is never called when the guard fires, confirming the abort-before-request behavior is correct.
The JSON.stringify(entry.message) round-trip into prepareMessageFromInput is the right technique for reusing the existing utility. Since entry.message comes from JSON.parse(jsonString) (user input), circular references are impossible, and the serialization handles all types correctly: string → {data: string}, number/array/null → {data: value}, plain object → structured message.
The asymmetry between recipient items (warn + strip) and channel items (actively process) is intentional and clearly communicated to users.
Error handling
this.fail()used everywhere, nothis.error()direct calls- Component string
"pushBatchPublish"is camelCase - No
new Error(...)wrapping inthis.fail() - No manual oclif re-throw guard in the catch block
this.logWarning()used correctly for the non-fatal recipient warning
Test coverage
8 new tests cover all documented cases: string message, object with name+data, name-only (remaining fields become data), non-push extras preserved, extras.push conflict rejection, plain object as data, recipient strip+warn, and no-message baseline. All 5 required describe blocks are present (3 explicit + 2 via standard helpers). No auth flags, no --duration in unit test args.
No issues found. The feature is implemented correctly and the test suite is thorough.
dc2e45a to
4d5370b
Compare
|
Closing in favour of #358 which is based on main instead of the now-merged fix/push-publish-message-shape branch. |
Summary
Depends on #352.
"message"field whose value is published as the realtime message alongside the push notification inextras.pushprepareMessageFromInputfrommessage.ts(viaJSON.stringify) — no new utility neededmessagefield follows the same shape as--messageinpush publish(PR fix(push publish): parse --message as a full Ably message shape #352):nameanddataare extracted; if onlynameis present, remaining fields becomedataExample
[ { "channels": ["my-channel"], "payload": {"notification": {"title": "Hello", "body": "World"}}, "message": {"name": "alert", "data": "Server down"} } ]Test plan
pnpm test:unitpasses (21 tests in batch-publish, covering string message, object with name+data, object with name-only, no message)pnpm exec eslint .clean🤖 Generated with Claude Code