Skip to content

feat(audit-roles-tasks): add read-only resources (Audit Events, Roles, Tasks, OKRs, Webhook Events)#107

Open
sgerrand wants to merge 4 commits into
mainfrom
feat/audit-roles-tasks
Open

feat(audit-roles-tasks): add read-only resources (Audit Events, Roles, Tasks, OKRs, Webhook Events)#107
sgerrand wants to merge 4 commits into
mainfrom
feat/audit-roles-tasks

Conversation

@sgerrand
Copy link
Copy Markdown
Owner

@sgerrand sgerrand commented May 4, 2026

💁 Adds 7 read-only resources — useful for reporting dashboards and admin/audit tooling.

Summary

Retrieve only (no list endpoint):

  • `Humaans.AuditEvents` — `/api/audit-events`

List + retrieve (read-only):

  • `Humaans.Roles` — `/api/roles`
  • `Humaans.RoleMembers` — `/api/role-members`
  • `Humaans.RolePermissions` — `/api/role-permissions`
  • `Humaans.Tasks` — `/api/tasks`
  • `Humaans.OKRs` — `/api/okrs`
  • `Humaans.WebhookEvents` — `/api/webhook-events`

Each resource declares the supported `actions: [...]` list explicitly and includes a guard test asserting that the unsupported actions stay unexported. Module access helpers and README updated.

Test plan

  • `mix test` passes (~27 new tests)
  • `mix credo` clean
  • `mix format --check-formatted` clean

sgerrand added 4 commits May 4, 2026 17:05
Adds Humaans.AuditEvents covering /api/audit-events. The API only
exposes GET /:id (no list), so the resource declares actions [:retrieve]
explicitly and a guard test asserts the other CRUD functions are not
exported.
Adds Humaans.Roles, Humaans.RoleMembers, Humaans.RolePermissions
covering /api/roles, /api/role-members, /api/role-permissions. All
three are read-only via the API; the resources declare actions
[:list, :retrieve] explicitly and guard tests assert the write
actions are not exported.
…list/retrieve

Adds Humaans.Tasks, Humaans.OKRs, Humaans.WebhookEvents covering
/api/tasks, /api/okrs, /api/webhook-events. All three are read-only
via the API.
Copilot AI review requested due to automatic review settings May 4, 2026 16:09
@coveralls
Copy link
Copy Markdown

Coverage Report for CI Build 25329531329

Coverage decreased (-3.1%) to 96.903%

Details

  • Coverage decreased (-3.1%) from the base build.
  • Patch coverage: 7 uncovered changes across 1 file (7 of 14 lines covered, 50.0%).
  • No coverage regressions found.

Uncovered Changes

File Changed Covered %
lib/humaans.ex 7 0 0.0%

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 226
Covered Lines: 219
Line Coverage: 96.9%
Coverage Strength: 22.22 hits per line

💛 - Coveralls

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds new read-only client modules and resource structs for audit/admin/reporting endpoints in the Humaans API, plus accompanying tests and documentation updates.

Changes:

  • Introduces 7 new read-only resource modules (AuditEvents, Roles, RoleMembers, RolePermissions, Tasks, OKRs, WebhookEvents) using Humaans.Resource with restricted actions.
  • Adds new resource struct modules under Humaans.Resources.* with basic new/1 constructors and timestamp/date parsing where applicable.
  • Updates Humaans module access helpers and README to surface the new resources; adds ExUnit tests covering list/retrieve and guarding unsupported actions.

Reviewed changes

Copilot reviewed 23 out of 23 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
README.md Documents newly supported read-only resources.
lib/humaans.ex Adds convenience accessors for the new resource modules.
lib/humaans/audit_events.ex Adds retrieve-only Audit Events resource module.
lib/humaans/roles.ex Adds read-only Roles resource module (list + retrieve).
lib/humaans/role_members.ex Adds read-only Role Members resource module (list + retrieve).
lib/humaans/role_permissions.ex Adds read-only Role Permissions resource module (list + retrieve).
lib/humaans/tasks.ex Adds read-only Tasks resource module (list + retrieve).
lib/humaans/okrs.ex Adds read-only OKRs resource module (list + retrieve).
lib/humaans/webhook_events.ex Adds read-only Webhook Events resource module (list + retrieve).
lib/humaans/resources/audit_event.ex Defines Humaans.Resources.AuditEvent struct + timestamp parsing.
lib/humaans/resources/role.ex Defines Humaans.Resources.Role struct.
lib/humaans/resources/role_member.ex Defines Humaans.Resources.RoleMember struct.
lib/humaans/resources/role_permission.ex Defines Humaans.Resources.RolePermission struct.
lib/humaans/resources/task.ex Defines Humaans.Resources.Task struct + date/datetime parsing.
lib/humaans/resources/okr.ex Defines Humaans.Resources.OKR struct + datetime parsing.
lib/humaans/resources/webhook_event.ex Defines Humaans.Resources.WebhookEvent struct + datetime parsing.
test/humaans/audit_events_test.exs Adds retrieve tests + guard that non-supported actions aren’t exported.
test/humaans/roles_test.exs Adds list/retrieve tests + guard that write actions aren’t exported.
test/humaans/role_members_test.exs Adds list/retrieve tests + guard that write actions aren’t exported.
test/humaans/role_permissions_test.exs Adds list/retrieve tests + guard that write actions aren’t exported.
test/humaans/tasks_test.exs Adds list/retrieve tests + guard that write actions aren’t exported.
test/humaans/okrs_test.exs Adds list/retrieve tests + guard that write actions aren’t exported.
test/humaans/webhook_events_test.exs Adds list/retrieve tests + guard that write actions aren’t exported.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +17 to +19
expect(Humaans.MockHTTPClient, :request, fn _, opts ->
assert Keyword.fetch!(opts, :url) == "https://app.humaans.io/api/webhook-events"

Comment on lines +17 to +19
expect(Humaans.MockHTTPClient, :request, fn _, opts ->
assert Keyword.fetch!(opts, :url) == "https://app.humaans.io/api/tasks"

Comment on lines +17 to +19
expect(Humaans.MockHTTPClient, :request, fn _, opts ->
assert Keyword.fetch!(opts, :url) == "https://app.humaans.io/api/okrs"

Comment on lines +17 to +19
expect(Humaans.MockHTTPClient, :request, fn _, opts ->
assert Keyword.fetch!(opts, :url) == "https://app.humaans.io/api/role-permissions"

Comment on lines +17 to +20
expect(Humaans.MockHTTPClient, :request, fn _, opts ->
assert Keyword.fetch!(opts, :method) == :get
assert Keyword.fetch!(opts, :url) == "https://app.humaans.io/api/role-members"

Comment on lines +17 to +21
expect(Humaans.MockHTTPClient, :request, fn client_param, opts ->
assert client_param == client
assert Keyword.fetch!(opts, :method) == :get
assert Keyword.fetch!(opts, :url) == "https://app.humaans.io/api/roles"

expect(Humaans.MockHTTPClient, :request, fn client_param, opts ->
assert client_param == client
assert Keyword.fetch!(opts, :method) == :get
assert Keyword.fetch!(opts, :url) == "https://app.humaans.io/api/audit-events/ae_abc"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants