Skip to content

feat(inquiries): add getByApplication - #11

Merged
thinkclay merged 1 commit into
mainfrom
fix/inquiries-get-by-application
Jul 30, 2026
Merged

thinkclay merged 1 commit into
mainfrom
fix/inquiries-get-by-application

Conversation

@thinkclay

Copy link
Copy Markdown
Contributor

Part of Scaffald/SaaS#443, which is the "Unable to load inquiry" bug in Scaffald/SaaS#440.

Why

The Scaffald app calls client.inquiries.getByApplication(applicationId) to load the capability inquiry attached to an application. The method did not exist. The call site papered over it:

return (client.inquiries as unknown as InquiryCapabilityClient).getByApplication(applicationId)

That cast silenced the missing-method type error, so it failed at runtime and the page rendered a red "Unable to load inquiry" instead. Only the legacy tRPC router had a real implementation.

What

getByApplication(applicationId): Promise<InquiryDetails | null>, backed by GET /v1/inquiries/by-application/{applicationId} (added in the companion server PR), ported from that tRPC procedure.

Resolves to null when the application has no inquiry yet — a normal state that callers should render as an empty state, not a failure.

Types come from the schema, not from guesses

Removing the cast made the caller's typecheck meaningful again, and it immediately caught two things the cast had been hiding:

  • InquiryComment needs sender_id, content, read_by and section_name — all NOT NULL in core.inquiry_comments.
  • InquiryCapabilityResponse.response_value / response_text are nullable, which the consumer's type denied.

Both verified against the live schema rather than inferred.

Naming caveat

This models the ATS capability-inquiry feature (core.application_inquiries), which is a different concept from the sender/recipient Inquiry that list and create model. Those two currently read core.inquiries — a table that does not exist in the database at all. Filed separately on the app repo; not touched here.

Verification

  • tsc --noEmit clean on this package.
  • The consuming repo's scf-core typechecks clean against the built dist with the cast removed — that is the real proof the surface matches.
  • 12 new tests on the server side cover the endpoint's access decisions and response mapping.

The Scaffald app calls `client.inquiries.getByApplication(applicationId)` to load
the capability inquiry attached to an application. The method did not exist. An
`as unknown as InquiryCapabilityClient` cast at the call site silenced the
type error, so it failed at runtime instead and the page rendered
"Unable to load inquiry".

Backed by GET /v1/inquiries/by-application/{applicationId}, ported from the
legacy tRPC procedure that was the only implementation.

Resolves to null when the application has no inquiry yet — a normal state
callers should render as empty, not as a failure.

Types are derived from the actual schema rather than guessed, which the caller's
typecheck immediately proved necessary:

  * InquiryComment carries sender_id, content, read_by and section_name; all are
    NOT NULL in core.inquiry_comments.
  * InquiryCapabilityResponse.response_value / response_text are nullable.

Note this models the ATS capability-inquiry feature
(core.application_inquiries), which is a different concept from the
sender/recipient `Inquiry` that list/create model.

Refs Scaffald/SaaS#443

Co-Authored-By: Claude Opus 5 <[email protected]>
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.

1 participant