feat(approval): support approval event consumption#1923
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (13)
🚧 Files skipped from review as they are similar to previous changes (10)
📝 WalkthroughWalkthroughAdds two Approval status-change event keys with flattened schemas, subscription pre-registration, payload processing, global registration, comprehensive tests, event-consumption documentation, and updates to Approval command references. ChangesApproval status-change events
Approval command documentation
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant Consumer
participant approvalSubscriptionPreConsume
participant ApprovalAPI
participant EventProcessor
Consumer->>approvalSubscriptionPreConsume: provide subscription_type
approvalSubscriptionPreConsume->>ApprovalAPI: POST subscription registrations
ApprovalAPI-->>Consumer: deliver Approval status-change event
Consumer->>EventProcessor: pass raw event payload
EventProcessor-->>Consumer: return flattened JSON output
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🚀 PR Preview Install Guide🧰 CLI updatenpm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@4c6aa423b57bc9818bb2564f2591a44656c99c74🧩 Skill updatenpx skills add larksuite/cli#feat/approval-event-consume -y -g |
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@cmd/event/schema_test.go`:
- Line 172: Before the cmdutil.TestFactory call in the relevant schema test, set
LARKSUITE_CLI_CONFIG_DIR to t.TempDir() so the test uses an isolated temporary
CLI configuration directory.
In `@events/approval/preconsume.go`:
- Line 15: Update approvalSubscriptionPreConsume to accept a configuration
struct with named fields for eventType and subscribePath instead of two string
parameters, then update its callers to initialize the fields explicitly and
preserve the existing request behavior.
- Around line 27-31: Update the subscription registration loop in the preconsume
flow to handle partial success when a later CallAPI request fails: either
compensate already-created subscriptions using an idempotent cleanup path, or
return a typed, structured error containing the successful and failed
subscription types plus actionable retry guidance. Preserve successful
registrations, avoid discarding write outcomes, and add coverage for failure on
the second relation.
In `@events/approval/register_test.go`:
- Around line 150-175: Replace loose map-based schema parsing with typed
projection structs in events/approval/register_test.go lines 150-175, covering
formats, enums, and nested user properties; update assertEnumContains in
events/approval/register_test.go lines 181-191 to accept []string. In
cmd/event/schema_test.go lines 178-210, decode command output into typed structs
for params, scopes, auth types, and resolved schema properties, with no new
map[string]interface{} parsing.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: b737246e-257b-44d0-9477-448d5e4e49e6
📒 Files selected for processing (13)
cmd/event/list_test.gocmd/event/schema_test.goevents/approval/preconsume.goevents/approval/register.goevents/approval/register_test.goevents/approval/types.goevents/register.goskills/lark-approval/references/lark-approval-initiate.mdskills/lark-approval/references/lark-approval-instances-initiated.mdskills/lark-approval/references/lark-approval-tasks-query.mdskills/lark-approval/references/lark-approval-tasks-rollback.mdskills/lark-event/SKILL.mdskills/lark-event/references/lark-event-approval.md
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1923 +/- ##
==========================================
+ Coverage 74.96% 74.99% +0.03%
==========================================
Files 892 894 +2
Lines 94058 94275 +217
==========================================
+ Hits 70506 70705 +199
- Misses 18139 18149 +10
- Partials 5413 5421 +8 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
17b63dd to
7d5e628
Compare
Register approval.instance.status_changed_v4 and approval.task.status_changed_v4 with custom flattened schemas and user-auth pre-consume subscription setup. Handle approval subscription_type as optional multi-value pre-registration metadata: omitted values register both involved and managed relations, explicit values can be single, comma-separated, or JSON array, and consumers do not unsubscribe on exit. Report partial approval subscription registration failures with registered and failed relation context while preserving the underlying typed error classification. Document approval event output fields and subscription semantics, and refresh approval skill references from API metadata.
7d5e628 to
4c6aa42
Compare
Summary
Add support for consuming Approval instance and task status change events through
lark-cli event consume, including user-auth pre-consume subscription setup, flattened output schemas, and agent-facing documentation.Changes
approval.instance.status_changed_v4andapproval.task.status_changed_v4EventKeys with custom flattened schemas, required user auth scopes, and console event metadata.subscription_typevalues.lark-eventskill references.Test Plan
go test ./cmd/event ./events/approvallark-cli event schema/lark-cli event listflow works as expected viago run . event schema approval.instance.status_changed_v4 --json,go run . event schema approval.task.status_changed_v4 --json, andgo run . event list --json.Related Issues
Summary by CodeRabbit
New Features
approval.instance.status_changed_v4,approval.task.status_changed_v4) with flattened JSON output.subscription_typepre-registration for approval subscriptions, supporting omitted/default, comma-separated, and JSON-array inputs, with multi-relation registration behavior.Documentation
subscription_typeusage formats.