Skip to content

feat(documents): add Documents, Document Types, and Document Folders#102

Open
sgerrand wants to merge 4 commits into
mainfrom
feat/documents
Open

feat(documents): add Documents, Document Types, and Document Folders#102
sgerrand wants to merge 4 commits into
mainfrom
feat/documents

Conversation

@sgerrand
Copy link
Copy Markdown
Owner

@sgerrand sgerrand commented May 4, 2026

💁 These changes add CRUD coverage for the three Documents-related resources, foundational for any onboarding-pipeline integration.

Summary

  • `Humaans.Documents` — `/api/documents` (full CRUD, including nested file metadata)
  • `Humaans.DocumentTypes` — `/api/document-types` (list/create/retrieve/update — the API does not support DELETE; a guard test asserts `delete/2` is not exported)
  • `Humaans.DocumentFolders` — `/api/document-folders` (full CRUD, with audience-rules and `deletedAt`)

Each ships as struct + module + tests using `Humaans.Resource`. Helpers and README updated.

Addresses Group D1 (Documents family) of the API coverage review.

Test plan

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

sgerrand added 4 commits May 4, 2026 15:21
Adds Humaans.Documents covering /api/documents. Documents associate a
person with a file (or external link) categorised by type and folder;
the struct mirrors the documented fields including the nested file
metadata.
Adds Humaans.DocumentTypes covering /api/document-types. The API does
not support DELETE so the resource declares actions [:list, :create,
:retrieve, :update] explicitly; a guard test asserts delete/2 is not
exported.
Adds Humaans.DocumentFolders covering /api/document-folders. Folders
group documents and carry an audience definition (type + rules) that
controls visibility; the struct exposes the documented fields including
deletedAt for soft-deleted folders.
Copilot AI review requested due to automatic review settings May 4, 2026 15:17
@coveralls
Copy link
Copy Markdown

Coverage Report for CI Build 25327281444

Coverage decreased (-1.5%) to 98.485%

Details

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

Uncovered Changes

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

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 198
Covered Lines: 195
Line Coverage: 98.48%
Coverage Strength: 21.44 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 the Documents resource family to the Elixir client so the library can access document records, document types, and document folders as first-class API modules, which aligns with the repo’s pattern of wrapping Humaans endpoints as resource modules plus structs and tests.

Changes:

  • Adds three new resource modules: Humaans.Documents, Humaans.DocumentTypes, and Humaans.DocumentFolders.
  • Adds matching resource structs for document, document type, and document folder payloads, including timestamp/date parsing.
  • Extends docs/tests by updating the README, adding resource test suites, and exposing new module access helpers on Humaans.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
test/humaans/documents_test.exs Adds CRUD tests for document requests and response shaping.
test/humaans/document_types_test.exs Adds tests for document-type list/create/retrieve/update and no-delete behavior.
test/humaans/document_folders_test.exs Adds CRUD tests for document-folder requests and response shaping.
README.md Lists the three new document-related resource modules.
lib/humaans/resources/document.ex Defines the Document struct and date/datetime parsing.
lib/humaans/resources/document_type.ex Defines the DocumentType struct and timestamp parsing.
lib/humaans/resources/document_folder.ex Defines the DocumentFolder struct and timestamp parsing.
lib/humaans/documents.ex Adds the documents API wrapper via Humaans.Resource.
lib/humaans/document_types.ex Adds the document-types API wrapper with delete disabled.
lib/humaans/document_folders.ex Adds the document-folders API wrapper via Humaans.Resource.
lib/humaans.ex Exposes top-level helpers for the three new resource modules.

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

Comment on lines +17 to +20
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/documents"
Comment on lines +17 to +20
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/document-types"
Comment on lines +17 to +20
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/document-folders"
Comment thread lib/humaans.ex
Comment on lines +199 to +213
def documents, do: Humaans.Documents

@doc """
Access the Document Types API.

Returns the module that contains functions for working with document type resources.
"""
def document_types, do: Humaans.DocumentTypes

@doc """
Access the Document Folders API.

Returns the module that contains functions for working with document folder resources.
"""
def document_folders, do: Humaans.DocumentFolders
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